我想在DSPACK显示的视频中(用的摄像头)加一个红色的框,然后将这个框中的视频保存保存为一个JPG文件。
主要用来拍证件照片。不知道DSPACK能够实现吗?
请指点下。
如果解决后,再追加100分。
谢谢!
主要用来拍证件照片。不知道DSPACK能够实现吗?
请指点下。
如果解决后,再追加100分。
谢谢!
解决方案 »
- 如何将SQL的“0行受影响”等信息在Delphi的showmessage里表示出来?
- 关于消息
- 控件的子属性如何通过代码设置?
- 急求帮助解决串口通信问题,请各位大哥帮忙。
- 如何在F1Book控件中嵌入一个Combobox控件! 如何改变列名的字体,如何改变某行的颜色?
- 關於文件屬性的操作!!
- 十万火急!!!mdi文档问题
- 如何在程序中创建TADOConnection
- 请问各位大侠,在delphi中怎样调用DLL,多谢了
- DELPHI 大富翁怎么啦
- 哪位大哥知道DSPask里的ControlStream怎么用?
- 动态创建shape控件,并想在运行时实现对shape的拖动,并可以用鼠标进行大小的拖拉
dspack的例子我都看了,没有看到相关的例子。
或者是我没有看明白是哪个例子,麻烦多指点下。
MyFilterGraph: TFilterGraph;
MyVideoWindow: TVideoWindow;
MyFilter: TFilter;
MySampleGrabber: TSampleGrabber;一、加一个红色的框
{在属性中设定}
MyVideoWindow.Mode := vmVMR; // 关键设置
MyVideoWindow.FilterGraphi := MyFilterGraph;procedure VMRRect(VideoWindow: TVideoWindow; Rt: TRect);
var
VMRBitmap: TVMRBitmap;
begin
if VideoWindow = nil then Exit; VMRBitmap := TVMRBitmap.Create(VideoWindow); with VMRBitmap, Canvas do
begin
LoadEmptyBitmap(VideoWindow.Width, VideoWindow.Height, pf24bit, clSilver);
Source := VMRBitmap.Canvas.ClipRect;
Options := VMRBitmap.Options + [vmrbSrcColorKey];
ColorKey := clSilver; Brush.Style := bsClear;
//Brush.Color := clSilver;
Pen.Color := clRed;
//Pen.width := 2;
Rectangle(Rt);
DrawTo(0, 0, 1, 1, 1);
end; VMRBitmap.Free;
end;比如调用
VMRRect(MyVideoWindow, Rect(10, 10, 10+150, 10+200));
将在视窗上(10, 10)位置画出 150 x 200 红线框。二、将这个框中的视频保存保存为一个JPG文件
{在属性中设定}
MySampleGrabber.FilterGraphi := MyFilterGraph;procedure CaptureRect(SampleGrabber: TSampleGrabber; Rt: TRect; PicName: string='c:\photo.jpg');
var
srcBMP, rtBmp : TBitmap;
JPG : TJPEGImage;
begin
srcBMP := TBitmap.Create;
rtBmp := TBitmap.Create;
JPG := TJPEGImage.Create;
try
SampleGrabber.GetBitmap(srcBMP);
with rtBmp,Canvas do
begin
Width := Rt.Right - Rt.Left;
Height := Rt.Bottom - Rt.Top;
CopyRect(ClipRect, srcBMP.Canvas, Rt);
end;
JPG.Assign(rtBmp);
JPG.SaveToFile(PicName);
finally
rtBmp.Free;
JPG.Free;
srcBMP.Free;
end;
end;比如调用
CaptureRect(MySampleGrabber, Rect(10, 10, 10+150, 10+200));
将照片保存为c:\photo.jpg
当我这样调用 的时候,视频全部都是白色了的,就是视频不见了,请问是什么原因呀?!
procedure TForm1.MyVideoWindowMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
VMRRect(MyVideoWindow, Rect(x, y, x + 150, y + 200));
end;解决后立即另开一贴100分相谢。太感谢您了。
Brush.Color := clSilver;
Brush.Style := bsClear;
或者MyVideoWindow属性没设置好2.鼠标的位置为中心,最好能够拖动这个红色的框
// 鼠标按下,将照片保存
procedure TForm1.MyVideoWindowMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
CaptureRect(MySampleGrabber, Rect(X-75,y-100,x+75,y+100));
end;// 框随着鼠标移动,中心重合
procedure TForm1.MyVideoWindowMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
VMRRect(MyVideoWindow, Rect(X-75,y-100,x+75,y+100));
end;具体功能自己完善一下
Brush.Color := clSilver;
Brush.Style := bsClear;
或者MyVideoWindow属性没设置好
这个还是问题,没有解决!!!
有可能是DSPACK版本或运行环境不一样,你自己去找找原因…… LoadEmptyBitmap(VideoWindow.Width, VideoWindow.Height, pf24bit, ColorKey);
Options := VMRBitmap.Options + [vmrbSrcColorKey];
Source := VMRBitmap.Canvas.ClipRect; Brush.Color := ColorKey;
Brush.Style := bsClear;
procedure TForm1.MyVideoWindowMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
CaptureRect(MySampleGrabber, Rect(X-75,y-100,x+75,y+100));
end;
我使用ShowPinPropertyPage调出视频对话窗查看时,发现里面的输出大小为640*480,而想设置成其他,比如320*240的时候,竟然设置不了,提示说“当前没有这种格式”(而用TVideoCap的时候却可以设置的)。
我在想是不是和这个有关系?!