Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to use webcam in Delphi Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
12-Jun-03
Category
ActiveX
Language
Delphi 5.x
Views
256
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jean Claude Servaye

Do you need to takes pictures from your Delphi application ?

Answer:

First of all, get the SDK at 
http://developer.logitech.comhttp://developer.logitech.com

After installation, open delphi and Import ActiveX Control VPortal2 from the list. 

Now, create a new form, and put a VideoPortal from the ActiveX panel and a button. 

In the uses, add VideoPortal 

On the OnShow add: 

1   VideoPortal1.PrepareControl('QCSDK',
2     'HKEY_LOCAL_MACHINE\Software\JCS Programmation\QCSDK', 0);
3   VideoPortal1.EnableUIElements(UIELEMENT_STATUSBAR, 0, 0);
4   VideoPortal1.ConnectCamera2;
5   VideoPortal1.EnablePreview := 1;
6   
7   //On the ButtonClick add: 
8   
9   var
10    BMP: TBitmap;
11    JPG: TJpegImage;
12    L: string;
13  begin
14    F := 'Photos\test.jpg';
15    VideoPortal1.StampBackgroundColor := clYellow;
16    VideoPortal1.StampTextColor := clBlack;
17    VideoPortal1.StampFontName := 'Arial';
18    VideoPortal1.StampPointSize := 10;
19    VideoPortal1.StampTransparentBackGround := 0;
20    L := Format(' %s - %s ', [DateTimeToStr(Now), Num]);
21    VideoPortal1.PictureToFile(0, 24, 'Temp.bmp', L);
22    BMP := TBitmap.Create;
23    JPG := TJpegImage.Create;
24    BMP.LoadFromFile('Temp.bmp');
25    JPG.CompressionQuality := 85;
26    JPG.Assign(BMP);
27    JPG.SaveToFile(F);
28    BMP.Free;
29    JPG.Free;
30  end;


It's all, run the application, you will see the image from the camera, click on the 
button to get a picture. 

Here is a copy a VideoPortal.Pas (constants). 

