1 | /*
|
---|
2 | ###############################################################################
|
---|
3 | # #
|
---|
4 | # File: uEye_tools.h #
|
---|
5 | # Project: Library interface for IDS uEye_tools #
|
---|
6 | # exported API functions #
|
---|
7 | # #
|
---|
8 | ###############################################################################
|
---|
9 | */
|
---|
10 |
|
---|
11 | #ifndef __UEYETOOLS_H__
|
---|
12 | #define __UEYETOOLS_H__
|
---|
13 |
|
---|
14 |
|
---|
15 | #ifdef __cplusplus
|
---|
16 | extern "C" {
|
---|
17 | #endif
|
---|
18 |
|
---|
19 | // Color modes ------------------------------------------------
|
---|
20 | #define IS_AVI_CM_RGB32 0 // RGB32
|
---|
21 | #define IS_AVI_CM_RGB24 1 // RGB24
|
---|
22 | #define IS_AVI_CM_Y8 6 // Y8
|
---|
23 | #define IS_AVI_CM_BAYER 11 // Bayer
|
---|
24 | typedef DWORD HIDS;
|
---|
25 |
|
---|
26 |
|
---|
27 | // Events ------------------------------------------------
|
---|
28 | #define IS_AVI_SET_EVENT_FRAME_SAVED 1
|
---|
29 |
|
---|
30 | // error constants --------------------------------------------
|
---|
31 | #define ISAVIERRBASE 300
|
---|
32 | #define ISAVIMAKEERR(_x_) (ISAVIERRBASE + _x_)
|
---|
33 | #define IS_AVI_NO_ERR 0
|
---|
34 | #define IS_AVI_ERR_INVALID_FILE ISAVIMAKEERR( 1)
|
---|
35 | #define IS_AVI_ERR_NEW_FAILED ISAVIMAKEERR( 2)
|
---|
36 | #define IS_AVI_ERR_CREATESTREAM ISAVIMAKEERR( 3)
|
---|
37 | #define IS_AVI_ERR_PARAMETER ISAVIMAKEERR( 4)
|
---|
38 | #define IS_AVI_ERR_NO_CODEC_AVAIL ISAVIMAKEERR( 5)
|
---|
39 | #define IS_AVI_ERR_INVALID_ID ISAVIMAKEERR( 6)
|
---|
40 | #define IS_AVI_ERR_COMPRESS ISAVIMAKEERR( 7)
|
---|
41 | #define IS_AVI_ERR_DECOMPRESS ISAVIMAKEERR( 8)
|
---|
42 | #define IS_AVI_ERR_CAPTURE_RUNNING ISAVIMAKEERR( 9)
|
---|
43 | #define IS_AVI_ERR_CAPTURE_NOT_RUNNING ISAVIMAKEERR(10)
|
---|
44 | #define IS_AVI_ERR_PLAY_RUNNING ISAVIMAKEERR(11)
|
---|
45 | #define IS_AVI_ERR_PLAY_NOT_RUNNING ISAVIMAKEERR(12)
|
---|
46 | #define IS_AVI_ERR_WRITE_INFO ISAVIMAKEERR(13)
|
---|
47 | #define IS_AVI_ERR_INVALID_VALUE ISAVIMAKEERR(14)
|
---|
48 | #define IS_AVI_ERR_ALLOC_MEMORY ISAVIMAKEERR(15)
|
---|
49 | #define IS_AVI_ERR_INVALID_CM ISAVIMAKEERR(16)
|
---|
50 | #define IS_AVI_ERR_COMPRESSION_RUN ISAVIMAKEERR(17)
|
---|
51 | #define IS_AVI_ERR_INVALID_SIZE ISAVIMAKEERR(18)
|
---|
52 | #define IS_AVI_ERR_INVALID_POSITION ISAVIMAKEERR(19)
|
---|
53 | #define IS_AVI_ERR_INVALID_UEYE ISAVIMAKEERR(20)
|
---|
54 | #define IS_AVI_ERR_EVENT_FAILED ISAVIMAKEERR(21)
|
---|
55 |
|
---|
56 | #define IDSAVIEXP extern __declspec(dllexport) INT __stdcall
|
---|
57 |
|
---|
58 | // function prototyes
|
---|
59 |
|
---|
60 |
|
---|
61 | /*! \brief Initialises the uEye AVI interface.
|
---|
62 | *
|
---|
63 | *
|
---|
64 | * \param pnAviID: After the function call, it contains the instance ID needed by the other functions.
|
---|
65 | * Several instances may be opened at the same time.
|
---|
66 | *
|
---|
67 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
68 | * \return IS_AVI_ERR_PARAMETER pnAviID points to NULL
|
---|
69 | * \return IS_AVI_ERR_NO_CODEC_AVAIL The maximum available instances of the interface have been
|
---|
70 | * reached.
|
---|
71 | ***********************************************************************************************************/
|
---|
72 | IDSAVIEXP isavi_InitAVI (INT* pnAviID,HIDS hu);
|
---|
73 |
|
---|
74 |
|
---|
75 | /*! \brief Ends and frees the instance of the uEye AVI interface specified by the given instance ID.
|
---|
76 | *
|
---|
77 | *
|
---|
78 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
79 | *
|
---|
80 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
81 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
82 | * specified interface has already been destroyed by a previous call to
|
---|
83 | * isavi_ExitAVI().
|
---|
84 | * \return IS_AVI_ERR_INVALID_FILE The AVI file could not be closed successfully
|
---|
85 | ***********************************************************************************************************/
|
---|
86 | IDSAVIEXP isavi_ExitAVI (INT nAviID);
|
---|
87 |
|
---|
88 |
|
---|
89 | /*! \brief Sets the size of the input buffer and the offset of the input data. After this, the function
|
---|
90 | * isavi_AddFrame receives as parameter a pointer to the data to compress, and uses this information
|
---|
91 | * to save only the valid data.
|
---|
92 | *
|
---|
93 | *
|
---|
94 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
95 | * \param cMode: Color mode of the input data. There are four supported formats (IS_AVI_CM_RGB32,
|
---|
96 | * IS_AVI_CM_RGB24,IS_AVI_CM_Y8 and IS_AVI_CM_BAYER)
|
---|
97 | * \param Width: Image width
|
---|
98 | * \param Height: Image height
|
---|
99 | * \param PosX: Offset in x axis
|
---|
100 | * \param PosY: Offset in y axis
|
---|
101 | * \param LineOffset: Empty position until next image line
|
---|
102 | *
|
---|
103 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
104 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
105 | * specified interface has already been destroyed by a previous call to
|
---|
106 | * isavi_ExitAVI().
|
---|
107 | * \return IS_AVI_ERR_INVALID_FILE The AVI file could not be closed successfully
|
---|
108 | * \return IS_AVI_ERR_CAPTURE_RUNNING Capture is running
|
---|
109 | * \return IS_AVI_ERR_ALLOC_MEMORY Error allocating memory
|
---|
110 | * \return IS_AVI_ERR_INVALID_CM Colour mode not supported
|
---|
111 | * \return IS_AVI_ERR_INVALID_SIZE Picture size less than 16 x 16 pixels
|
---|
112 | * \return IS_AVI_ERR_INVALID_POSITION Invalid position
|
---|
113 | ***********************************************************************************************************/
|
---|
114 | IDSAVIEXP isavi_SetImageSize (INT nAviID,INT cMode, INT Width, INT Height, INT PosX, INT PosY, INT LineOffset);
|
---|
115 |
|
---|
116 |
|
---|
117 | /*! \brief Opens an AVI file for recording.
|
---|
118 | *
|
---|
119 | *
|
---|
120 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
121 | * \param pFileName: NULL or pointer to the filename Name that should be used for the avi file.
|
---|
122 | * If NULL is used, than a Dialog box allowing to select a file appears.
|
---|
123 | *
|
---|
124 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
125 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
126 | * specified interface has already been destroyed by a previous call to
|
---|
127 | * isavi_ExitAVI().
|
---|
128 | * \return IS_AVI_ERR_INVALID_FILE The user did not select a valid file in the dialog box
|
---|
129 | * IS_AVI_ERR_NEW_FAILED Memory allocation failed
|
---|
130 | * IS_AVI_ERR_AVIFILEOPEN The AVI file could not be opened successfully
|
---|
131 | * IS_AVI_ERR_CREATESTREAM The AVI stream could not be created (Recording only)
|
---|
132 | ***********************************************************************************************************/
|
---|
133 | IDSAVIEXP isavi_OpenAVI (INT nAviID, const char* strFileName);
|
---|
134 |
|
---|
135 |
|
---|
136 | /*! \brief Starts the picture compression thread.
|
---|
137 | *
|
---|
138 | *
|
---|
139 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
140 | *
|
---|
141 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
142 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
143 | * specified interface has already been destroyed by a previous call to
|
---|
144 | * isavi_ExitAVI().
|
---|
145 | * \return IS_AVI_ERR_INVALID_FILE The AVI file is not open
|
---|
146 | ***********************************************************************************************************/
|
---|
147 | IDSAVIEXP isavi_StartAVI (INT nAviID);
|
---|
148 |
|
---|
149 |
|
---|
150 | /*! \brief Stops the picture compression thread, the call of isavi_AddFrame is ignored.
|
---|
151 | *
|
---|
152 | *
|
---|
153 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
154 | *
|
---|
155 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
156 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
157 | * specified interface has already been destroyed by a previous call to
|
---|
158 | * isavi_ExitAVI().
|
---|
159 | * \return IS_AVI_ERR_INVALID_FILE The AVI file is not open
|
---|
160 | ***********************************************************************************************************/
|
---|
161 | IDSAVIEXP isavi_StopAVI (INT nAviID);
|
---|
162 |
|
---|
163 |
|
---|
164 | /*! \brief Add a new frame to the avi sequence.
|
---|
165 | *
|
---|
166 | *
|
---|
167 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
168 | * \param pcImageMem: Pointer to data image
|
---|
169 | *
|
---|
170 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
171 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
172 | * specified interface has already been destroyed by a previous call to
|
---|
173 | * isavi_ExitAVI().
|
---|
174 | * \return IS_AVI_ERR_INVALID_FILE The AVI file is not open
|
---|
175 | * \return IS_AVI_ERR_COMPRESSION_RUN A compression run and can not compress the actual picture
|
---|
176 | ***********************************************************************************************************/
|
---|
177 | IDSAVIEXP isavi_AddFrame (INT nAviID,char *pcImageMem);
|
---|
178 |
|
---|
179 |
|
---|
180 | /*! \brief Sets the frame rate of the video. The frame rate can be changed at any time if the avi file is
|
---|
181 | * already created.
|
---|
182 | *
|
---|
183 | *
|
---|
184 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
185 | * \param pcImageMem: Pointer to data image
|
---|
186 | *
|
---|
187 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
188 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
189 | * specified interface has already been destroyed by a previous call to
|
---|
190 | * isavi_ExitAVI().
|
---|
191 | * \return IS_AVI_ERR_WRITE_INFO The AVI file could not be modified
|
---|
192 | ***********************************************************************************************************/
|
---|
193 | IDSAVIEXP isavi_SetFrameRate (INT nAviID,double fr);
|
---|
194 |
|
---|
195 |
|
---|
196 | /*! \brief Sets the quality of the actual image that is going to be compressed and added to the video stream.
|
---|
197 | * The quality can be changed at any time. The best image quality is 100 (bigger avi file size) and
|
---|
198 | * the worst is 1.
|
---|
199 | *
|
---|
200 | *
|
---|
201 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
202 | * \param q: Quality of compression [1
|
---|
203 | 100]
|
---|
204 | *
|
---|
205 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
206 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid
|
---|
207 | * for the specified interface has already been destroyed by a previous
|
---|
208 | * call to isavi_ExitAVI().
|
---|
209 | * \return IS_AVI_ERR_INVALID_VALUE The parameter q is bigger than 100 or less than 1
|
---|
210 | ***********************************************************************************************************/
|
---|
211 | IDSAVIEXP isavi_SetImageQuality (INT nAviID,INT q);
|
---|
212 |
|
---|
213 |
|
---|
214 | /*! \brief Sets the quality of the actual image that is going to be compressed and added to the video stream.
|
---|
215 | * The quality can be changed at any time. The best image quality is 100 (bigger avi file size) and
|
---|
216 | * the worst is 1.
|
---|
217 | *
|
---|
218 | *
|
---|
219 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
220 | * \param size: Size in Kbytes
|
---|
221 | *
|
---|
222 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
223 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid
|
---|
224 | * or the specified interface has already been destroyed by a previous
|
---|
225 | * call to isavi_ExitAVI().
|
---|
226 | ***********************************************************************************************************/
|
---|
227 | IDSAVIEXP isavi_GetAVISize (INT nAviID,float *size);
|
---|
228 |
|
---|
229 |
|
---|
230 | /*! \brief Allows to retrieve the filename of the current AVI file. It is useful when the AVI file has been
|
---|
231 | * opened specifying NULL for the filename (see isavi_OpenAVI()).
|
---|
232 | *
|
---|
233 | *
|
---|
234 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
235 | * \param strName: Pointer to a buffer that will receive the filename. The allocated memory must be
|
---|
236 | * sufficient to contain the complete path to the file.
|
---|
237 | *
|
---|
238 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
239 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid
|
---|
240 | * or the specified interface has already been destroyed by a previous
|
---|
241 | * call to isavi_ExitAVI().
|
---|
242 | ***********************************************************************************************************/
|
---|
243 | IDSAVIEXP isavi_GetAVIFileName (INT nAviID, char* strName);
|
---|
244 |
|
---|
245 |
|
---|
246 | /*! \brief gets the actual number of pictures written in the avi file.
|
---|
247 | *
|
---|
248 | *
|
---|
249 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
250 | * \param nFrames: Number of frames
|
---|
251 | *
|
---|
252 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
253 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
254 | * specified interface has already been destroyed by a previous call to
|
---|
255 | * isavi_ExitAVI().
|
---|
256 | ***********************************************************************************************************/
|
---|
257 | IDSAVIEXP isavi_GetnCompressedFrames(INT nAviID,unsigned long *nFrames);
|
---|
258 |
|
---|
259 |
|
---|
260 | /*! \brief Gets the actual number of dropped pictures. It can be caused in two ways:
|
---|
261 | * 1. A compression is running and the current isavi_AddFrame call cannot be attended.
|
---|
262 | * 2. An error in the compression algorithm has occurred.
|
---|
263 | *
|
---|
264 | *
|
---|
265 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
266 | * \param nLostFrames: Number of dropped frames
|
---|
267 | *
|
---|
268 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
269 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
270 | * specified interface has already been destroyed by a previous call to
|
---|
271 | * isavi_ExitAVI().
|
---|
272 | ***********************************************************************************************************/
|
---|
273 | IDSAVIEXP isavi_GetnLostFrames (INT nAviID,unsigned long *nLostFrames);
|
---|
274 |
|
---|
275 |
|
---|
276 | /*! \brief resets the number of lost frames and saved frames.
|
---|
277 | *
|
---|
278 | *
|
---|
279 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
280 | *
|
---|
281 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
282 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found. The ID is either invalid or the
|
---|
283 | * specified interface has already been destroyed by a previous call to
|
---|
284 | * isavi_ExitAVI().
|
---|
285 | ***********************************************************************************************************/
|
---|
286 | IDSAVIEXP isavi_ResetFrameCounters (INT nAviID);
|
---|
287 |
|
---|
288 |
|
---|
289 | /*! \brief Closes a file opened by a previous call to isavi_OpenAVI().
|
---|
290 | *
|
---|
291 | *
|
---|
292 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
293 | *
|
---|
294 | * \return IS_AVI_NO_ERR No error, initialisation was successful
|
---|
295 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found.
|
---|
296 | *
|
---|
297 | ***********************************************************************************************************/
|
---|
298 | IDSAVIEXP isavi_CloseAVI (INT nAviID);
|
---|
299 |
|
---|
300 | /*! \brief Initializes the event handler by registering the event object in the avi engine
|
---|
301 | *
|
---|
302 | *
|
---|
303 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
304 | * \param hEv: Event handle
|
---|
305 | * \param which: Event id. (ex: IS_AVI_SET_EVENT_FRAME_SAVED)
|
---|
306 | *
|
---|
307 | * \return IS_AVI_NO_ERR No error, Event initialisation was successful
|
---|
308 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found.
|
---|
309 | * \return IS_AVI_ERR_EVENT_FAILED SetEvent failed
|
---|
310 | * \return IS_AVI_ERR_PARAMETER Invalid Event id
|
---|
311 | ***********************************************************************************************************/
|
---|
312 | IDSAVIEXP isavi_InitEvent (INT nAviID, HANDLE hEv, INT which);
|
---|
313 |
|
---|
314 | /*! \brief Release of the equipped event object. After the release, the event signalling
|
---|
315 | * of the current event object is allowed.
|
---|
316 | *
|
---|
317 | *
|
---|
318 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
319 | * \param which: Event id.
|
---|
320 | *
|
---|
321 | * \return IS_AVI_NO_ERR No error
|
---|
322 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found.
|
---|
323 | * \return IS_AVI_ERR_PARAMETER Invalid Event id
|
---|
324 | ***********************************************************************************************************/
|
---|
325 | IDSAVIEXP isavi_EnableEvent (INT nAviID, INT which);
|
---|
326 |
|
---|
327 |
|
---|
328 | /*! \brief blocks the event given here. The event will generally still occur,
|
---|
329 | * but not trigger an event signal any more. After this function is called, the application does not
|
---|
330 | * notice the blocked events any more. A desired event can be reactivated with isavi_EnableEvent() if
|
---|
331 | * required.
|
---|
332 | *
|
---|
333 | *
|
---|
334 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
335 | * \param which: Event id.
|
---|
336 | *
|
---|
337 | * \return IS_AVI_NO_ERR No error
|
---|
338 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found.
|
---|
339 | * \return IS_AVI_ERR_PARAMETER Invalid Event id
|
---|
340 | ***********************************************************************************************************/
|
---|
341 | IDSAVIEXP isavi_DisableEvent (INT nAviID, INT which);
|
---|
342 |
|
---|
343 | /*! \brief Deletes set event object. After deleting it can not be activated with isavi_EnableEvent().
|
---|
344 | *
|
---|
345 | *
|
---|
346 | * \param nAviID: Instance ID returned by isavi_InitAVI()
|
---|
347 | * \param which: Event id.
|
---|
348 | *
|
---|
349 | * \return IS_AVI_NO_ERR No error
|
---|
350 | * \return IS_AVI_ERR_INVALID_ID The specified instance could not be found.
|
---|
351 | * \return IS_AVI_ERR_PARAMETER Invalid Event id
|
---|
352 | ***********************************************************************************************************/
|
---|
353 | IDSAVIEXP isavi_ExitEvent (INT nAviID, INT which);
|
---|
354 |
|
---|
355 |
|
---|
356 | #ifdef __cplusplus
|
---|
357 | }
|
---|
358 | #endif
|
---|
359 |
|
---|
360 | #endif // __UEYETOOLS_H__
|
---|
361 |
|
---|