For Newbie

Tuesday, 23 August 2011

Step By Step Create Application to Capture Photo/ Picture Using Delphi 7.0 by DsPack

These are the step of how making picture/photo capturer program using Delphi with Ds Pack Component

1. Open Borland Delphi 7
 2. In the available Form, enter the following component from DS Pack Component Palllete and the other.

No. Component  Pallete Component Name Property Value
1 Standard Button1 Caption Start
Name BtnStart
2 Standard Button 2 Cation Capture
Name BtnFoto
3 Standard Combo box 1 Text -
4 Additional Image1 Proportional True
5 DS Pack FilterGraph1 Active False
Auto create False
Graph edit True
Linear volume True
Mode Gmcapture
6 SampleGrabber1 FilterGraph FilterGraph1
7 Filter1 FilterGraph FilterGraph1
8 VideoWindow1 FilterGraph FilterGraph1
9 Mode VmNormal

3.Arrange those components so that at least having same image with the picture below. 



Picture1. Step By Step Create Application to Capture Photo/ Picture Using Delphi 7.0 by DsPack : Visualization Program Design

4.Declare a Global Variable “CapEnum: TSySDevEnum” in writing column in the position as follows:

 Picture2. Step By Step Create Application to Capture Photo/ Picture Using Delphi 7.0 by DsPack : Variable Declaration.
5. Enter this following source code:
No Component Name Source code Note
1 BtnStart (Onclick) var i: integer;

begin

CapEnum:=TSysDevEnum.Create(CLSID_VideoInputDeviceCategory);

For i:=0 to CapEnum.CountFilters-1 do

begin

combobox1.Items.Add(CapEnum.Filters[i].FriendlyName);
2 BtnCapture (OnClick) samplegrabber1.GetBitmap(Image1.Picture.Bitmap);
3 Combobox1 (OnChange) FilterGraph1.ClearGraph;

FilterGraph1.Active := false;

Filter1.BaseFilter.Moniker := capenum.GetMoniker(combobox1.ItemIndex);

FilterGraph1.Active := true;

with FilterGraph1 as ICaptureGraphBuilder2 do

RenderStream(@PIN_CATEGORY_PREVIEW, nil, Filter1 as IBaseFilter, SampleGrabber1 as IBaseFilter, VideoWindow1 as IbaseFilter);FilterGraph1.Play;
Infor
mation 1
Form 1 (Form Create) capenum.Free;

FilterGraph1.ClearGraph;

FilterGraph1.Active := false;
Infor
mation 2
Information1: click the combo box component, then in object inspector choose event tab, in “On click” option choose combobox1 click or double click directly in combobox1 component. Enter the code in the table above

Information 2: click the form 1,

Click event tab then double click in the right option event on close query type the code above
picture 3. Step By Step Create Application to Capture Photo/ Picture Using Delphi 7.0 by DsPack :Close query


6. Add/type DirectShow9,Dsutil, in the uses part until it appears like the following below: 

picture . Step By Step Create Application to Capture Photo/ Picture Using Delphi 7.0 by DsPack : add DirectShow9,Dsutil,
7. Program is done; please press the run button in IDE Borland Delphi 7, or by press the F9 button in the keyboard. This is the result of the experimental program which has been made.
Picture 3. Step By Step Create Application to Capture Photo/ Picture Using Delphi 7.0 by DsPack : The result Aplication

 I hope this article can give benefit to the visitors, readers, developer and me. Thanks for visiting and availability for sharing this article by pressing 
Share this on Facebook
or just press like button under this posting

Share on Facebook
Share on Twitter
Share on Google+

Related : Step By Step Create Application to Capture Photo/ Picture Using Delphi 7.0 by DsPack