1 | // 1394Camera.h: interface for the C1394Camera class.
|
---|
2 | //
|
---|
3 | // Version 5.2
|
---|
4 | //
|
---|
5 | // Copyright 5/2000
|
---|
6 | //
|
---|
7 | // Iwan Ulrich
|
---|
8 | // Robotics Institute
|
---|
9 | // Carnegie Mellon University
|
---|
10 | // Pittsburgh, PA
|
---|
11 | //
|
---|
12 | // Copyright 3/2002
|
---|
13 | //
|
---|
14 | // Christopher Baker
|
---|
15 | // Robotics Institute
|
---|
16 | // Carnegie Mellon University
|
---|
17 | // Pittsburgh, PA
|
---|
18 | //
|
---|
19 | // This program is free software; you can redistribute it and/or
|
---|
20 | // modify it under the terms of the GNU General Public License
|
---|
21 | // as published by the Free Software Foundation; either version 2
|
---|
22 | // of the License, or (at your option) any later version.
|
---|
23 | //
|
---|
24 | // This program is distributed in the hope that it will be useful,
|
---|
25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
27 | // GNU General Public License for more details.
|
---|
28 | //
|
---|
29 | // You should have received a copy of the GNU General Public License
|
---|
30 | // along with this program; if not, write to the Free Software
|
---|
31 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
32 | //
|
---|
33 | // Revision History...
|
---|
34 | //////////////////////////////////////////////////////////////////////
|
---|
35 |
|
---|
36 | #ifndef __1394CAMERA_H__
|
---|
37 | #define __1394CAMERA_H__
|
---|
38 |
|
---|
39 | #ifdef MY1394CAMERA_EXPORTS
|
---|
40 |
|
---|
41 | // compiling library, reference
|
---|
42 | // private, potentially modified
|
---|
43 | // version of the header
|
---|
44 | #include "1394camapi.h"
|
---|
45 |
|
---|
46 | #else
|
---|
47 |
|
---|
48 | // using library, use global version
|
---|
49 | #include "1394camapi.h"
|
---|
50 |
|
---|
51 | #endif // MY1394CAMERA_EXPORTS
|
---|
52 |
|
---|
53 | #include "1394CameraControl.h"
|
---|
54 | #include "1394CameraControlTrigger.h"
|
---|
55 | #include "1394CameraControlSize.h"
|
---|
56 |
|
---|
57 | // error codes
|
---|
58 |
|
---|
59 | #define CAM_SUCCESS 0
|
---|
60 | #define CAM_ERROR -1
|
---|
61 | #define CAM_ERROR_NOT_INITIALIZED 1
|
---|
62 | #define CAM_ERROR_INVALID_VIDEO_SETTINGS 2
|
---|
63 | #define CAM_ERROR_BUSY 3
|
---|
64 | #define CAM_ERROR_INSUFFICIENT_RESOURCES 4
|
---|
65 | #define CAM_ERROR_PARAM_OUT_OF_RANGE 5
|
---|
66 | #define CAM_ERROR_FRAME_TIMEOUT 6
|
---|
67 |
|
---|
68 | // structures used by C1394Camera
|
---|
69 |
|
---|
70 | /*
|
---|
71 | * ACQUISITION_BUFFER
|
---|
72 | *
|
---|
73 | * Associates all the necessary information for an image acquisition buffer
|
---|
74 | * This includes the overlapped structure used with DeviceIoControl, pointers
|
---|
75 | * to the buffer and other bookeeping stuff
|
---|
76 | */
|
---|
77 |
|
---|
78 | typedef struct _ACQUISITION_BUFFER {
|
---|
79 | OVERLAPPED overLapped;
|
---|
80 | PISOCH_ATTACH_BUFFERS pIsochAttachBuffers;
|
---|
81 | PUCHAR pDataBuf;
|
---|
82 | PUCHAR pFrameStart;
|
---|
83 | int index;
|
---|
84 | struct _ACQUISITION_BUFFER *pNextBuffer;
|
---|
85 | } ACQUISITION_BUFFER, *PACQUISITION_BUFFER;
|
---|
86 |
|
---|
87 | // the C1394Camera class
|
---|
88 | // member function implementations are in 1394Camera.cpp unless otherwise noted
|
---|
89 |
|
---|
90 | class CAMAPI C1394Camera
|
---|
91 | {
|
---|
92 | friend class C1394CameraControlSize;
|
---|
93 |
|
---|
94 | public:
|
---|
95 | // constructor
|
---|
96 | C1394Camera();
|
---|
97 | // destructor
|
---|
98 | ~C1394Camera();
|
---|
99 |
|
---|
100 | // Selection/Control
|
---|
101 | int InitCamera();
|
---|
102 | int GetNode();
|
---|
103 | int SelectCamera(int node);
|
---|
104 | unsigned long GetVersion();
|
---|
105 | int GetNumberCameras();
|
---|
106 | int GetMaxSpeed();
|
---|
107 | int CheckLink();
|
---|
108 |
|
---|
109 | // Store/Retrieve Settings from camera EEPROM
|
---|
110 | int MemGetNumChannels();
|
---|
111 | int MemGetCurrentChannel();
|
---|
112 | int MemLoadChannel(int channel);
|
---|
113 | int MemSaveChannel(int channel);
|
---|
114 |
|
---|
115 | // Store/Retrieve Settings from system Registry
|
---|
116 | int RegLoadSettings(const char *pname);
|
---|
117 | int RegSaveSettings(const char *pname);
|
---|
118 |
|
---|
119 | // Raw register I/O
|
---|
120 | int WriteQuadlet(unsigned long address, unsigned long data);
|
---|
121 | int ReadQuadlet(unsigned long address, unsigned long *pData);
|
---|
122 |
|
---|
123 | // Video format/mode/rate
|
---|
124 | int GetVideoFormat();
|
---|
125 | int SetVideoFormat(unsigned long format);
|
---|
126 | int GetVideoMode();
|
---|
127 | int SetVideoMode(unsigned long mode);
|
---|
128 | int GetVideoFrameRate();
|
---|
129 | int SetVideoFrameRate(unsigned long rate);
|
---|
130 |
|
---|
131 | // Image Capture (1394CamCap.cpp)
|
---|
132 | int StartImageCapture();
|
---|
133 | int CaptureImage();
|
---|
134 | int StopImageCapture();
|
---|
135 |
|
---|
136 | // Image Acquisition (1394CamAcq.cpp)
|
---|
137 | int StartImageAcquisition();
|
---|
138 | int AcquireImage();
|
---|
139 | int AcquireImageEx(BOOL DropStaleFrames, int *lpnDroppedFrames);
|
---|
140 | int StopImageAcquisition();
|
---|
141 |
|
---|
142 | // Synchronization Support
|
---|
143 | HANDLE GetFrameEvent();
|
---|
144 |
|
---|
145 | // Color Format Conversion (1394CamRGB.cpp)
|
---|
146 |
|
---|
147 | // convert data to standard: RGB, upper-left corner
|
---|
148 | // based on video format/mode
|
---|
149 | void getRGB(unsigned char *pBitmap);
|
---|
150 |
|
---|
151 | // same as getRGB, except data is returned in the
|
---|
152 | // bottom-up, BGR format the MS calls a DIB
|
---|
153 | void getDIB(unsigned char *pBitmap);
|
---|
154 |
|
---|
155 | // individual RGB converters
|
---|
156 | void YtoRGB(unsigned char *pBitmap);
|
---|
157 | void Y16toRGB(unsigned char *pBitmap);
|
---|
158 | void YUV411toRGB(unsigned char* pBitmap);
|
---|
159 | void YUV422toRGB(unsigned char* pBitmap);
|
---|
160 | void YUV444toRGB(unsigned char* pBitmap);
|
---|
161 | void RGB16toRGB(unsigned char *pBitmap);
|
---|
162 |
|
---|
163 | // Control Wrappers (ControlWrappers.cpp)
|
---|
164 | void InquireControlRegisters();
|
---|
165 | void StatusControlRegisters();
|
---|
166 | void SetIris(int value);
|
---|
167 | void SetFocus(int value);
|
---|
168 | void SetZoom(int value);
|
---|
169 | void SetBrightness(int value);
|
---|
170 | void SetAutoExposure(int value);
|
---|
171 | void SetSharpness(int value);
|
---|
172 | void SetWhiteBalance(int u, int v);
|
---|
173 | void SetHue(int value);
|
---|
174 | void SetSaturation(int value);
|
---|
175 | void SetGamma(int value);
|
---|
176 | void SetShutter(int value);
|
---|
177 | void SetGain(int value);
|
---|
178 |
|
---|
179 | // Control Members
|
---|
180 | // Feature_Hi
|
---|
181 | C1394CameraControl m_controlBrightness;
|
---|
182 | C1394CameraControl m_controlAutoExposure;
|
---|
183 | C1394CameraControl m_controlSharpness;
|
---|
184 | C1394CameraControl m_controlWhiteBalance;
|
---|
185 | C1394CameraControl m_controlHue;
|
---|
186 | C1394CameraControl m_controlSaturation;
|
---|
187 | C1394CameraControl m_controlGamma;
|
---|
188 | C1394CameraControl m_controlShutter;
|
---|
189 | C1394CameraControl m_controlGain;
|
---|
190 | C1394CameraControl m_controlIris;
|
---|
191 | C1394CameraControl m_controlFocus;
|
---|
192 | C1394CameraControlTrigger m_controlTrigger;
|
---|
193 | // there is a temperature control as well to worry about
|
---|
194 |
|
---|
195 | // Feature_Lo
|
---|
196 | C1394CameraControl m_controlZoom;
|
---|
197 | // there's also pan, tilt, and optical filter controls, but we don't care for now
|
---|
198 |
|
---|
199 | // Partial Scan Control class
|
---|
200 | C1394CameraControlSize m_controlSize;
|
---|
201 |
|
---|
202 | // utility members
|
---|
203 | int m_width;
|
---|
204 | int m_height;
|
---|
205 | bool m_linkChecked;
|
---|
206 | bool m_cameraInitialized;
|
---|
207 | char m_nameModel[256];
|
---|
208 | char m_nameVendor[256];
|
---|
209 | LARGE_INTEGER m_UniqueID;
|
---|
210 | unsigned char* m_pData;
|
---|
211 | bool m_bxAvailableFormats[8]; // [format]
|
---|
212 | bool m_bxAvailableModes[8][8]; //[format][mode]
|
---|
213 | bool m_videoFlags[8][8][8]; // [format][mode][rate]
|
---|
214 |
|
---|
215 | private:
|
---|
216 | BOOL InitResources();
|
---|
217 | BOOL FreeResources();
|
---|
218 | BOOL InquireVideoFormats();
|
---|
219 | BOOL InquireVideoModes();
|
---|
220 | BOOL InquireVideoRates();
|
---|
221 | BOOL OneShot();
|
---|
222 | void UpdateParameters();
|
---|
223 | void StopVideoStream();
|
---|
224 | void StartVideoStream();
|
---|
225 |
|
---|
226 | // pertaining to video format/mode/rate
|
---|
227 | int m_videoFrameRate;
|
---|
228 | int m_videoMode;
|
---|
229 | int m_videoFormat;
|
---|
230 | int m_maxBytes;
|
---|
231 | int m_maxBufferSize;
|
---|
232 | ULONG m_maxSpeed;
|
---|
233 |
|
---|
234 | // which camera are we using
|
---|
235 | int m_node;
|
---|
236 | char* m_pName;
|
---|
237 |
|
---|
238 | // camera data grabbed from the driver
|
---|
239 | CAMERA_SPECIFICATION m_spec;
|
---|
240 | DEVICE_DATA m_DeviceData;
|
---|
241 |
|
---|
242 | // our isochronous resources (to replace the above structs)
|
---|
243 | HANDLE m_hBandwidth;
|
---|
244 | HANDLE m_hResource;
|
---|
245 | LONG m_lChannel;
|
---|
246 |
|
---|
247 | // buffer management
|
---|
248 | PACQUISITION_BUFFER m_pFirstBuffer;
|
---|
249 | PACQUISITION_BUFFER m_pLastBuffer;
|
---|
250 | PACQUISITION_BUFFER m_pCurrentBuffer;
|
---|
251 |
|
---|
252 | // persistent handles
|
---|
253 | HANDLE m_hDeviceAcquisition;
|
---|
254 | HANDLE m_hDeviceCapture;
|
---|
255 |
|
---|
256 |
|
---|
257 | // things that used to be part of the class, but aren't anymore
|
---|
258 | // they are preserved here partly for posterity, and partly "just in case"
|
---|
259 |
|
---|
260 | // resetting the link is no longer necessary, so we do not support it
|
---|
261 | //void ResetLink(bool root);
|
---|
262 |
|
---|
263 | //void DisableVideoMode(int format, int mode);
|
---|
264 | //void DisableVideoFormat(int format);
|
---|
265 | // removed private functions
|
---|
266 | // these functions were no-argument one-liners that used to pop up message boxes
|
---|
267 | // they have been consolidated directly into the functions that called them.
|
---|
268 | //void Speed(unsigned char value);
|
---|
269 | //void AllocateResources();
|
---|
270 | //void AllocateChannel();
|
---|
271 | //void AllocateBandwidth();
|
---|
272 | //void SetChannelSpeed();
|
---|
273 | //void GetDeviceName();
|
---|
274 | //void StopListen();
|
---|
275 | //void Listen();
|
---|
276 |
|
---|
277 | // removed members
|
---|
278 | // for the most part, they were from the old buffer management code
|
---|
279 | //int m_nBuffers;
|
---|
280 | //int m_nDescriptors;
|
---|
281 | //ULONG m_acquisitionBufferSize;
|
---|
282 | //ULONG m_captureBufferSize;
|
---|
283 | //OVERLAPPED m_captureOverlapped;
|
---|
284 | //PISOCH_ATTACH_BUFFERS m_pIsochAttachBuffers;
|
---|
285 | //ISOCH_GET_IMAGE_PARAMS m_isochGetImageParams;
|
---|
286 | //ACQUISITION_BUFFER m_acquisitionBuffer[6];
|
---|
287 | //bool m_allocateMemory;
|
---|
288 | //HWND m_hWnd;
|
---|
289 | //ISOCH_LISTEN m_listen;
|
---|
290 | //ISOCH_STOP m_stop;
|
---|
291 | // structs for the various Isoch functions we use
|
---|
292 | //ISOCH_ALLOCATE_BANDWIDTH m_bandwidth;
|
---|
293 | //ISOCH_ALLOCATE_CHANNEL m_channel;
|
---|
294 | //ISOCH_ALLOCATE_RESOURCES m_resource;
|
---|
295 | };
|
---|
296 |
|
---|
297 | /*
|
---|
298 | * CameraControlDialog
|
---|
299 | *
|
---|
300 | * This function provides a complete control dialog for
|
---|
301 | * all the standard controls for a 1394 camera.
|
---|
302 | *
|
---|
303 | * Note: this is a non-modal dialog, which means you
|
---|
304 | * need to do your own message pumping
|
---|
305 | *
|
---|
306 | * Arguments:
|
---|
307 | * - hWndParent: the parent window for this instance
|
---|
308 | * - pCamera: pointer to the camera to be controlled
|
---|
309 | * this allows multiple control windows to be open for multiple cameras
|
---|
310 | * - bLoadDefaultView :
|
---|
311 | *
|
---|
312 | * Returns:
|
---|
313 | * HWND to the control window, NULL on error. GetLastError() should work.
|
---|
314 | *
|
---|
315 | * Location: ControlDialog.cpp
|
---|
316 | *
|
---|
317 | */
|
---|
318 |
|
---|
319 | HWND
|
---|
320 | CAMAPI
|
---|
321 | CameraControlDialog(
|
---|
322 | HWND hWndParent,
|
---|
323 | C1394Camera *pCamera,
|
---|
324 | BOOL bLoadDefaultView
|
---|
325 | );
|
---|
326 |
|
---|
327 | extern "C" {
|
---|
328 |
|
---|
329 | /*
|
---|
330 | * CameraDebugDialog
|
---|
331 | *
|
---|
332 | * This function provides a dialog to dynamically change the trace level of the DLL.
|
---|
333 | *
|
---|
334 | * Arguments:
|
---|
335 | * - hWndParent: the parent window for this instance
|
---|
336 | *
|
---|
337 | * Note: this is a modal dialog, which means it will block until you click "OK"
|
---|
338 | *
|
---|
339 | * Location: debug.c
|
---|
340 | */
|
---|
341 |
|
---|
342 | void
|
---|
343 | CAMAPI
|
---|
344 | CameraDebugDialog(
|
---|
345 | HWND hWndParent
|
---|
346 | );
|
---|
347 | }
|
---|
348 |
|
---|
349 | /*
|
---|
350 | * CameraControlSizeDialog
|
---|
351 | *
|
---|
352 | * This function spawns a modal dialog that is a graphical interface to the
|
---|
353 | * C1394CameraControlSize class.
|
---|
354 | *
|
---|
355 | * Arguments:
|
---|
356 | * - hWndParent: the parent window for this instance
|
---|
357 | * - pCamera: pointer to the camera whose size you wish to control
|
---|
358 | *
|
---|
359 | * Notes:
|
---|
360 | * - This is a modal dialog, which means it will block until you click "OK" or "Cancel"
|
---|
361 | *
|
---|
362 | * - It is not recommended to futz with the partial scan controls while the camera is sending
|
---|
363 | * image data.
|
---|
364 | *
|
---|
365 | * Location: ControlSizeDialog.cpp
|
---|
366 | */
|
---|
367 |
|
---|
368 |
|
---|
369 | long
|
---|
370 | CAMAPI
|
---|
371 | CameraControlSizeDialog(HWND hWndParent,
|
---|
372 | C1394Camera *pCamera);
|
---|
373 |
|
---|
374 | #endif // __1394CAMERA_H__
|
---|