VideoCapture.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. //
  2. // This file is auto-generated. Please don't modify it!
  3. //
  4. #pragma once
  5. #ifdef __cplusplus
  6. //#import "opencv.hpp"
  7. #import "opencv2/videoio.hpp"
  8. #else
  9. #define CV_EXPORTS
  10. #endif
  11. #import <Foundation/Foundation.h>
  12. @class IntVector;
  13. @class Mat;
  14. NS_ASSUME_NONNULL_BEGIN
  15. // C++: class VideoCapture
  16. /**
  17. * Class for video capturing from video files, image sequences or cameras.
  18. *
  19. * The class provides C++ API for capturing video from cameras or for reading video files and image sequences.
  20. *
  21. * Here is how the class can be used:
  22. * INCLUDE: samples/cpp/videocapture_basic.cpp
  23. *
  24. * NOTE: In REF: videoio_c "C API" the black-box structure `CvCapture` is used instead of %VideoCapture.
  25. * NOTE:
  26. * - (C++) A basic sample on using the %VideoCapture interface can be found at
  27. * `OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cpp`
  28. * - (Python) A basic sample on using the %VideoCapture interface can be found at
  29. * `OPENCV_SOURCE_CODE/samples/python/video.py`
  30. * - (Python) A multi threaded video processing sample can be found at
  31. * `OPENCV_SOURCE_CODE/samples/python/video_threaded.py`
  32. * - (Python) %VideoCapture sample showcasing some features of the Video4Linux2 backend
  33. * `OPENCV_SOURCE_CODE/samples/python/video_v4l2.py`
  34. *
  35. * Member of `Videoio`
  36. */
  37. CV_EXPORTS @interface VideoCapture : NSObject
  38. #ifdef __cplusplus
  39. @property(readonly)cv::Ptr<cv::VideoCapture> nativePtr;
  40. #endif
  41. #ifdef __cplusplus
  42. - (instancetype)initWithNativePtr:(cv::Ptr<cv::VideoCapture>)nativePtr;
  43. + (instancetype)fromNative:(cv::Ptr<cv::VideoCapture>)nativePtr;
  44. #endif
  45. #pragma mark - Methods
  46. //
  47. // cv::VideoCapture::VideoCapture()
  48. //
  49. /**
  50. * Default constructor
  51. * NOTE: In REF: videoio_c "C API", when you finished working with video, release CvCapture structure with
  52. * cvReleaseCapture(), or use Ptr\<CvCapture\> that calls cvReleaseCapture() automatically in the
  53. * destructor.
  54. */
  55. - (instancetype)init;
  56. //
  57. // cv::VideoCapture::VideoCapture(String filename, int apiPreference = CAP_ANY)
  58. //
  59. /**
  60. *
  61. * Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
  62. *
  63. * @param filename it can be:
  64. * - name of video file (eg. `video.avi`)
  65. * - or image sequence (eg. `img_%02d.jpg`, which will read samples like `img_00.jpg, img_01.jpg, img_02.jpg, ...`)
  66. * - or URL of video stream (eg. `protocol://host:port/script_name?script_params|auth`)
  67. * - or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend
  68. * Note that each video stream or IP camera feed has its own URL scheme. Please refer to the
  69. * documentation of source stream to know the right URL.
  70. * @param apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader
  71. * implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
  72. *
  73. * @see `cv::VideoCaptureAPIs`
  74. */
  75. - (instancetype)initWithFilename:(NSString*)filename apiPreference:(int)apiPreference;
  76. /**
  77. *
  78. * Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
  79. *
  80. * @param filename it can be:
  81. * - name of video file (eg. `video.avi`)
  82. * - or image sequence (eg. `img_%02d.jpg`, which will read samples like `img_00.jpg, img_01.jpg, img_02.jpg, ...`)
  83. * - or URL of video stream (eg. `protocol://host:port/script_name?script_params|auth`)
  84. * - or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend
  85. * Note that each video stream or IP camera feed has its own URL scheme. Please refer to the
  86. * documentation of source stream to know the right URL.
  87. * implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
  88. *
  89. * @see `cv::VideoCaptureAPIs`
  90. */
  91. - (instancetype)initWithFilename:(NSString*)filename;
  92. //
  93. // cv::VideoCapture::VideoCapture(String filename, int apiPreference, vector_int params)
  94. //
  95. /**
  96. *
  97. * Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
  98. *
  99. * The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`.
  100. * See cv::VideoCaptureProperties
  101. */
  102. - (instancetype)initWithFilename:(NSString*)filename apiPreference:(int)apiPreference params:(IntVector*)params;
  103. //
  104. // cv::VideoCapture::VideoCapture(int index, int apiPreference = CAP_ANY)
  105. //
  106. /**
  107. *
  108. * Opens a camera for video capturing
  109. *
  110. * @param index id of the video capturing device to open. To open default camera using default backend just pass 0.
  111. * (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)
  112. * @param apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader
  113. * implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.
  114. *
  115. * @see `cv::VideoCaptureAPIs`
  116. */
  117. - (instancetype)initWithIndex:(int)index apiPreference:(int)apiPreference;
  118. /**
  119. *
  120. * Opens a camera for video capturing
  121. *
  122. * @param index id of the video capturing device to open. To open default camera using default backend just pass 0.
  123. * (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)
  124. * implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.
  125. *
  126. * @see `cv::VideoCaptureAPIs`
  127. */
  128. - (instancetype)initWithIndex:(int)index;
  129. //
  130. // cv::VideoCapture::VideoCapture(int index, int apiPreference, vector_int params)
  131. //
  132. /**
  133. *
  134. * Opens a camera for video capturing with API Preference and parameters
  135. *
  136. * The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`.
  137. * See cv::VideoCaptureProperties
  138. */
  139. - (instancetype)initWithIndex:(int)index apiPreference:(int)apiPreference params:(IntVector*)params;
  140. //
  141. // bool cv::VideoCapture::open(String filename, int apiPreference = CAP_ANY)
  142. //
  143. /**
  144. * Opens a video file or a capturing device or an IP video stream for video capturing.
  145. *
  146. *
  147. *
  148. * Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY)
  149. * @return `true` if the file has been successfully opened
  150. *
  151. * The method first calls VideoCapture::release to close the already opened file or camera.
  152. */
  153. - (BOOL)open:(NSString*)filename apiPreference:(int)apiPreference NS_SWIFT_NAME(open(filename:apiPreference:));
  154. /**
  155. * Opens a video file or a capturing device or an IP video stream for video capturing.
  156. *
  157. *
  158. *
  159. * Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY)
  160. * @return `true` if the file has been successfully opened
  161. *
  162. * The method first calls VideoCapture::release to close the already opened file or camera.
  163. */
  164. - (BOOL)open:(NSString*)filename NS_SWIFT_NAME(open(filename:));
  165. //
  166. // bool cv::VideoCapture::open(String filename, int apiPreference, vector_int params)
  167. //
  168. /**
  169. * Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
  170. *
  171. *
  172. *
  173. * The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`.
  174. * See cv::VideoCaptureProperties
  175. *
  176. * @return `true` if the file has been successfully opened
  177. *
  178. * The method first calls VideoCapture::release to close the already opened file or camera.
  179. */
  180. - (BOOL)open:(NSString*)filename apiPreference:(int)apiPreference params:(IntVector*)params NS_SWIFT_NAME(open(filename:apiPreference:params:));
  181. //
  182. // bool cv::VideoCapture::open(int index, int apiPreference = CAP_ANY)
  183. //
  184. /**
  185. * Opens a camera for video capturing
  186. *
  187. *
  188. *
  189. * Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)
  190. * @return `true` if the camera has been successfully opened.
  191. *
  192. * The method first calls VideoCapture::release to close the already opened file or camera.
  193. */
  194. - (BOOL)openWithIndex:(int)index apiPreference:(int)apiPreference NS_SWIFT_NAME(open(index:apiPreference:));
  195. /**
  196. * Opens a camera for video capturing
  197. *
  198. *
  199. *
  200. * Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)
  201. * @return `true` if the camera has been successfully opened.
  202. *
  203. * The method first calls VideoCapture::release to close the already opened file or camera.
  204. */
  205. - (BOOL)openWithIndex:(int)index NS_SWIFT_NAME(open(index:));
  206. //
  207. // bool cv::VideoCapture::open(int index, int apiPreference, vector_int params)
  208. //
  209. /**
  210. * Opens a camera for video capturing with API Preference and parameters
  211. *
  212. *
  213. *
  214. * The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`.
  215. * See cv::VideoCaptureProperties
  216. *
  217. * @return `true` if the camera has been successfully opened.
  218. *
  219. * The method first calls VideoCapture::release to close the already opened file or camera.
  220. */
  221. - (BOOL)openWithIndexAndParameters:(int)index apiPreference:(int)apiPreference params:(IntVector*)params NS_SWIFT_NAME(open(index:apiPreference:params:));
  222. //
  223. // bool cv::VideoCapture::isOpened()
  224. //
  225. /**
  226. * Returns true if video capturing has been initialized already.
  227. *
  228. * If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns
  229. * true.
  230. */
  231. - (BOOL)isOpened NS_SWIFT_NAME(isOpened());
  232. //
  233. // bool cv::VideoCapture::grab()
  234. //
  235. /**
  236. * Grabs the next frame from video file or capturing device.
  237. *
  238. * @return `true` (non-zero) in the case of success.
  239. *
  240. * The method/function grabs the next frame from video file or camera and returns true (non-zero) in
  241. * the case of success.
  242. *
  243. * The primary use of the function is in multi-camera environments, especially when the cameras do not
  244. * have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that
  245. * call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way
  246. * the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames
  247. * from different cameras will be closer in time.
  248. *
  249. * Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the
  250. * correct way of retrieving data from it is to call VideoCapture::grab() first and then call
  251. * VideoCapture::retrieve() one or more times with different values of the channel parameter.
  252. *
  253. * REF: tutorial_kinect_openni
  254. */
  255. - (BOOL)grab NS_SWIFT_NAME(grab());
  256. //
  257. // bool cv::VideoCapture::retrieve(Mat& image, int flag = 0)
  258. //
  259. /**
  260. * Decodes and returns the grabbed video frame.
  261. *
  262. * @param flag it could be a frame index or a driver specific flag
  263. * @return `false` if no frames has been grabbed
  264. *
  265. * The method decodes and returns the just grabbed frame. If no frames has been grabbed
  266. * (camera has been disconnected, or there are no more frames in video file), the method returns false
  267. * and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).
  268. *
  269. * @see `read()`
  270. *
  271. * NOTE: In REF: videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
  272. * capturing structure. It is not allowed to modify or release the image! You can copy the frame using
  273. * cvCloneImage and then do whatever you want with the copy.
  274. */
  275. - (BOOL)retrieve:(Mat*)image flag:(int)flag NS_SWIFT_NAME(retrieve(image:flag:));
  276. /**
  277. * Decodes and returns the grabbed video frame.
  278. *
  279. * @return `false` if no frames has been grabbed
  280. *
  281. * The method decodes and returns the just grabbed frame. If no frames has been grabbed
  282. * (camera has been disconnected, or there are no more frames in video file), the method returns false
  283. * and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).
  284. *
  285. * @see `read()`
  286. *
  287. * NOTE: In REF: videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
  288. * capturing structure. It is not allowed to modify or release the image! You can copy the frame using
  289. * cvCloneImage and then do whatever you want with the copy.
  290. */
  291. - (BOOL)retrieve:(Mat*)image NS_SWIFT_NAME(retrieve(image:));
  292. //
  293. // bool cv::VideoCapture::read(Mat& image)
  294. //
  295. /**
  296. * Grabs, decodes and returns the next video frame.
  297. *
  298. * @return `false` if no frames has been grabbed
  299. *
  300. * The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the
  301. * most convenient method for reading video files or capturing data from decode and returns the just
  302. * grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more
  303. * frames in video file), the method returns false and the function returns empty image (with %cv::Mat, test it with Mat::empty()).
  304. *
  305. * NOTE: In REF: videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
  306. * capturing structure. It is not allowed to modify or release the image! You can copy the frame using
  307. * cvCloneImage and then do whatever you want with the copy.
  308. */
  309. - (BOOL)read:(Mat*)image NS_SWIFT_NAME(read(image:));
  310. //
  311. // bool cv::VideoCapture::set(int propId, double value)
  312. //
  313. /**
  314. * Sets a property in the VideoCapture.
  315. *
  316. * @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)
  317. * or one from REF: videoio_flags_others
  318. * @param value Value of the property.
  319. * @return `true` if the property is supported by backend used by the VideoCapture instance.
  320. * NOTE: Even if it returns `true` this doesn't ensure that the property
  321. * value has been accepted by the capture device. See note in VideoCapture::get()
  322. */
  323. - (BOOL)set:(int)propId value:(double)value NS_SWIFT_NAME(set(propId:value:));
  324. //
  325. // double cv::VideoCapture::get(int propId)
  326. //
  327. /**
  328. * Returns the specified VideoCapture property
  329. *
  330. * @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)
  331. * or one from REF: videoio_flags_others
  332. * @return Value for the specified property. Value 0 is returned when querying a property that is
  333. * not supported by the backend used by the VideoCapture instance.
  334. *
  335. * NOTE: Reading / writing properties involves many layers. Some unexpected result might happens
  336. * along this chain.
  337. *
  338. * VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware
  339. *
  340. * The returned value might be different from what really used by the device or it could be encoded
  341. * using device dependent rules (eg. steps or percentage). Effective behaviour depends from device
  342. * driver and API Backend
  343. */
  344. - (double)get:(int)propId NS_SWIFT_NAME(get(propId:));
  345. //
  346. // String cv::VideoCapture::getBackendName()
  347. //
  348. /**
  349. * Returns used backend API name
  350. *
  351. * NOTE: Stream should be opened.
  352. */
  353. - (NSString*)getBackendName NS_SWIFT_NAME(getBackendName());
  354. //
  355. // void cv::VideoCapture::setExceptionMode(bool enable)
  356. //
  357. /**
  358. * Switches exceptions mode
  359. *
  360. * methods raise exceptions if not successful instead of returning an error code
  361. */
  362. - (void)setExceptionMode:(BOOL)enable NS_SWIFT_NAME(setExceptionMode(enable:));
  363. //
  364. // bool cv::VideoCapture::getExceptionMode()
  365. //
  366. - (BOOL)getExceptionMode NS_SWIFT_NAME(getExceptionMode());
  367. @end
  368. NS_ASSUME_NONNULL_END