1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
45 #pragma warning( disable: 4711 )
48 #if defined WIN64 && defined EM64T && defined _MSC_VER && !defined __ICL
49 #pragma optimize("",off)
53 /************************* Reading AVIs & Camera data **************************/
55 CV_IMPL void cvReleaseCapture( CvCapture** pcapture )
57 if( pcapture && *pcapture )
64 CV_IMPL IplImage* cvQueryFrame( CvCapture* capture )
66 return capture ? capture->queryFrame() : 0;
70 CV_IMPL int cvGrabFrame( CvCapture* capture )
72 return capture ? capture->grabFrame() : 0;
75 CV_IMPL IplImage* cvRetrieveFrame( CvCapture* capture )
77 return capture ? capture->retrieveFrame() : 0;
80 CV_IMPL double cvGetCaptureProperty( CvCapture* capture, int id )
82 return capture ? capture->getProperty(id) : 0;
85 CV_IMPL int cvSetCaptureProperty( CvCapture* capture, int id, double value )
87 return capture ? capture->setProperty(id, value) : 0;
92 * Camera dispatching method: index is the camera number.
93 * If given an index from 0 to 99, it tries to find the first
94 * API that can access a given camera index.
95 * Add multiples of 100 to select an API.
97 CV_IMPL CvCapture * cvCreateCameraCapture (int index)
101 CV_CAP_IEEE1394, // identical to CV_CAP_DC1394
103 CV_CAP_VFW, // identical to CV_CAP_V4L
111 // interpret preferred interface (0 = autodetect)
112 int pref = (index / 100) * 100;
120 // try every possibly installed camera API
121 for (int i = 0; domains[i] >= 0; i++)
123 // local variable to memorize the captured device
130 capture = cvCreateCameraCapture_TYZX (index);
138 capture = cvCreateCameraCapture_VFW (index);
142 #if defined (HAVE_CAMV4L) || defined (HAVE_CAMV4L2)
143 capture = cvCreateCameraCapture_V4L (index);
147 #ifdef HAVE_GSTREAMER
148 capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, 0);
151 capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, 0);
157 case CV_CAP_FIREWIRE:
159 capture = cvCreateCameraCapture_DC1394 (index);
164 capture = cvCreateCameraCapture_CMU (index);
168 #ifdef HAVE_GSTREAMER
169 capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_1394, 0);
177 capture = cvCreateCameraCapture_MIL (index);
183 #ifdef HAVE_QUICKTIME
185 capture = cvCreateCameraCapture_QT (index);
193 capture = cvCreateCameraCapture_Unicap (index);
202 // failed open a camera
207 * Videoreader dispatching method: it tries to find the first
208 * API that can access a given filename.
210 CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
212 CvCapture * result = 0;
215 result = cvCreateFileCapture_Images (filename);
219 result = cvCreateFileCapture_Win32 (filename);
224 result = cvCreateFileCapture_XINE (filename);
227 #ifdef HAVE_GSTREAMER
229 result = cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename);
234 result = cvCreateFileCapture_FFMPEG (filename);
237 #ifdef HAVE_QUICKTIME
239 result = cvCreateFileCapture_QT (filename);
246 * Videowriter dispatching method: it tries to find the first
247 * API that can write a given stream.
249 CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
250 double fps, CvSize frameSize, int is_color )
252 CV_FUNCNAME( "cvCreateVideoWriter" );
254 CvVideoWriter *result = 0;
257 result = cvCreateVideoWriter_Images(filename);
261 result = cvCreateVideoWriter_Win32(filename, fourcc, fps, frameSize, is_color);
266 result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
271 result = cvCreateVideoWriter_FFMPEG(filename, fourcc, fps, frameSize, is_color);
274 #ifdef HAVE_QUICKTIME
276 result = cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color);
280 result = cvCreateVideoWriter_Images(filename);
285 CV_IMPL int cvWriteFrame( CvVideoWriter* writer, const IplImage* image )
287 return writer ? writer->writeFrame(image) : 0;
290 CV_IMPL void cvReleaseVideoWriter( CvVideoWriter** pwriter )
292 if( pwriter && *pwriter )