关于视频图像采集,我出500分或者更高! (200分)

  • 主题发起人 主题发起人 blacksnow
  • 开始时间 开始时间
B

blacksnow

Unregistered / Unconfirmed
GUEST, unregistred user!
我们厂需要用视频卡监视场地的作业情况,要求
1。动态的视频画面在自己程序的窗口内显示(比如在一个Panel或者Bevel)
不用视频卡本身的程序
2。可以随时将画面定格并且保存为jpg格式图像,然后继续动态显示图像。
3。用带sdk开发包和不带开发包的视频卡,各需要怎么做?
时间紧急,各位大虾赶快出手~~
另外如果讲解详细,分不问题~~~谢谢
 
1,看msdn,在search里输入video capture,看video capture 的帮助。
2,video capture里提供截取图像的函数,不过是bmp的,如果想弄成jpg的,装个
图像转换方面的控件或者什么的。
3,带不带开发包到不是很关键,只要符合微软的标准就成。可以用vfw进行编程。
这样的卡很多的,随便找一块就成。
 
用带开发包的视频卡,一般是控件或者DDL
 
1。如果有sdk的话,可以通过sdk写很容易,我们公司以前也是搞视频的,只要厂商的sdk支持
全面;
2。如果没有sdk的话,可以通过directx中的directdraw和directshow来实现,相对比较难。
以上是显示,显示后,抓图就很简单。
例如这样的视频卡很多,如TV capture98等等。
 
能否再详细一点?各位!谢了,我第一次亲密接触这个,呵呵
 
use video for windows api
but you should find some components in the internet.such as tvideo etc.
very easy.
 
http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=116436
 
使用WIN API 的 MCI 函数集,原理是:
用mci将采集卡采来的一帧图放到剪贴板上,(你的程序上放image控件)利用
image提供的属性 把剪贴板上的图画到image上,你得放两个image,用timer控制
两个image交互显示(画好图的image显示,没画好的image不显示)。

以下是我编的代码,供参考(别忘了给我加分哦)
--------------------------------------------------------------
unit Unit_mci;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ExtCtrls, MPlayer, mmsystem, ComCtrls, Clipbrd, Buttons,
ExtDlgs;

type
TForm1 = class(TForm)
Panel2: TPanel;
Panel1: TPanel;
StatusBar1: TStatusBar;
Image1: TImage;
SpeedButton1: TSpeedButton;
Timer1: TTimer;
Image2: TImage;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
sp_8_24: TSpeedButton;
SavePictureDialog1: TSavePictureDialog;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure SpeedButton1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure sp_8_24Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
procedure SpeedButton8Click(Sender: TObject);
private
cat_sp_24_8:boolean;
{ Private declarations }
public
procedure mci_SendString(command_str:pchar);
function PlayAviWindow(x_image_1,x_image_2:Timage):boolean;
procedure VideoLoad;
{ Public declarations }
end;

var
Form1: TForm1;

{$R cat_capture.res} //引用资源文件

implementation

uses Unit_mci_source, Unit_mci_change;

{$R *.DFM}

//-----------.* * 自定义函数/过程 * *.-------------------------
// *
// * 过程:mci_SendString(command_str:pchar)
// * 功能:封装 API -> MciSendString(...)
//API 原形(在 mmsystem.pas 中):
//function mciSendString(lpstrCommand, lpstrReturnString: PChar;
// uReturnLength: UINT; hWndCallback: HWND): MCIERROR; stdcall;
procedure TForm1.mci_SendString(command_str:pchar);
var
ret : Longint;
tstr : array[0..200] of char;
begin
ret := mciSendString(command_str,nil,0,0); // ?form1
//...
end;

function TForm1.PlayAviWindow(x_image_1,x_image_2:Timage):boolean; //自定义
begin
result := false;
StatusBar1.SimpleText := '播放视频……';
//
mci_sendstring('copy cat_mci'); //300x200
if Clipboard.HasFormat(CF_BITMAP)=true then
begin
if x_image_1.Visible=false then
begin
x_image_1.Picture.Assign(Clipboard);
x_image_2.Visible := false;
x_image_1.Visible := true;
end else begin
x_image_2.Picture.Assign(Clipboard);
x_image_1.Visible := false;
x_image_2.Visible := true;
end;
mci_SendString('unfreeze cat_mci');
//
result := true;
end;
end;