31  unit VideoPortal;
32  
33  interface
34  // Copyright (c) 1996-2000 Logitech, Inc.  All Rights Reserved
35  // User Interface Element, codes used with EnableUIElement method
36  const
37    UIELEMENT_640x480 = 0;
38  const
39    UIELEMENT_320x240 = 1;
40  const
41    UIELEMENT_PCSMART = 2;
42  const
43    UIELEMENT_STATUSBAR = 3;
44  const
45    UIELEMENT_UI = 4;
46  const
47    UIELEMENT_CAMERA = 5;
48  const
49    UIELEMENT_160x120 = 6;
50  
51    // Camera status codes, returned by CameraState property
52  const
53    CAMERA_OK = 0;
54  const
55    CAMERA_UNPLUGGED = 1;
56  const
57    CAMERA_INUSE = 2;
58  const
59    CAMERA_ERROR = 3;
60  const
61    CAMERA_SUSPENDED = 4;
62  const
63    CAMERA_DUAL_DETACHED = 5;
64  const
65    CAMERA_UNKNOWNSTATUS = 10;
66  
67    // Movie Recording Modes, used with MovieRecordMode property
68  const
69    SEQUENCECAPTURE_FPS_USERSPECIFIED = 1;
70  const
71    SEQUENCECAPTURE_FPS_FASTASPOSSIBLE = 2;
72  const
73    STEPCAPTURE_MANUALTRIGGERED = 3;
74  
75    // Movie Creation Flags, used with MovieCreateFlags property
76  const
77    MOVIECREATEFLAGS_CREATENEW = 1;
78  const
79    MOVIECREATEFLAGS_APPEND = 2;
80  
81    // Notification Codes
82  const
83    NOTIFICATIONMSG_MOTION = 1;
84  const
85    NOTIFICATIONMSG_MOVIERECORDERROR = 2;
86  const
87    NOTIFICATIONMSG_CAMERADETACHED = 3;
88  const
89    NOTIFICATIONMSG_CAMERAREATTACHED = 4;
90  const
91    NOTIFICATIONMSG_IMAGESIZECHANGE = 5;
92  const
93    NOTIFICATIONMSG_CAMERAPRECHANGE = 6;
94  const
95    NOTIFICATIONMSG_CAMERACHANGEFAILED = 7;
96  const
97    NOTIFICATIONMSG_POSTCAMERACHANGED = 8;
98  const
99    NOTIFICATIONMSG_CAMERBUTTONCLICKED = 9;
100 const
101   NOTIFICATIONMSG_VIDEOHOOK = 10;
102 const
103   NOTIFICATIONMSG_SETTINGDLGCLOSED = 11;
104 const
105   NOTIFICATIONMSG_QUERYPRECAMERAMODIFICATION = 12;
106 const
107   NOTIFICATIONMSG_MOVIESIZE = 13;
108 
109   // Error codes used by NOTIFICATIONMSG_MOVIERECORDERROR notification:
110 const
111   WRITEFAILURE_RECORDINGSTOPPED = 0;
112 const
113   WRITEFAILURE_RECORDINGSTOPPED_FILECORRUPTANDDELETED = 1;
114 const
115   WRITEFAILURE_CAMERA_UNPLUGGED = 2;
116 const
117   WRITEFAILURE_CAMERA_SUSPENDED = 3;
118 
119   // Camera type codes, returned by GetCameraType method
120 const
121   CAMERA_UNKNOWN = 0;
122 const
123   CAMERA_QUICKCAM_VC = 1;
124 const
125   CAMERA_QUICKCAM_QUICKCLIP = 2;
126 const
127   CAMERA_QUICKCAM_PRO = 3;
128 const
129   CAMERA_QUICKCAM_HOME = 4;
130 const
131   CAMERA_QUICKCAM_PRO_B = 5;
132 const
133   CAMERA_QUICKCAM_TEKCOM = 6;
134 const
135   CAMERA_QUICKCAM_EXPRESS = 7;
136 const
137   CAMERA_QUICKCAM_FROG = 8; // MIGHT CHANGE NAME BUT ENUM STAYS THE SAME
138 const
139   CAMERA_QUICKCAM_EMERALD = 9; // MIGHT CHANGE NAME BUT ENUM STAYS THE SAME
140 
141   // Camera-specific property codes used by Set/GetCameraPropertyLong
142 const
143   PROPERTY_ORIENTATION = 0;
144 const
145   PROPERTY_BRIGHTNESSMODE = 1;
146 const
147   PROPERTY_BRIGHTNESS = 2;
148 const
149   PROPERTY_CONTRAST = 3;
150 const
151   PROPERTY_COLORMODE = 4;
152 const
153   PROPERTY_REDGAIN = 5;
154 const
155   PROPERTY_BLUEGAIN = 6;
156 const
157   PROPERTY_SATURATION = 7;
158 const
159   PROPERTY_EXPOSURE = 8;
160 const
161   PROPERTY_RESET = 9;
162 const
163   PROPERTY_COMPRESSION = 10;
164 const
165   PROPERTY_ANTIBLOOM = 11;
166 const
167   PROPERTY_LOWLIGHTFILTER = 12;
168 const
169   PROPERTY_IMAGEFIELD = 13;
170 const
171   PROPERTY_HUE = 14;
172 const
173   PROPERTY_PORT_TYPE = 15;
174 const
175   PROPERTY_PICTSMART_MODE = 16;
176 const
177   PROPERTY_PICTSMART_LIGHT = 17;
178 const
179   PROPERTY_PICTSMART_LENS = 18;
180 const
181   PROPERTY_MOTION_DETECTION_MODE = 19;
182 const
183   PROPERTY_MOTION_SENSITIVITY = 20;
184 const
185   PROPERTY_WHITELEVEL = 21;
186 const
187   PROPERTY_AUTO_WHITELEVEL = 22;
188 const
189   PROPERTY_ANALOGGAIN = 23;
190 const
191   PROPERTY_AUTO_ANALOGGAIN = 24;
192 const
193   PROPERTY_LOWLIGHTBOOST = 25;
194 const
195   PROPERTY_COLORBOOST = 26;
196 const
197   PROPERTY_ANTIFLICKER = 27;
198 const
199   PROPERTY_OPTIMIZATION_SPEED_QUALITY = 28;
200 const
201   PROPERTY_STREAM_HOOK = 29;
202 const
203   PROPERTY_LED = 30;
204 
205 const
206   ADJUSTMENT_MANUAL = 0;
207 const
208   ADJUSTMENT_AUTOMATIC = 1;
209 
210 const
211   ORIENTATIONMODE_NORMAL = 0;
212 const
213   ORIENTATIONMODE_MIRRORED = 1;
214 const
215   ORIENTATIONMODE_FLIPPED = 2;
216 const
217   ORIENTATIONMODE_FLIPPED_AND_MIRRORED = 3;
218 
219 const
220   COMPRESSION_Q0 = 0;
221 const
222   COMPRESSION_Q1 = 1;
223 const
224   COMPRESSION_Q2 = 2;
225 
226 const
227   ANTIFLICKER_OFF = 0;
228 const
229   ANTIFLICKER_50Hz = 1;
230 const
231   ANTIFLICKER_60Hz = 2;
232 
233 const
234   OPTIMIZE_QUALITY = 0;
235 const
236   OPTIMIZE_SPEED = 1;
237 
238 const
239   LED_OFF = 0;
240 const
241   LED_ON = 1;
242 const
243   LED_AUTO = 2;
244 const
245   LED_MAX = 3;
246 
247 const
248   PICTSMART_LIGHTCORRECTION_NONE = 0;
249 const
250   PICTSMART_LIGHTCORRECTION_COOLFLORESCENT = 1;
251 const
252   PICTSMART_LIGHTCORRECTION_WARMFLORESCENT = 2;
253 const
254   PICTSMART_LIGHTCORRECTION_OUTSIDE = 3;
255 const
256   PICTSMART_LIGHTCORRECTION_TUNGSTEN = 4;
257 
258 const
259   PICTSMART_LENSCORRECTION_NORMAL = 0;
260 const
261   PICTSMART_LENSCORRECTION_WIDEANGLE = 1;
262 const
263   PICTSMART_LENSCORRECTION_TELEPHOTO = 2;
264 
265 const
266   CAMERADLG_GENERAL = 0;
267 const
268   CAMERADLG_ADVANCED = 1;
269 
270 implementation
271 end.
272 
273 //Example shows how to use the PictureToMemory method in the QuickCam SDK. 
274 
275 type
276   TMemoryStream = class(Classes.TMemoryStream);
277 
278 var
279   MS: TMemoryStream;
280   lSize: LongInt;
281   pBuffer: ^Byte;
282 
283 begin
284 
285   MS := TMemoryStream.Create;
286   bitmap1 := TBitmap.Create;
287 
288   try
289     if VideoPortal1.PictureToMemory(0, 24, 0, lSize, '') = 1 then
290     begin
291       pBuffer := AllocMem(lSize);
292       if VideoPortal1.PictureToMemory(0, 24, integer(pBuffer), lSize, '') = 1 then
293       begin
294         MS.SetPointer(pBuffer, lSize);
295         bitmap1.loadfromstream(MS);
296       end;
297     end;
298   finally
299     MS.Free;
300     FreeMem(pBuffer);
301   end;
302 end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC