Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
204 chris 1
/*  --------------------------------------------------------------------------
2
 *      Copyright (c) 2004-2006 Philip Lamb (PRL) phil@eden.net.nz. All rights reserved.
3
 * This file is part of ARToolKit.
4
 *
5
 * ARToolKit is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * ARToolKit is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with ARToolKit; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 *   -------------------------------------------------------------------------*/
19
/**
20
 *  \file video.h
21
 *  \brief ARToolkit video subroutines.
22
 *
23
 *  This library provides multi-platform video input support for ARToolKit.
24
 *  It abstracts access to hardware video input available on different machines and
25
 *  operating systems.
26
 *
27
 *  The actual supported platforms (and the driver/library used) are:
28
 *  - Windows: with Microsoft DirectShow (VFW obsolete).
29
 *  - Linux: with Video4Linux library, GStreamer, IEEE1394 camera library and DV camera library.
30
 *  - Macintosh: with QuickTime.
31
 *  - SGI: with VL.
32
 *
33
 *  This library provides two sets of functions, depending on whether your program
34
 *  needs to use only one video stream, or more than one video stream. These
35
 *  two sets are functionally identical.
36
 *  - one camera: use the <b>arVideo*</b> functions.
37
 *  - multiple cameras: use the <b>ar2Video*</b> functions.
38
 *
39
 *  More information on establishing video streams is available in the ARToolKit manual.
40
 *
41
 *  \remark The arVideo* functions maintain the current video stream in a global variable
42
 *  and internally call the ar2Video* functions.
43
 *
44
 *  History :
45
 *              modified by Thomas Pintaric (pintaric@ims.tuwien.ac.at) to add
46
 *       a fully transparent DirectShow Driver.
47
 *      modified by Hartmut Seichter (hartmut@technotecture.com) to add
48
 *       GStreamer video support
49
 *
50
 *  \author Hirokazu Kato kato@sys.im.hiroshima-cu.ac.jp
51
 *  \author Atsishi Nakazawa nakazawa@inolab.sys.es.osaka-u.ac.jp
52
 *  \author Thomas Pintaric pintaric@ims.tuwien.ac.at (Windows DirectShow video support).
53
 *  \author Philip Lamb phil@eden.net.nz (Macintosh Quicktime video support).
54
 *  \author Hartmut Seichter hartmut@technotecture.com (GStreamer Video support)
55
 *  \version 4.3b
56
 *  \date 03/02/02
57
 *
58
 */
59
/* --------------------------------------------------------------------------
60
 * History :
61
 * Rev          Date            Who             Changes
62
 * 2.6.8        2004-07-20      PRL             Rewrite for ARToolKit 2.68.2
63
 *
64
 *----------------------------------------------------------------------------
65
 */
66
 
67
#ifndef AR_VIDEO_H
68
#define AR_VIDEO_H
69
 
70
#ifdef  __cplusplus
71
extern "C" {
72
#endif
73
 
74
// ============================================================================
75
//      Public includes.
76
// ============================================================================
77
 
78
#include <AR/config.h>
79
#include <AR/ar.h>
80
 
81
// ============================================================================
82
//      Public types and defines.
83
// ============================================================================
84
 
85
#ifdef _WIN32
86
#  include <AR/sys/videoWin32DirectShow.h>
87
#  ifdef LIBARVIDEO_EXPORTS
88
#    define AR_DLL_API __declspec(dllexport)
89
#  else
90
#    ifdef _DLL
91
#      define AR_DLL_API __declspec(dllimport)
92
#    else
93
#      define AR_DLL_API extern
94
#    endif
95
#  endif
96
#else
97
#  define AR_DLL_API
98
#endif
99
 
100
#ifdef __linux
101
#  ifdef AR_INPUT_V4L
102
#    include <AR/sys/videoLinuxV4L.h>
103
#  endif
104
#  ifdef  AR_INPUT_DV
105
#    include <AR/sys/videoLinuxDV.h>
106
#  endif
107
#  ifdef  AR_INPUT_1394CAM
108
#    include <AR/sys/videoLinux1394Cam.h>
109
#  endif
110
#  ifdef  AR_INPUT_GSTREAMER
111
#    include <AR/sys/videoGStreamer.h>
112
#  endif
113
#endif
114
 
115
#ifdef __sgi
116
#  include <AR/sys/videoSGI.h>
117
#endif
118
 
119
#ifdef __APPLE__
120
#  include <AR/sys/videoMacOSX.h>
121
#endif
122
 
123
// ============================================================================
124
//      Public globals.
125
// ============================================================================
126
 
127
// ============================================================================
128
//      Public functions.
129
// ============================================================================
130
 
131
/*
132
        mono-camera
133
*/
134
 
135
/**
136
 * \brief display the video option.
137
 *
138
 * The video configuration options vary by operating system and platform.
139
 * This function outputs to the standard output the options available
140
 * on the current OS and platform.
141
 * \return 0
142
 */
143
AR_DLL_API  int                         arVideoDispOption(void);
144
 
145
/**
146
 * \brief open a video source.
147
 *
148
 * This function opens a video input path with the
149
 * driver (and device) present on your platform.
150
 * According to your operating system and the
151
 * hardware the initialization will be different : a
152
 * generic string structure is used for this issue.
153
 * This function prepares the video stream for capture,
154
 * but capture will not actually begin until arVideoCapStart
155
 * is called.
156
 * \param config string of the selected video configuration.
157
 * See the <a href="video/">video configuration documentation</a>
158
 * for more information on this parameter.
159
 * \return 0 if successful, -1 if a video path couldn't be opened
160
 */    
161
AR_DLL_API  int                         arVideoOpen(char *config);
162
 
163
/**
164
 * \brief close the video source.
165
 * After your application has finished using a video stream,
166
 * this function must be called to close the link to the
167
 * input source, and free resources associated with the
168
 * capture operation.
169
 * \return 0 if shut down successfully, otherwise -1.
170
 */
171
AR_DLL_API  int                         arVideoClose(void);
172
 
173
/**
174
 * \brief start the capture of video.
175
 *
176
 * This function starts the video capture routine.
177
 * \remark On some operating systems, capture operations
178
 * may run in a separate execution thread. This call starts that thread.
179
 * \remark this function coupled with arVideoCapStop, can
180
 * be call many times in your program (this may reduce the CPU load
181
 * when video processing is stopped or for long and critical operations).
182
 * \return 0 if successful, -1 if the capture couldn't be started.
183
 */
184
AR_DLL_API  int                         arVideoCapStart(void);
185
 
186
/**
187
 * \brief stop the capture of video.
188
 *
189
 * This function stops the video capture routine.
190
 * \remark On some operating systems, capture operations
191
 * may run in a separate execution thread. This call stops that thread.
192
 * \remark this function coupled with arVideoCapStart, can
193
 * be call many times in your program (this may reduce the CPU load
194
 * when video processing is stopped or for long and critical operations).
195
 * \return 0 if successful, -1 if the capture couldn't be stopped.
196
 */
197
AR_DLL_API  int                         arVideoCapStop(void);
198
 
199
/**
200
 * \brief call for the next grabbed video frame.
201
 *
202
 * This function should be called at least once per frame.
203
 * It has several purposes, depending on the operating system.
204
 * It allows the video driver to perform housekeeping tasks
205
 * and also signals to the video grabber that your code
206
 * has finished using the most recent video frame returned by
207
 * arVideoGetImage(), and that the video driver may re-use the
208
 * memory occupied by the frame.
209
 * The effect of this call is operating-system dependent.
210
 * The best place to call this function is immediately after
211
 * you have finished displaying the current video frame, i.e.
212
 * after calling arglDispImage() or argDispImage().
213
 *
214
 * \remark On some operating systems, this function is a no-op.
215
 * \return 0 if successful, -1 if the video driver encountered an error.
216
 */
217
AR_DLL_API  int                         arVideoCapNext(void);
218
 
219
/**
220
 * \brief get the video image.
221
 *
222
 * This function returns a buffer with a captured video image.
223
 * The returned data consists of a tightly-packed array of
224
 * pixels, beginning with the first component of the leftmost
225
 * pixel of the topmost row, and continuing with the remaining
226
 * components of that pixel, followed by the remaining pixels
227
 * in the topmost row, followed by the leftmost pixel of the
228
 * second row, and so on.
229
 * The arrangement of components of the pixels in the buffer is
230
 * determined by the configuration string passed in to the driver
231
 * at the time the video stream was opened. If no pixel format
232
 * was specified in the configuration string, then an operating-
233
 * system dependent default, defined in <AR/config.h> is used.
234
 * The memory occupied by the pixel data is owned by the video
235
 * driver and should not be freed by your program.
236
 * The pixels in the buffer remain valid until the next call to
237
 * arVideoCapNext, or the next call to arVideoGetImage which
238
 * returns a non-NULL pointer, or any call to arVideoCapStop or
239
 * arVideoClose.
240
 * \return A pointer to the pixel data of the captured video frame,
241
 * or NULL if no new pixel data was available at the time of calling.
242
 */
243
AR_DLL_API  ARUint8*            arVideoGetImage(void);
244
 
245
/**
246
 * \brief get the video image size, in pixels.
247
 *
248
 * This function returns the size of the captured video frame, in
249
 * pixels.
250
 * \param x a pointer to the length of the captured image
251
 * \param y a pointer to the width of the captured image
252
 * \return 0 if the dimensions are found successfully, otherwise -1
253
 */
254
AR_DLL_API  int                         arVideoInqSize(int *x, int *y);
255
 
256
/*
257
        multiple cameras
258
 */
259
 
260
/**
261
 * \brief display the video option (multiple video inputs)
262
 *
263
 * Companion function to arVideoDispOption, for multiple video sources.
264
 */
265
AR_DLL_API  int                         ar2VideoDispOption(void);
266
 
267
/**
268
 * \brief open a video source (multiple video inputs)
269
 *
270
 *  Companion function to arVideoOpen for multiple video sources.
271
 *  This function can be called multiple times to open multiple
272
 *  video streams. The maximum number of streams is dependent on
273
 *  the operating system and the performance characteristics of
274
 *  the host CPU and video capture infrastructure.
275
 *
276
 * \param config string of the selected video configuration.
277
 * \return If the video path was successfully opened, this
278
 * function returns a pointer to an AR2VideoParamT structure,
279
 * an opaque structure which holds information and configuration
280
 * for the video stream. This paramater should then be passed
281
 * to other ar2Video* functions to specify which video stream
282
 * is being operated upon. If the video path was not successfully
283
 * opened, NULL will be returned.
284
 s*/
285
AR_DLL_API  AR2VideoParamT  *ar2VideoOpen(char *config);
286
 
287
/**
288
 * \brief close a video source (multiple video inputs)
289
 *
290
 * Companion function to arVideoClose for multiple video sources.
291
 * \param vid a video handle structure for multi-camera grabbing.
292
 */
293
AR_DLL_API  int                         ar2VideoClose(AR2VideoParamT *vid);
294
 
295
/**
296
 * \brief start the capture of a video source (multiple video inputs)
297
 *
298
 * Companion function to arVideoCapStart for multiple video sources.
299
 * \param vid a video handle structure for multi-camera grabbing
300
 */
301
AR_DLL_API  int                         ar2VideoCapStart(AR2VideoParamT *vid);
302
 
303
/**
304
 * \brief call for the next grabbed video frame of a video source (multiple video inputs)
305
 *
306
 * Companion function to arVideoCapNext for multiple video sources.
307
 * \param vid a video handle structure for multi-camera grabbing
308
 */
309
AR_DLL_API  int                         ar2VideoCapNext(AR2VideoParamT *vid);
310
 
311
/**
312
 * \brief stop the capture of a video source (multiple video inputs)
313
 *
314
 * Companion function to arVideoCapStop for multiple video sources.
315
 * \param vid a video handle structure for multi-camera grabbing
316
 */
317
AR_DLL_API  int                         ar2VideoCapStop(AR2VideoParamT *vid);
318
 
319
/**
320
 * \brief get a video image from a video source (multiple video inputs)
321
 *
322
 * Companion function to arVideoGetImage for multiple video sources.
323
 * \param vid a video handle structure for multi-camera grabbing
324
 */
325
AR_DLL_API  ARUint8                     *ar2VideoGetImage(AR2VideoParamT *vid);
326
 
327
/**
328
 * \brief get the video image size of a video source (multiple video inputs)
329
 *
330
 * Companion function to arVideoInqSize for multiple video sources.
331
 * \param vid a video handle structure for multi-camera grabbing
332
 */
333
AR_DLL_API  int                         ar2VideoInqSize(AR2VideoParamT *vid, int *x, int *y);
334
 
335
// Functions added for Studierstube/OpenTracker.
336
#ifdef _WIN32
337
#  ifndef __MEMORY_BUFFER_HANDLE__
338
#  define __MEMORY_BUFFER_HANDLE__
339
#  define DEFAULT_NUMBER_OF_ALLOCATOR_BUFFERS 3
340
typedef struct _MemoryBufferHandle
341
{
342
        unsigned long  n; // sample number
343
        __int64 t;                // timestamp
344
} MemoryBufferHandle;
345
#  endif // __MEMORY_BUFFER_HANDLE__
346
AR_DLL_API  int                         ar2VideoInqFreq(AR2VideoParamT *vid, float *fps);
347
AR_DLL_API  int                         ar2VideoInqFlipping(AR2VideoParamT *vid, int *flipH, int *flipV);
348
AR_DLL_API  unsigned char       *ar2VideoLockBuffer(AR2VideoParamT *vid, MemoryBufferHandle *pHandle);
349
AR_DLL_API  int                         ar2VideoUnlockBuffer(AR2VideoParamT *vid, MemoryBufferHandle Handle);
350
#endif // _WIN32
351
 
352
#ifdef  __cplusplus
353
}
354
#endif
355
 
356
#endif // AR_VIDEO_H