Joe Verbout
/
main
opencv on mbed
Embed:
(wiki syntax)
Show/hide line numbers
videoio.hpp
00001 /*M/////////////////////////////////////////////////////////////////////////////////////// 00002 // 00003 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 00004 // 00005 // By downloading, copying, installing or using the software you agree to this license. 00006 // If you do not agree to this license, do not download, install, 00007 // copy or use the software. 00008 // 00009 // 00010 // License Agreement 00011 // For Open Source Computer Vision Library 00012 // 00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 00015 // Third party copyrights are property of their respective owners. 00016 // 00017 // Redistribution and use in source and binary forms, with or without modification, 00018 // are permitted provided that the following conditions are met: 00019 // 00020 // * Redistribution's of source code must retain the above copyright notice, 00021 // this list of conditions and the following disclaimer. 00022 // 00023 // * Redistribution's in binary form must reproduce the above copyright notice, 00024 // this list of conditions and the following disclaimer in the documentation 00025 // and/or other materials provided with the distribution. 00026 // 00027 // * The name of the copyright holders may not be used to endorse or promote products 00028 // derived from this software without specific prior written permission. 00029 // 00030 // This software is provided by the copyright holders and contributors "as is" and 00031 // any express or implied warranties, including, but not limited to, the implied 00032 // warranties of merchantability and fitness for a particular purpose are disclaimed. 00033 // In no event shall the Intel Corporation or contributors be liable for any direct, 00034 // indirect, incidental, special, exemplary, or consequential damages 00035 // (including, but not limited to, procurement of substitute goods or services; 00036 // loss of use, data, or profits; or business interruption) however caused 00037 // and on any theory of liability, whether in contract, strict liability, 00038 // or tort (including negligence or otherwise) arising in any way out of 00039 // the use of this software, even if advised of the possibility of such damage. 00040 // 00041 //M*/ 00042 00043 #ifndef __OPENCV_VIDEOIO_HPP__ 00044 #define __OPENCV_VIDEOIO_HPP__ 00045 00046 #include "opencv2/core.hpp" 00047 00048 /** 00049 @defgroup videoio Media I/O 00050 @{ 00051 @defgroup videoio_c C API 00052 @defgroup videoio_ios iOS glue 00053 @defgroup videoio_winrt WinRT glue 00054 @} 00055 */ 00056 00057 ////////////////////////////////// video io ///////////////////////////////// 00058 00059 typedef struct CvCapture CvCapture; 00060 typedef struct CvVideoWriter CvVideoWriter; 00061 00062 namespace cv 00063 { 00064 00065 //! @addtogroup videoio 00066 //! @{ 00067 00068 // Camera API 00069 enum { CAP_ANY = 0, // autodetect 00070 CAP_VFW = 200, // platform native 00071 CAP_V4L = 200, 00072 CAP_V4L2 = CAP_V4L, 00073 CAP_FIREWARE = 300, // IEEE 1394 drivers 00074 CAP_FIREWIRE = CAP_FIREWARE, 00075 CAP_IEEE1394 = CAP_FIREWARE, 00076 CAP_DC1394 = CAP_FIREWARE, 00077 CAP_CMU1394 = CAP_FIREWARE, 00078 CAP_QT = 500, // QuickTime 00079 CAP_UNICAP = 600, // Unicap drivers 00080 CAP_DSHOW = 700, // DirectShow (via videoInput) 00081 CAP_PVAPI = 800, // PvAPI, Prosilica GigE SDK 00082 CAP_OPENNI = 900, // OpenNI (for Kinect) 00083 CAP_OPENNI_ASUS = 910, // OpenNI (for Asus Xtion) 00084 CAP_ANDROID = 1000, // Android - not used 00085 CAP_XIAPI = 1100, // XIMEA Camera API 00086 CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API) 00087 CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK 00088 CAP_MSMF = 1400, // Microsoft Media Foundation (via videoInput) 00089 CAP_WINRT = 1410, // Microsoft Windows Runtime using Media Foundation 00090 CAP_INTELPERC = 1500, // Intel Perceptual Computing SDK 00091 CAP_OPENNI2 = 1600, // OpenNI2 (for Kinect) 00092 CAP_OPENNI2_ASUS = 1610, // OpenNI2 (for Asus Xtion and Occipital Structure sensors) 00093 CAP_GPHOTO2 = 1700, // gPhoto2 connection 00094 CAP_GSTREAMER = 1800, // GStreamer 00095 CAP_FFMPEG = 1900, // FFMPEG 00096 CAP_IMAGES = 2000 // OpenCV Image Sequence (e.g. img_%02d.jpg) 00097 }; 00098 00099 // generic properties (based on DC1394 properties) 00100 enum { CAP_PROP_POS_MSEC =0, 00101 CAP_PROP_POS_FRAMES =1, 00102 CAP_PROP_POS_AVI_RATIO =2, 00103 CAP_PROP_FRAME_WIDTH =3, 00104 CAP_PROP_FRAME_HEIGHT =4, 00105 CAP_PROP_FPS =5, 00106 CAP_PROP_FOURCC =6, 00107 CAP_PROP_FRAME_COUNT =7, 00108 CAP_PROP_FORMAT =8, 00109 CAP_PROP_MODE =9, 00110 CAP_PROP_BRIGHTNESS =10, 00111 CAP_PROP_CONTRAST =11, 00112 CAP_PROP_SATURATION =12, 00113 CAP_PROP_HUE =13, 00114 CAP_PROP_GAIN =14, 00115 CAP_PROP_EXPOSURE =15, 00116 CAP_PROP_CONVERT_RGB =16, 00117 CAP_PROP_WHITE_BALANCE_BLUE_U =17, 00118 CAP_PROP_RECTIFICATION =18, 00119 CAP_PROP_MONOCHROME =19, 00120 CAP_PROP_SHARPNESS =20, 00121 CAP_PROP_AUTO_EXPOSURE =21, // DC1394: exposure control done by camera, user can adjust refernce level using this feature 00122 CAP_PROP_GAMMA =22, 00123 CAP_PROP_TEMPERATURE =23, 00124 CAP_PROP_TRIGGER =24, 00125 CAP_PROP_TRIGGER_DELAY =25, 00126 CAP_PROP_WHITE_BALANCE_RED_V =26, 00127 CAP_PROP_ZOOM =27, 00128 CAP_PROP_FOCUS =28, 00129 CAP_PROP_GUID =29, 00130 CAP_PROP_ISO_SPEED =30, 00131 CAP_PROP_BACKLIGHT =32, 00132 CAP_PROP_PAN =33, 00133 CAP_PROP_TILT =34, 00134 CAP_PROP_ROLL =35, 00135 CAP_PROP_IRIS =36, 00136 CAP_PROP_SETTINGS =37, 00137 CAP_PROP_BUFFERSIZE =38, 00138 CAP_PROP_AUTOFOCUS =39 00139 }; 00140 00141 00142 // Generic camera output modes. 00143 // Currently, these are supported through the libv4l interface only. 00144 enum { CAP_MODE_BGR = 0, // BGR24 (default) 00145 CAP_MODE_RGB = 1, // RGB24 00146 CAP_MODE_GRAY = 2, // Y8 00147 CAP_MODE_YUYV = 3 // YUYV 00148 }; 00149 00150 00151 // DC1394 only 00152 // modes of the controlling registers (can be: auto, manual, auto single push, absolute Latter allowed with any other mode) 00153 // every feature can have only one mode turned on at a time 00154 enum { CAP_PROP_DC1394_OFF = -4, //turn the feature off (not controlled manually nor automatically) 00155 CAP_PROP_DC1394_MODE_MANUAL = -3, //set automatically when a value of the feature is set by the user 00156 CAP_PROP_DC1394_MODE_AUTO = -2, 00157 CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1, 00158 CAP_PROP_DC1394_MAX = 31 00159 }; 00160 00161 00162 // OpenNI map generators 00163 enum { CAP_OPENNI_DEPTH_GENERATOR = 1 << 31, 00164 CAP_OPENNI_IMAGE_GENERATOR = 1 << 30, 00165 CAP_OPENNI_GENERATORS_MASK = CAP_OPENNI_DEPTH_GENERATOR + CAP_OPENNI_IMAGE_GENERATOR 00166 }; 00167 00168 // Properties of cameras available through OpenNI interfaces 00169 enum { CAP_PROP_OPENNI_OUTPUT_MODE = 100, 00170 CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm 00171 CAP_PROP_OPENNI_BASELINE = 102, // in mm 00172 CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels 00173 CAP_PROP_OPENNI_REGISTRATION = 104, // flag that synchronizes the remapping depth map to image map 00174 // by changing depth generator's view point (if the flag is "on") or 00175 // sets this view point to its normal one (if the flag is "off"). 00176 CAP_PROP_OPENNI_REGISTRATION_ON = CAP_PROP_OPENNI_REGISTRATION, 00177 CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105, 00178 CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106, 00179 CAP_PROP_OPENNI_CIRCLE_BUFFER = 107, 00180 CAP_PROP_OPENNI_MAX_TIME_DURATION = 108, 00181 CAP_PROP_OPENNI_GENERATOR_PRESENT = 109, 00182 CAP_PROP_OPENNI2_SYNC = 110, 00183 CAP_PROP_OPENNI2_MIRROR = 111 00184 }; 00185 00186 // OpenNI shortcats 00187 enum { CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT, 00188 CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_OUTPUT_MODE, 00189 CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_BASELINE, 00190 CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_FOCAL_LENGTH, 00191 CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION, 00192 CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION 00193 }; 00194 00195 // OpenNI data given from depth generator 00196 enum { CAP_OPENNI_DEPTH_MAP = 0, // Depth values in mm (CV_16UC1) 00197 CAP_OPENNI_POINT_CLOUD_MAP = 1, // XYZ in meters (CV_32FC3) 00198 CAP_OPENNI_DISPARITY_MAP = 2, // Disparity in pixels (CV_8UC1) 00199 CAP_OPENNI_DISPARITY_MAP_32F = 3, // Disparity in pixels (CV_32FC1) 00200 CAP_OPENNI_VALID_DEPTH_MASK = 4, // CV_8UC1 00201 00202 // Data given from RGB image generator 00203 CAP_OPENNI_BGR_IMAGE = 5, 00204 CAP_OPENNI_GRAY_IMAGE = 6 00205 }; 00206 00207 // Supported output modes of OpenNI image generator 00208 enum { CAP_OPENNI_VGA_30HZ = 0, 00209 CAP_OPENNI_SXGA_15HZ = 1, 00210 CAP_OPENNI_SXGA_30HZ = 2, 00211 CAP_OPENNI_QVGA_30HZ = 3, 00212 CAP_OPENNI_QVGA_60HZ = 4 00213 }; 00214 00215 00216 // GStreamer 00217 enum { CAP_PROP_GSTREAMER_QUEUE_LENGTH = 200 // default is 1 00218 }; 00219 00220 00221 // PVAPI 00222 enum { CAP_PROP_PVAPI_MULTICASTIP = 300, // ip for anable multicast master mode. 0 for disable multicast 00223 CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE = 301, // FrameStartTriggerMode: Determines how a frame is initiated 00224 CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302, // Horizontal sub-sampling of the image 00225 CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image 00226 CAP_PROP_PVAPI_BINNINGX = 304, // Horizontal binning factor 00227 CAP_PROP_PVAPI_BINNINGY = 305, // Vertical binning factor 00228 CAP_PROP_PVAPI_PIXELFORMAT = 306 // Pixel format 00229 }; 00230 00231 // PVAPI: FrameStartTriggerMode 00232 enum { CAP_PVAPI_FSTRIGMODE_FREERUN = 0, // Freerun 00233 CAP_PVAPI_FSTRIGMODE_SYNCIN1 = 1, // SyncIn1 00234 CAP_PVAPI_FSTRIGMODE_SYNCIN2 = 2, // SyncIn2 00235 CAP_PVAPI_FSTRIGMODE_FIXEDRATE = 3, // FixedRate 00236 CAP_PVAPI_FSTRIGMODE_SOFTWARE = 4 // Software 00237 }; 00238 00239 // PVAPI: DecimationHorizontal, DecimationVertical 00240 enum { CAP_PVAPI_DECIMATION_OFF = 1, // Off 00241 CAP_PVAPI_DECIMATION_2OUTOF4 = 2, // 2 out of 4 decimation 00242 CAP_PVAPI_DECIMATION_2OUTOF8 = 4, // 2 out of 8 decimation 00243 CAP_PVAPI_DECIMATION_2OUTOF16 = 8 // 2 out of 16 decimation 00244 }; 00245 00246 // PVAPI: PixelFormat 00247 enum { CAP_PVAPI_PIXELFORMAT_MONO8 = 1, // Mono8 00248 CAP_PVAPI_PIXELFORMAT_MONO16 = 2, // Mono16 00249 CAP_PVAPI_PIXELFORMAT_BAYER8 = 3, // Bayer8 00250 CAP_PVAPI_PIXELFORMAT_BAYER16 = 4, // Bayer16 00251 CAP_PVAPI_PIXELFORMAT_RGB24 = 5, // Rgb24 00252 CAP_PVAPI_PIXELFORMAT_BGR24 = 6, // Bgr24 00253 CAP_PVAPI_PIXELFORMAT_RGBA32 = 7, // Rgba32 00254 CAP_PVAPI_PIXELFORMAT_BGRA32 = 8, // Bgra32 00255 }; 00256 00257 // Properties of cameras available through XIMEA SDK interface 00258 enum { CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping. 00259 CAP_PROP_XI_DATA_FORMAT = 401, // Output data format. 00260 CAP_PROP_XI_OFFSET_X = 402, // Horizontal offset from the origin to the area of interest (in pixels). 00261 CAP_PROP_XI_OFFSET_Y = 403, // Vertical offset from the origin to the area of interest (in pixels). 00262 CAP_PROP_XI_TRG_SOURCE = 404, // Defines source of trigger. 00263 CAP_PROP_XI_TRG_SOFTWARE = 405, // Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE. 00264 CAP_PROP_XI_GPI_SELECTOR = 406, // Selects general purpose input 00265 CAP_PROP_XI_GPI_MODE = 407, // Set general purpose input mode 00266 CAP_PROP_XI_GPI_LEVEL = 408, // Get general purpose level 00267 CAP_PROP_XI_GPO_SELECTOR = 409, // Selects general purpose output 00268 CAP_PROP_XI_GPO_MODE = 410, // Set general purpose output mode 00269 CAP_PROP_XI_LED_SELECTOR = 411, // Selects camera signalling LED 00270 CAP_PROP_XI_LED_MODE = 412, // Define camera signalling LED functionality 00271 CAP_PROP_XI_MANUAL_WB = 413, // Calculates White Balance(must be called during acquisition) 00272 CAP_PROP_XI_AUTO_WB = 414, // Automatic white balance 00273 CAP_PROP_XI_AEAG = 415, // Automatic exposure/gain 00274 CAP_PROP_XI_EXP_PRIORITY = 416, // Exposure priority (0.5 - exposure 50%, gain 50%). 00275 CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure 00276 CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure 00277 CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %) 00278 CAP_PROP_XI_TIMEOUT = 420 // Image capture timeout in milliseconds 00279 }; 00280 00281 // Properties of cameras available through AVFOUNDATION interface 00282 enum { CAP_PROP_IOS_DEVICE_FOCUS = 9001, 00283 CAP_PROP_IOS_DEVICE_EXPOSURE = 9002, 00284 CAP_PROP_IOS_DEVICE_FLASH = 9003, 00285 CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004, 00286 CAP_PROP_IOS_DEVICE_TORCH = 9005 00287 }; 00288 00289 00290 // Properties of cameras available through Smartek Giganetix Ethernet Vision interface 00291 /* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */ 00292 enum { CAP_PROP_GIGA_FRAME_OFFSET_X = 10001, 00293 CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002, 00294 CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003, 00295 CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004, 00296 CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005, 00297 CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006 00298 }; 00299 00300 enum { CAP_PROP_INTELPERC_PROFILE_COUNT = 11001, 00301 CAP_PROP_INTELPERC_PROFILE_IDX = 11002, 00302 CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003, 00303 CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004, 00304 CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005, 00305 CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006, 00306 CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007 00307 }; 00308 00309 // Intel PerC streams 00310 enum { CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29, 00311 CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28, 00312 CAP_INTELPERC_GENERATORS_MASK = CAP_INTELPERC_DEPTH_GENERATOR + CAP_INTELPERC_IMAGE_GENERATOR 00313 }; 00314 00315 enum { CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. 00316 CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. 00317 CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. 00318 CAP_INTELPERC_IMAGE = 3 00319 }; 00320 00321 enum { VIDEOWRITER_PROP_QUALITY = 1, // Quality (0..100%) of the videostream encoded 00322 VIDEOWRITER_PROP_FRAMEBYTES = 2, // (Read-only): Size of just encoded video frame 00323 VIDEOWRITER_PROP_NSTRIPES = 3 // Number of stripes for parallel encoding. -1 for auto detection 00324 }; 00325 00326 // gPhoto2 properties, if propertyId is less than 0 then work on widget with that __additive inversed__ camera setting ID 00327 // Get IDs by using CAP_PROP_GPHOTO2_WIDGET_ENUMERATE. 00328 // @see CvCaptureCAM_GPHOTO2 for more info 00329 enum { CAP_PROP_GPHOTO2_PREVIEW = 17001, // Capture only preview from liveview mode. 00330 CAP_PROP_GPHOTO2_WIDGET_ENUMERATE = 17002, // Readonly, returns (const char *). 00331 CAP_PROP_GPHOTO2_RELOAD_CONFIG = 17003, // Trigger, only by set. Reload camera settings. 00332 CAP_PROP_GPHOTO2_RELOAD_ON_CHANGE = 17004, // Reload all settings on set. 00333 CAP_PROP_GPHOTO2_COLLECT_MSGS = 17005, // Collect messages with details. 00334 CAP_PROP_GPHOTO2_FLUSH_MSGS = 17006, // Readonly, returns (const char *). 00335 CAP_PROP_SPEED = 17007, // Exposure speed. Can be readonly, depends on camera program. 00336 CAP_PROP_APERTURE = 17008, // Aperture. Can be readonly, depends on camera program. 00337 CAP_PROP_EXPOSUREPROGRAM = 17009, // Camera exposure program. 00338 CAP_PROP_VIEWFINDER = 17010 // Enter liveview mode. 00339 }; 00340 00341 //enum { 00342 00343 class IVideoCapture; 00344 00345 /** @brief Class for video capturing from video files, image sequences or cameras. The class provides C++ API 00346 for capturing video from cameras or for reading video files and image sequences. Here is how the 00347 class can be used: : 00348 @code 00349 #include "opencv2/opencv.hpp" 00350 00351 using namespace cv; 00352 00353 int main(int, char**) 00354 { 00355 VideoCapture cap(0); // open the default camera 00356 if(!cap.isOpened()) // check if we succeeded 00357 return -1; 00358 00359 Mat edges; 00360 namedWindow("edges",1); 00361 for(;;) 00362 { 00363 Mat frame; 00364 cap >> frame; // get a new frame from camera 00365 cvtColor(frame, edges, COLOR_BGR2GRAY); 00366 GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5); 00367 Canny(edges, edges, 0, 30, 3); 00368 imshow("edges", edges); 00369 if(waitKey(30) >= 0) break; 00370 } 00371 // the camera will be deinitialized automatically in VideoCapture destructor 00372 return 0; 00373 } 00374 @endcode 00375 @note In C API the black-box structure CvCapture is used instead of VideoCapture. 00376 00377 @note 00378 - A basic sample on using the VideoCapture interface can be found at 00379 opencv_source_code/samples/cpp/starter_video.cpp 00380 - Another basic video processing sample can be found at 00381 opencv_source_code/samples/cpp/video_dmtx.cpp 00382 - (Python) A basic sample on using the VideoCapture interface can be found at 00383 opencv_source_code/samples/python/video.py 00384 - (Python) Another basic video processing sample can be found at 00385 opencv_source_code/samples/python/video_dmtx.py 00386 - (Python) A multi threaded video processing sample can be found at 00387 opencv_source_code/samples/python/video_threaded.py 00388 */ 00389 class CV_EXPORTS_W VideoCapture 00390 { 00391 public: 00392 /** @brief 00393 @note In C API, when you finished working with video, release CvCapture structure with 00394 cvReleaseCapture(), or use Ptr<CvCapture> that calls cvReleaseCapture() automatically in the 00395 destructor. 00396 */ 00397 CV_WRAP VideoCapture(); 00398 00399 /** @overload 00400 @param filename name of the opened video file (eg. video.avi) or image sequence (eg. 00401 img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...) 00402 */ 00403 CV_WRAP VideoCapture(const String& filename); 00404 00405 /** @overload 00406 @param filename name of the opened video file (eg. video.avi) or image sequence (eg. 00407 img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...) 00408 00409 @param apiPreference preferred Capture API to use. Can be used to enforce a specific reader 00410 implementation if multiple are available: e.g. CAP_FFMPEG or CAP_IMAGES 00411 */ 00412 CV_WRAP VideoCapture(const String& filename, int apiPreference); 00413 00414 /** @overload 00415 @param index = camera_id + domain_offset (CAP_*). id of the video capturing device to open. If there is a single 00416 camera connected, just pass 0. Advanced Usage: to open Camera 1 using the MS Media Foundation API: index = 1 + CAP_MSMF 00417 */ 00418 CV_WRAP VideoCapture(int index); 00419 00420 virtual ~VideoCapture(); 00421 00422 /** @brief Open video file or a capturing device for video capturing 00423 00424 @param filename name of the opened video file (eg. video.avi) or image sequence (eg. 00425 img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...) 00426 00427 The methods first call VideoCapture::release to close the already opened file or camera. 00428 */ 00429 CV_WRAP virtual bool open(const String& filename); 00430 00431 /** @overload 00432 @param index = camera_id + domain_offset (CAP_*). id of the video capturing device to open. If there is a single 00433 camera connected, just pass 0. Advanced Usage: to open Camera 1 using the MS Media Foundation API: index = 1 + CAP_MSMF 00434 */ 00435 CV_WRAP virtual bool open(int index); 00436 00437 /** @brief Returns true if video capturing has been initialized already. 00438 00439 If the previous call to VideoCapture constructor or VideoCapture::open succeeded, the method returns 00440 true. 00441 */ 00442 CV_WRAP virtual bool isOpened() const; 00443 00444 /** @brief Closes video file or capturing device. 00445 00446 The methods are automatically called by subsequent VideoCapture::open and by VideoCapture 00447 destructor. 00448 00449 The C function also deallocates memory and clears \*capture pointer. 00450 */ 00451 CV_WRAP virtual void release(); 00452 00453 /** @brief Grabs the next frame from video file or capturing device. 00454 00455 The methods/functions grab the next frame from video file or camera and return true (non-zero) in 00456 the case of success. 00457 00458 The primary use of the function is in multi-camera environments, especially when the cameras do not 00459 have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that 00460 call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way 00461 the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames 00462 from different cameras will be closer in time. 00463 00464 Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the 00465 correct way of retrieving data from it is to call VideoCapture::grab first and then call 00466 VideoCapture::retrieve one or more times with different values of the channel parameter. See 00467 <https://github.com/Itseez/opencv/tree/master/samples/cpp/openni_capture.cpp> 00468 */ 00469 CV_WRAP virtual bool grab(); 00470 00471 /** @brief Decodes and returns the grabbed video frame. 00472 00473 The methods/functions decode and return the just grabbed frame. If no frames has been grabbed 00474 (camera has been disconnected, or there are no more frames in video file), the methods return false 00475 and the functions return NULL pointer. 00476 00477 @note OpenCV 1.x functions cvRetrieveFrame and cv.RetrieveFrame return image stored inside the video 00478 capturing structure. It is not allowed to modify or release the image! You can copy the frame using 00479 :ocvcvCloneImage and then do whatever you want with the copy. 00480 */ 00481 CV_WRAP virtual bool retrieve(OutputArray image, int flag = 0); 00482 virtual VideoCapture& operator >> (CV_OUT Mat& image); 00483 virtual VideoCapture& operator >> (CV_OUT UMat & image); 00484 00485 /** @brief Grabs, decodes and returns the next video frame. 00486 00487 The methods/functions combine VideoCapture::grab and VideoCapture::retrieve in one call. This is the 00488 most convenient method for reading video files or capturing data from decode and return the just 00489 grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more 00490 frames in video file), the methods return false and the functions return NULL pointer. 00491 00492 @note OpenCV 1.x functions cvRetrieveFrame and cv.RetrieveFrame return image stored inside the video 00493 capturing structure. It is not allowed to modify or release the image! You can copy the frame using 00494 :ocvcvCloneImage and then do whatever you want with the copy. 00495 */ 00496 CV_WRAP virtual bool read(OutputArray image); 00497 00498 /** @brief Sets a property in the VideoCapture. 00499 00500 @param propId Property identifier. It can be one of the following: 00501 - **CAP_PROP_POS_MSEC** Current position of the video file in milliseconds. 00502 - **CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next. 00503 - **CAP_PROP_POS_AVI_RATIO** Relative position of the video file: 0 - start of the 00504 film, 1 - end of the film. 00505 - **CAP_PROP_FRAME_WIDTH** Width of the frames in the video stream. 00506 - **CAP_PROP_FRAME_HEIGHT** Height of the frames in the video stream. 00507 - **CAP_PROP_FPS** Frame rate. 00508 - **CAP_PROP_FOURCC** 4-character code of codec. 00509 - **CAP_PROP_FRAME_COUNT** Number of frames in the video file. 00510 - **CAP_PROP_FORMAT** Format of the Mat objects returned by retrieve() . 00511 - **CAP_PROP_MODE** Backend-specific value indicating the current capture mode. 00512 - **CAP_PROP_BRIGHTNESS** Brightness of the image (only for cameras). 00513 - **CAP_PROP_CONTRAST** Contrast of the image (only for cameras). 00514 - **CAP_PROP_SATURATION** Saturation of the image (only for cameras). 00515 - **CAP_PROP_HUE** Hue of the image (only for cameras). 00516 - **CAP_PROP_GAIN** Gain of the image (only for cameras). 00517 - **CAP_PROP_EXPOSURE** Exposure (only for cameras). 00518 - **CAP_PROP_CONVERT_RGB** Boolean flags indicating whether images should be converted 00519 to RGB. 00520 - **CAP_PROP_WHITE_BALANCE** Currently unsupported 00521 - **CAP_PROP_RECTIFICATION** Rectification flag for stereo cameras (note: only supported 00522 by DC1394 v 2.x backend currently) 00523 @param value Value of the property. 00524 */ 00525 CV_WRAP virtual bool set(int propId, double value); 00526 00527 /** @brief Returns the specified VideoCapture property 00528 00529 @param propId Property identifier. It can be one of the following: 00530 - **CAP_PROP_POS_MSEC** Current position of the video file in milliseconds or video 00531 capture timestamp. 00532 - **CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next. 00533 - **CAP_PROP_POS_AVI_RATIO** Relative position of the video file: 0 - start of the 00534 film, 1 - end of the film. 00535 - **CAP_PROP_FRAME_WIDTH** Width of the frames in the video stream. 00536 - **CAP_PROP_FRAME_HEIGHT** Height of the frames in the video stream. 00537 - **CAP_PROP_FPS** Frame rate. 00538 - **CAP_PROP_FOURCC** 4-character code of codec. 00539 - **CAP_PROP_FRAME_COUNT** Number of frames in the video file. 00540 - **CAP_PROP_FORMAT** Format of the Mat objects returned by retrieve() . 00541 - **CAP_PROP_MODE** Backend-specific value indicating the current capture mode. 00542 - **CAP_PROP_BRIGHTNESS** Brightness of the image (only for cameras). 00543 - **CAP_PROP_CONTRAST** Contrast of the image (only for cameras). 00544 - **CAP_PROP_SATURATION** Saturation of the image (only for cameras). 00545 - **CAP_PROP_HUE** Hue of the image (only for cameras). 00546 - **CAP_PROP_GAIN** Gain of the image (only for cameras). 00547 - **CAP_PROP_EXPOSURE** Exposure (only for cameras). 00548 - **CAP_PROP_CONVERT_RGB** Boolean flags indicating whether images should be converted 00549 to RGB. 00550 - **CAP_PROP_WHITE_BALANCE** Currently not supported 00551 - **CAP_PROP_RECTIFICATION** Rectification flag for stereo cameras (note: only supported 00552 by DC1394 v 2.x backend currently) 00553 00554 @note When querying a property that is not supported by the backend used by the VideoCapture 00555 class, value 0 is returned. 00556 */ 00557 CV_WRAP virtual double get(int propId) const; 00558 00559 /** @overload 00560 00561 @param filename name of the opened video file (eg. video.avi) or image sequence (eg. 00562 img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...) 00563 00564 @param apiPreference preferred Capture API to use. Can be used to enforce a specific reader 00565 implementation if multiple are available: e.g. CAP_FFMPEG or CAP_IMAGES 00566 00567 The methods first call VideoCapture::release to close the already opened file or camera. 00568 */ 00569 CV_WRAP virtual bool open(const String& filename, int apiPreference); 00570 00571 protected: 00572 Ptr<CvCapture> cap; 00573 Ptr<IVideoCapture> icap; 00574 }; 00575 00576 class IVideoWriter; 00577 00578 /** @brief Video writer class. 00579 */ 00580 class CV_EXPORTS_W VideoWriter 00581 { 00582 public: 00583 /** @brief VideoWriter constructors 00584 00585 The constructors/functions initialize video writers. On Linux FFMPEG is used to write videos; on 00586 Windows FFMPEG or VFW is used; on MacOSX QTKit is used. 00587 */ 00588 CV_WRAP VideoWriter(); 00589 00590 /** @overload 00591 @param filename Name of the output video file. 00592 @param fourcc 4-character code of codec used to compress the frames. For example, 00593 VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') is a 00594 motion-jpeg codec etc. List of codes can be obtained at [Video Codecs by 00595 FOURCC](http://www.fourcc.org/codecs.php) page. FFMPEG backend with MP4 container natively uses 00596 other values as fourcc code: see [ObjectType](http://www.mp4ra.org/codecs.html), 00597 so you may receive a warning message from OpenCV about fourcc code conversion. 00598 @param fps Framerate of the created video stream. 00599 @param frameSize Size of the video frames. 00600 @param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it 00601 will work with grayscale frames (the flag is currently supported on Windows only). 00602 */ 00603 CV_WRAP VideoWriter(const String& filename, int fourcc, double fps, 00604 Size frameSize, bool isColor = true); 00605 00606 virtual ~VideoWriter(); 00607 00608 /** @brief Initializes or reinitializes video writer. 00609 00610 The method opens video writer. Parameters are the same as in the constructor 00611 VideoWriter::VideoWriter. 00612 */ 00613 CV_WRAP virtual bool open(const String& filename, int fourcc, double fps, 00614 Size frameSize, bool isColor = true); 00615 00616 /** @brief Returns true if video writer has been successfully initialized. 00617 */ 00618 CV_WRAP virtual bool isOpened() const; 00619 00620 /** @brief Closes the video writer. 00621 00622 The methods are automatically called by subsequent VideoWriter::open and by the VideoWriter 00623 destructor. 00624 */ 00625 CV_WRAP virtual void release(); 00626 virtual VideoWriter& operator << (const Mat& image); 00627 00628 /** @brief Writes the next video frame 00629 00630 @param image The written frame 00631 00632 The functions/methods write the specified image to video file. It must have the same size as has 00633 been specified when opening the video writer. 00634 */ 00635 CV_WRAP virtual void write(const Mat& image); 00636 00637 /** @brief Sets a property in the VideoWriter. 00638 00639 @param propId Property identifier. It can be one of the following: 00640 - **VIDEOWRITER_PROP_QUALITY** Quality (0..100%) of the videostream encoded. Can be adjusted dynamically in some codecs. 00641 - **VIDEOWRITER_PROP_NSTRIPES** Number of stripes for parallel encoding 00642 @param value Value of the property. 00643 */ 00644 CV_WRAP virtual bool set(int propId, double value); 00645 00646 /** @brief Returns the specified VideoWriter property 00647 00648 @param propId Property identifier. It can be one of the following: 00649 - **VIDEOWRITER_PROP_QUALITY** Current quality of the encoded videostream. 00650 - **VIDEOWRITER_PROP_FRAMEBYTES** (Read-only) Size of just encoded video frame; note that the encoding order may be different from representation order. 00651 - **VIDEOWRITER_PROP_NSTRIPES** Number of stripes for parallel encoding 00652 00653 @note When querying a property that is not supported by the backend used by the VideoWriter 00654 class, value 0 is returned. 00655 */ 00656 CV_WRAP virtual double get(int propId) const; 00657 00658 /** @brief Concatenates 4 chars to a fourcc code 00659 00660 This static method constructs the fourcc code of the codec to be used in the constructor 00661 VideoWriter::VideoWriter or VideoWriter::open. 00662 */ 00663 CV_WRAP static int fourcc(char c1, char c2, char c3, char c4); 00664 00665 protected: 00666 Ptr<CvVideoWriter> writer; 00667 Ptr<IVideoWriter> iwriter; 00668 00669 static Ptr<IVideoWriter> create(const String& filename, int fourcc, double fps, 00670 Size frameSize, bool isColor = true); 00671 }; 00672 00673 template<> CV_EXPORTS void DefaultDeleter<CvCapture>::operator ()(CvCapture* obj) const; 00674 template<> CV_EXPORTS void DefaultDeleter<CvVideoWriter>::operator ()(CvVideoWriter* obj) const; 00675 00676 //! @} videoio 00677 00678 } // cv 00679 00680 #endif //__OPENCV_VIDEOIO_HPP__ 00681
Generated on Tue Jul 12 2022 16:42:40 by 1.7.2