帮我看看哪里错了?捕获不到摄像头……(100分)

  • 主题发起人 主题发起人 zhenh
  • 开始时间 开始时间
Z

zhenh

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
begin

SysDev:= TSysDevEnum.Create(CLSID_VideoInputDeviceCategory);
if sysdev.CountFilters>0 then

for i:=0 to sysdev.CountFilters-1do

begin

combobox1.Items.Text:=SysDev.Filters.FriendlyName;
combobox1.ItemIndex:=i;
end;


end;


procedure TForm1.Button1Click(Sender: TObject);
begin

FilterGraph1.ClearGraph;
FilterGraph1.Active := false;
Filter1.BaseFilter.Moniker := SysDev.GetMoniker(combobox1.ItemIndex);
FilterGraph1.Active := true;
with FilterGraph1 as ICaptureGraphBuilder2do

begin


if Filter1.BaseFilter.DataLength > 0 then

RenderStream(@PIN_CATEGORY_PREVIEW, nil, Filter1 as IBaseFilter,
nil , VideoWindow1 as IBaseFilter);

// Connect Video capture streams
if Filter1.FilterGraph <> nil then

RenderStream(@PIN_CATEGORY_CAPTURE, nil, Filter1 as IBaseFilter,
nil, VideoWindow1 as IBaseFilter);

end;

FilterGraph1.Play;
end;
 
后退
顶部