procedure TForm1.VideoLoad; //加载图象时初始化图象性质
begin
mci_Sendstring('freeze cat_Mci');
mci_SendString('SetVideo cat_mci bitsperpel to 24');
mci_Sendstring('unfreeze cat_Mci');
sp_8_24.Glyph.Handle := LoadBitmap(HInstance,'A_24_8');
sp_8_24.Hint := '转换成黑白图象';
end;

//==================================================

procedure TForm1.FormCreate(Sender: TObject);
begin
speedbutton2.Enabled := false;
speedbutton3.Enabled := false;
speedbutton4.Enabled := false;
speedbutton5.Enabled := false;
speedbutton6.Enabled := false;
sp_8_24.Enabled := false;
//
cat_sp_24_8 :=false;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
mci_SendString('close cat_mci');
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
mci_SendString('open overlay alias cat_mci');
VideoLoad;
timer1.enabled := true;
//
speedbutton2.Enabled := true;
speedbutton3.Enabled := true;
speedbutton4.Enabled := true;
speedbutton5.Enabled := true;
speedbutton6.Enabled := true;
sp_8_24.Enabled := true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if PlayAviWindow(image1,image2)=false then
application.MessageBox('播放视频失败。','MCI 设备',mb_ok+mb_iconStop);
end;

procedure TForm1.sp_8_24Click(Sender: TObject); // -- ok --
begin
mci_SendString('freeze cat_mci');
if cat_sp_24_8=false then
begin
mci_SendString('SetVideo cat_mci bitsperpel to 8');
sp_8_24.Glyph.Handle := LoadBitmap(HInstance,'A_8_24');
cat_sp_24_8 := true;
sp_8_24.Hint := '转换成彩色图象';
end else begin
mci_SendString('SetVideo cat_mci bitsperpel to 24');
sp_8_24.Glyph.Handle := LoadBitmap(HInstance,'A_24_8');
cat_sp_24_8 := false;
sp_8_24.Hint := '转换成黑白图象';
end;
mci_SendString('unfreeze cat_mci');
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
savePictureDialog1.Filter := '*.BMP|*.bmp+*.JPG|*.jpg';
savePictureDialog1.DefaultExt := 'BMP';
if SavePictureDialog1.Execute=true then
if image1.Visible=true then
image1.Picture.SaveToFile(SavePictureDialog1.filename)//'aa.bmp')
else
image2.Picture.SaveToFile(SavePictureDialog1.filename);//'aa.bmp');
end;

procedure TForm1.SpeedButton5Click(Sender: TObject);
var
aa1:string;
aa2:array[0..127] of char;
reg01:TRegistry;
begin
form_change.Caption := '调节亮度和饱和度';
//
if form_change.ShowModal=mrok then
begin
mci_sendstring('freeze cat_mci');
//
aa1 := strpas('setvideo cat_mci brightness to ');
aa1 := aa1+form_change.Edit1.text;
strpcopy(aa2,aa1);
mci_SendString(aa2);
//
aa1 := strpas('setvideo cat_mci color to ');
aa1 := aa1+form_change.Edit2.text;
strpcopy(aa2,aa1);
mci_SendString(aa2);
//
mci_Sendstring('unfreeze cat_mci');
end;
end;

procedure TForm1.SpeedButton6Click(Sender: TObject);
var
aa1:string;
aa2:array[0..127] of char;
reg02:Tregistry;
begin
form_change.Caption := '调节对比度和色调值';
//
if form_change.ShowModal=mrok then
begin
mci_Sendstring('freeze cat_mci');
//
aa1 := strpas('setvideo cat_mci contrast to ');
aa1 := aa1+form_change.Edit1.text;
strpcopy(aa2,aa1);
mci_SendString(aa2);
//
aa1 := strpas('setvideo cat_mci tint to ');
aa1 := aa1+form_change.Edit2.text;
strpcopy(aa2,aa1);
mci_SendString(aa2);
//
mci_Sendstring('unfreeze cat_mci');
end;
end;

procedure TForm1.SpeedButton4Click(Sender: TObject);
var
aa1:string;
aa2:array[0..127] of char;
begin
if form_source.ShowModal=mrok then
begin
mci_Sendstring('freeze cat_mci');
//
aa1 := strpas('setvideo cat_mci number ')+form_source.aa;
strpcopy(aa2,aa1);
mci_Sendstring(aa2);
//
mci_Sendstring('unfreeze cat_mci');
end;
end;

end.
 
多人接受答案了。
 
后退
顶部