VideoCapture.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.VideoioModule
  7. {
  8. // C++: class VideoCapture
  9. /**
  10. * Class for video capturing from video files, image sequences or cameras.
  11. *
  12. * The class provides C++ API for capturing video from cameras or for reading video files and image sequences.
  13. *
  14. * Here is how the class can be used:
  15. * INCLUDE: samples/cpp/videocapture_basic.cpp
  16. *
  17. * <b>Note:</b> In REF: videoio_c "C API" the black-box structure {code CvCapture} is used instead of %VideoCapture.
  18. * <b>Note:</b>
  19. * <ul>
  20. * <li>
  21. * (C++) A basic sample on using the %VideoCapture interface can be found at
  22. * {code OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cpp}
  23. * </li>
  24. * <li>
  25. * (Python) A basic sample on using the %VideoCapture interface can be found at
  26. * {code OPENCV_SOURCE_CODE/samples/python/video.py}
  27. * </li>
  28. * <li>
  29. * (Python) A multi threaded video processing sample can be found at
  30. * {code OPENCV_SOURCE_CODE/samples/python/video_threaded.py}
  31. * </li>
  32. * <li>
  33. * (Python) %VideoCapture sample showcasing some features of the Video4Linux2 backend
  34. * {code OPENCV_SOURCE_CODE/samples/python/video_v4l2.py}
  35. * </li>
  36. * </ul>
  37. */
  38. public class VideoCapture : DisposableOpenCVObject
  39. {
  40. protected override void Dispose(bool disposing)
  41. {
  42. try
  43. {
  44. if (disposing)
  45. {
  46. }
  47. if (IsEnabledDispose)
  48. {
  49. if (nativeObj != IntPtr.Zero)
  50. videoio_VideoCapture_delete(nativeObj);
  51. nativeObj = IntPtr.Zero;
  52. }
  53. }
  54. finally
  55. {
  56. base.Dispose(disposing);
  57. }
  58. }
  59. protected internal VideoCapture(IntPtr addr) : base(addr) { }
  60. public IntPtr getNativeObjAddr() { return nativeObj; }
  61. // internal usage only
  62. public static VideoCapture __fromPtr__(IntPtr addr) { return new VideoCapture(addr); }
  63. //
  64. // C++: cv::VideoCapture::VideoCapture()
  65. //
  66. /**
  67. * Default constructor
  68. * <b>Note:</b> In REF: videoio_c "C API", when you finished working with video, release CvCapture structure with
  69. * cvReleaseCapture(), or use Ptr&lt;CvCapture&gt; that calls cvReleaseCapture() automatically in the
  70. * destructor.
  71. */
  72. public VideoCapture()
  73. {
  74. nativeObj = DisposableObject.ThrowIfNullIntPtr(videoio_VideoCapture_VideoCapture_10());
  75. }
  76. //
  77. // C++: cv::VideoCapture::VideoCapture(String filename, int apiPreference = CAP_ANY)
  78. //
  79. /**
  80. *
  81. * Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
  82. *
  83. * param filename it can be:
  84. * <ul>
  85. * <li>
  86. * name of video file (eg. {code video.avi})
  87. * </li>
  88. * <li>
  89. * or image sequence (eg. {code img_%02d.jpg}, which will read samples like {code img_00.jpg, img_01.jpg, img_02.jpg, ...})
  90. * </li>
  91. * <li>
  92. * or URL of video stream (eg. {code protocol://host:port/script_name?script_params|auth})
  93. * </li>
  94. * <li>
  95. * or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend
  96. * Note that each video stream or IP camera feed has its own URL scheme. Please refer to the
  97. * documentation of source stream to know the right URL.
  98. * </li>
  99. * </ul>
  100. * param apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader
  101. * implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
  102. *
  103. * SEE: cv::VideoCaptureAPIs
  104. */
  105. public VideoCapture(string filename, int apiPreference)
  106. {
  107. nativeObj = DisposableObject.ThrowIfNullIntPtr(videoio_VideoCapture_VideoCapture_11(filename, apiPreference));
  108. }
  109. /**
  110. *
  111. * Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
  112. *
  113. * param filename it can be:
  114. * <ul>
  115. * <li>
  116. * name of video file (eg. {code video.avi})
  117. * </li>
  118. * <li>
  119. * or image sequence (eg. {code img_%02d.jpg}, which will read samples like {code img_00.jpg, img_01.jpg, img_02.jpg, ...})
  120. * </li>
  121. * <li>
  122. * or URL of video stream (eg. {code protocol://host:port/script_name?script_params|auth})
  123. * </li>
  124. * <li>
  125. * or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend
  126. * Note that each video stream or IP camera feed has its own URL scheme. Please refer to the
  127. * documentation of source stream to know the right URL.
  128. * </li>
  129. * </ul>
  130. * implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
  131. *
  132. * SEE: cv::VideoCaptureAPIs
  133. */
  134. public VideoCapture(string filename)
  135. {
  136. nativeObj = DisposableObject.ThrowIfNullIntPtr(videoio_VideoCapture_VideoCapture_12(filename));
  137. }
  138. //
  139. // C++: cv::VideoCapture::VideoCapture(String filename, int apiPreference, vector_int _params)
  140. //
  141. /**
  142. *
  143. * Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
  144. *
  145. * The {code params} parameter allows to specify extra parameters encoded as pairs {code (paramId_1, paramValue_1, paramId_2, paramValue_2, ...)}.
  146. * See cv::VideoCaptureProperties
  147. * param filename automatically generated
  148. * param apiPreference automatically generated
  149. * param _params automatically generated
  150. */
  151. public VideoCapture(string filename, int apiPreference, MatOfInt _params)
  152. {
  153. if (_params != null) _params.ThrowIfDisposed();
  154. Mat _params_mat = _params;
  155. nativeObj = DisposableObject.ThrowIfNullIntPtr(videoio_VideoCapture_VideoCapture_13(filename, apiPreference, _params_mat.nativeObj));
  156. }
  157. //
  158. // C++: cv::VideoCapture::VideoCapture(int index, int apiPreference = CAP_ANY)
  159. //
  160. /**
  161. *
  162. * Opens a camera for video capturing
  163. *
  164. * param index id of the video capturing device to open. To open default camera using default backend just pass 0.
  165. * (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)
  166. * param apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader
  167. * implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.
  168. *
  169. * SEE: cv::VideoCaptureAPIs
  170. */
  171. public VideoCapture(int index, int apiPreference)
  172. {
  173. nativeObj = DisposableObject.ThrowIfNullIntPtr(videoio_VideoCapture_VideoCapture_14(index, apiPreference));
  174. }
  175. /**
  176. *
  177. * Opens a camera for video capturing
  178. *
  179. * param index id of the video capturing device to open. To open default camera using default backend just pass 0.
  180. * (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)
  181. * implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.
  182. *
  183. * SEE: cv::VideoCaptureAPIs
  184. */
  185. public VideoCapture(int index)
  186. {
  187. nativeObj = DisposableObject.ThrowIfNullIntPtr(videoio_VideoCapture_VideoCapture_15(index));
  188. }
  189. //
  190. // C++: cv::VideoCapture::VideoCapture(int index, int apiPreference, vector_int _params)
  191. //
  192. /**
  193. *
  194. * Opens a camera for video capturing with API Preference and parameters
  195. *
  196. * The {code params} parameter allows to specify extra parameters encoded as pairs {code (paramId_1, paramValue_1, paramId_2, paramValue_2, ...)}.
  197. * See cv::VideoCaptureProperties
  198. * param index automatically generated
  199. * param apiPreference automatically generated
  200. * param _params automatically generated
  201. */
  202. public VideoCapture(int index, int apiPreference, MatOfInt _params)
  203. {
  204. if (_params != null) _params.ThrowIfDisposed();
  205. Mat _params_mat = _params;
  206. nativeObj = DisposableObject.ThrowIfNullIntPtr(videoio_VideoCapture_VideoCapture_16(index, apiPreference, _params_mat.nativeObj));
  207. }
  208. //
  209. // C++: bool cv::VideoCapture::open(String filename, int apiPreference = CAP_ANY)
  210. //
  211. /**
  212. * Opens a video file or a capturing device or an IP video stream for video capturing.
  213. *
  214. *
  215. *
  216. * Parameters are same as the constructor VideoCapture(const String&amp; filename, int apiPreference = CAP_ANY)
  217. * return {code true} if the file has been successfully opened
  218. *
  219. * The method first calls VideoCapture::release to close the already opened file or camera.
  220. * param filename automatically generated
  221. * param apiPreference automatically generated
  222. */
  223. public bool open(string filename, int apiPreference)
  224. {
  225. ThrowIfDisposed();
  226. return videoio_VideoCapture_open_10(nativeObj, filename, apiPreference);
  227. }
  228. /**
  229. * Opens a video file or a capturing device or an IP video stream for video capturing.
  230. *
  231. *
  232. *
  233. * Parameters are same as the constructor VideoCapture(const String&amp; filename, int apiPreference = CAP_ANY)
  234. * return {code true} if the file has been successfully opened
  235. *
  236. * The method first calls VideoCapture::release to close the already opened file or camera.
  237. * param filename automatically generated
  238. */
  239. public bool open(string filename)
  240. {
  241. ThrowIfDisposed();
  242. return videoio_VideoCapture_open_11(nativeObj, filename);
  243. }
  244. //
  245. // C++: bool cv::VideoCapture::open(String filename, int apiPreference, vector_int _params)
  246. //
  247. /**
  248. * Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
  249. *
  250. *
  251. *
  252. * The {code params} parameter allows to specify extra parameters encoded as pairs {code (paramId_1, paramValue_1, paramId_2, paramValue_2, ...)}.
  253. * See cv::VideoCaptureProperties
  254. *
  255. * return {code true} if the file has been successfully opened
  256. *
  257. * The method first calls VideoCapture::release to close the already opened file or camera.
  258. * param filename automatically generated
  259. * param apiPreference automatically generated
  260. * param _params automatically generated
  261. */
  262. public bool open(string filename, int apiPreference, MatOfInt _params)
  263. {
  264. ThrowIfDisposed();
  265. if (_params != null) _params.ThrowIfDisposed();
  266. Mat _params_mat = _params;
  267. return videoio_VideoCapture_open_12(nativeObj, filename, apiPreference, _params_mat.nativeObj);
  268. }
  269. //
  270. // C++: bool cv::VideoCapture::open(int index, int apiPreference = CAP_ANY)
  271. //
  272. /**
  273. * Opens a camera for video capturing
  274. *
  275. *
  276. *
  277. * Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)
  278. * return {code true} if the camera has been successfully opened.
  279. *
  280. * The method first calls VideoCapture::release to close the already opened file or camera.
  281. * param index automatically generated
  282. * param apiPreference automatically generated
  283. */
  284. public bool open(int index, int apiPreference)
  285. {
  286. ThrowIfDisposed();
  287. return videoio_VideoCapture_open_13(nativeObj, index, apiPreference);
  288. }
  289. /**
  290. * Opens a camera for video capturing
  291. *
  292. *
  293. *
  294. * Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)
  295. * return {code true} if the camera has been successfully opened.
  296. *
  297. * The method first calls VideoCapture::release to close the already opened file or camera.
  298. * param index automatically generated
  299. */
  300. public bool open(int index)
  301. {
  302. ThrowIfDisposed();
  303. return videoio_VideoCapture_open_14(nativeObj, index);
  304. }
  305. //
  306. // C++: bool cv::VideoCapture::open(int index, int apiPreference, vector_int _params)
  307. //
  308. /**
  309. * Opens a camera for video capturing with API Preference and parameters
  310. *
  311. *
  312. *
  313. * The {code params} parameter allows to specify extra parameters encoded as pairs {code (paramId_1, paramValue_1, paramId_2, paramValue_2, ...)}.
  314. * See cv::VideoCaptureProperties
  315. *
  316. * return {code true} if the camera has been successfully opened.
  317. *
  318. * The method first calls VideoCapture::release to close the already opened file or camera.
  319. * param index automatically generated
  320. * param apiPreference automatically generated
  321. * param _params automatically generated
  322. */
  323. public bool open(int index, int apiPreference, MatOfInt _params)
  324. {
  325. ThrowIfDisposed();
  326. if (_params != null) _params.ThrowIfDisposed();
  327. Mat _params_mat = _params;
  328. return videoio_VideoCapture_open_15(nativeObj, index, apiPreference, _params_mat.nativeObj);
  329. }
  330. //
  331. // C++: bool cv::VideoCapture::isOpened()
  332. //
  333. /**
  334. * Returns true if video capturing has been initialized already.
  335. *
  336. * If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns
  337. * true.
  338. * return automatically generated
  339. */
  340. public bool isOpened()
  341. {
  342. ThrowIfDisposed();
  343. return videoio_VideoCapture_isOpened_10(nativeObj);
  344. }
  345. //
  346. // C++: void cv::VideoCapture::release()
  347. //
  348. /**
  349. * Closes video file or capturing device.
  350. *
  351. * The method is automatically called by subsequent VideoCapture::open and by VideoCapture
  352. * destructor.
  353. *
  354. * The C function also deallocates memory and clears \*capture pointer.
  355. */
  356. public void release()
  357. {
  358. ThrowIfDisposed();
  359. videoio_VideoCapture_release_10(nativeObj);
  360. }
  361. //
  362. // C++: bool cv::VideoCapture::grab()
  363. //
  364. /**
  365. * Grabs the next frame from video file or capturing device.
  366. *
  367. * return {code true} (non-zero) in the case of success.
  368. *
  369. * The method/function grabs the next frame from video file or camera and returns true (non-zero) in
  370. * the case of success.
  371. *
  372. * The primary use of the function is in multi-camera environments, especially when the cameras do not
  373. * have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that
  374. * call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way
  375. * the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames
  376. * from different cameras will be closer in time.
  377. *
  378. * Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the
  379. * correct way of retrieving data from it is to call VideoCapture::grab() first and then call
  380. * VideoCapture::retrieve() one or more times with different values of the channel parameter.
  381. *
  382. * REF: tutorial_kinect_openni
  383. */
  384. public bool grab()
  385. {
  386. ThrowIfDisposed();
  387. return videoio_VideoCapture_grab_10(nativeObj);
  388. }
  389. //
  390. // C++: bool cv::VideoCapture::retrieve(Mat& image, int flag = 0)
  391. //
  392. /**
  393. * Decodes and returns the grabbed video frame.
  394. *
  395. * param flag it could be a frame index or a driver specific flag
  396. * return {code false} if no frames has been grabbed
  397. *
  398. * The method decodes and returns the just grabbed frame. If no frames has been grabbed
  399. * (camera has been disconnected, or there are no more frames in video file), the method returns false
  400. * and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).
  401. *
  402. * SEE: read()
  403. *
  404. * <b>Note:</b> In REF: videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
  405. * capturing structure. It is not allowed to modify or release the image! You can copy the frame using
  406. * cvCloneImage and then do whatever you want with the copy.
  407. * param image automatically generated
  408. */
  409. public bool retrieve(Mat image, int flag)
  410. {
  411. ThrowIfDisposed();
  412. if (image != null) image.ThrowIfDisposed();
  413. return videoio_VideoCapture_retrieve_10(nativeObj, image.nativeObj, flag);
  414. }
  415. /**
  416. * Decodes and returns the grabbed video frame.
  417. *
  418. * return {code false} if no frames has been grabbed
  419. *
  420. * The method decodes and returns the just grabbed frame. If no frames has been grabbed
  421. * (camera has been disconnected, or there are no more frames in video file), the method returns false
  422. * and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).
  423. *
  424. * SEE: read()
  425. *
  426. * <b>Note:</b> In REF: videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
  427. * capturing structure. It is not allowed to modify or release the image! You can copy the frame using
  428. * cvCloneImage and then do whatever you want with the copy.
  429. * param image automatically generated
  430. */
  431. public bool retrieve(Mat image)
  432. {
  433. ThrowIfDisposed();
  434. if (image != null) image.ThrowIfDisposed();
  435. return videoio_VideoCapture_retrieve_11(nativeObj, image.nativeObj);
  436. }
  437. //
  438. // C++: bool cv::VideoCapture::read(Mat& image)
  439. //
  440. /**
  441. * Grabs, decodes and returns the next video frame.
  442. *
  443. * return {code false} if no frames has been grabbed
  444. *
  445. * The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the
  446. * most convenient method for reading video files or capturing data from decode and returns the just
  447. * grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more
  448. * frames in video file), the method returns false and the function returns empty image (with %cv::Mat, test it with Mat::empty()).
  449. *
  450. * <b>Note:</b> In REF: videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
  451. * capturing structure. It is not allowed to modify or release the image! You can copy the frame using
  452. * cvCloneImage and then do whatever you want with the copy.
  453. * param image automatically generated
  454. */
  455. public bool read(Mat image)
  456. {
  457. ThrowIfDisposed();
  458. if (image != null) image.ThrowIfDisposed();
  459. return videoio_VideoCapture_read_10(nativeObj, image.nativeObj);
  460. }
  461. //
  462. // C++: bool cv::VideoCapture::set(int propId, double value)
  463. //
  464. /**
  465. * Sets a property in the VideoCapture.
  466. *
  467. * param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)
  468. * or one from REF: videoio_flags_others
  469. * param value Value of the property.
  470. * return {code true} if the property is supported by backend used by the VideoCapture instance.
  471. * <b>Note:</b> Even if it returns {code true} this doesn't ensure that the property
  472. * value has been accepted by the capture device. See note in VideoCapture::get()
  473. */
  474. public bool set(int propId, double value)
  475. {
  476. ThrowIfDisposed();
  477. return videoio_VideoCapture_set_10(nativeObj, propId, value);
  478. }
  479. //
  480. // C++: double cv::VideoCapture::get(int propId)
  481. //
  482. /**
  483. * Returns the specified VideoCapture property
  484. *
  485. * param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)
  486. * or one from REF: videoio_flags_others
  487. * return Value for the specified property. Value 0 is returned when querying a property that is
  488. * not supported by the backend used by the VideoCapture instance.
  489. *
  490. * <b>Note:</b> Reading / writing properties involves many layers. Some unexpected result might happens
  491. * along this chain.
  492. * <code>
  493. * VideoCapture -&gt; API Backend -&gt; Operating System -&gt; Device Driver -&gt; Device Hardware
  494. * </code>
  495. * The returned value might be different from what really used by the device or it could be encoded
  496. * using device dependent rules (eg. steps or percentage). Effective behaviour depends from device
  497. * driver and API Backend
  498. */
  499. public double get(int propId)
  500. {
  501. ThrowIfDisposed();
  502. return videoio_VideoCapture_get_10(nativeObj, propId);
  503. }
  504. //
  505. // C++: String cv::VideoCapture::getBackendName()
  506. //
  507. /**
  508. * Returns used backend API name
  509. *
  510. * <b>Note:</b> Stream should be opened.
  511. * return automatically generated
  512. */
  513. public string getBackendName()
  514. {
  515. ThrowIfDisposed();
  516. string retVal = Marshal.PtrToStringAnsi(DisposableObject.ThrowIfNullIntPtr(videoio_VideoCapture_getBackendName_10(nativeObj)));
  517. return retVal;
  518. }
  519. //
  520. // C++: void cv::VideoCapture::setExceptionMode(bool enable)
  521. //
  522. /**
  523. * Switches exceptions mode
  524. *
  525. * methods raise exceptions if not successful instead of returning an error code
  526. * param enable automatically generated
  527. */
  528. public void setExceptionMode(bool enable)
  529. {
  530. ThrowIfDisposed();
  531. videoio_VideoCapture_setExceptionMode_10(nativeObj, enable);
  532. }
  533. //
  534. // C++: bool cv::VideoCapture::getExceptionMode()
  535. //
  536. public bool getExceptionMode()
  537. {
  538. ThrowIfDisposed();
  539. return videoio_VideoCapture_getExceptionMode_10(nativeObj);
  540. }
  541. //
  542. // C++: static bool cv::VideoCapture::waitAny(vector_VideoCapture streams, vector_int& readyIndex, int64 timeoutNs = 0)
  543. //
  544. // Unknown type 'vector_VideoCapture' (I), skipping the function
  545. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  546. const string LIBNAME = "__Internal";
  547. #else
  548. const string LIBNAME = "opencvforunity";
  549. #endif
  550. // C++: cv::VideoCapture::VideoCapture()
  551. [DllImport(LIBNAME)]
  552. private static extern IntPtr videoio_VideoCapture_VideoCapture_10();
  553. // C++: cv::VideoCapture::VideoCapture(String filename, int apiPreference = CAP_ANY)
  554. [DllImport(LIBNAME)]
  555. private static extern IntPtr videoio_VideoCapture_VideoCapture_11(string filename, int apiPreference);
  556. [DllImport(LIBNAME)]
  557. private static extern IntPtr videoio_VideoCapture_VideoCapture_12(string filename);
  558. // C++: cv::VideoCapture::VideoCapture(String filename, int apiPreference, vector_int _params)
  559. [DllImport(LIBNAME)]
  560. private static extern IntPtr videoio_VideoCapture_VideoCapture_13(string filename, int apiPreference, IntPtr _params_mat_nativeObj);
  561. // C++: cv::VideoCapture::VideoCapture(int index, int apiPreference = CAP_ANY)
  562. [DllImport(LIBNAME)]
  563. private static extern IntPtr videoio_VideoCapture_VideoCapture_14(int index, int apiPreference);
  564. [DllImport(LIBNAME)]
  565. private static extern IntPtr videoio_VideoCapture_VideoCapture_15(int index);
  566. // C++: cv::VideoCapture::VideoCapture(int index, int apiPreference, vector_int _params)
  567. [DllImport(LIBNAME)]
  568. private static extern IntPtr videoio_VideoCapture_VideoCapture_16(int index, int apiPreference, IntPtr _params_mat_nativeObj);
  569. // C++: bool cv::VideoCapture::open(String filename, int apiPreference = CAP_ANY)
  570. [DllImport(LIBNAME)]
  571. [return: MarshalAs(UnmanagedType.U1)]
  572. private static extern bool videoio_VideoCapture_open_10(IntPtr nativeObj, string filename, int apiPreference);
  573. [DllImport(LIBNAME)]
  574. [return: MarshalAs(UnmanagedType.U1)]
  575. private static extern bool videoio_VideoCapture_open_11(IntPtr nativeObj, string filename);
  576. // C++: bool cv::VideoCapture::open(String filename, int apiPreference, vector_int _params)
  577. [DllImport(LIBNAME)]
  578. [return: MarshalAs(UnmanagedType.U1)]
  579. private static extern bool videoio_VideoCapture_open_12(IntPtr nativeObj, string filename, int apiPreference, IntPtr _params_mat_nativeObj);
  580. // C++: bool cv::VideoCapture::open(int index, int apiPreference = CAP_ANY)
  581. [DllImport(LIBNAME)]
  582. [return: MarshalAs(UnmanagedType.U1)]
  583. private static extern bool videoio_VideoCapture_open_13(IntPtr nativeObj, int index, int apiPreference);
  584. [DllImport(LIBNAME)]
  585. [return: MarshalAs(UnmanagedType.U1)]
  586. private static extern bool videoio_VideoCapture_open_14(IntPtr nativeObj, int index);
  587. // C++: bool cv::VideoCapture::open(int index, int apiPreference, vector_int _params)
  588. [DllImport(LIBNAME)]
  589. [return: MarshalAs(UnmanagedType.U1)]
  590. private static extern bool videoio_VideoCapture_open_15(IntPtr nativeObj, int index, int apiPreference, IntPtr _params_mat_nativeObj);
  591. // C++: bool cv::VideoCapture::isOpened()
  592. [DllImport(LIBNAME)]
  593. [return: MarshalAs(UnmanagedType.U1)]
  594. private static extern bool videoio_VideoCapture_isOpened_10(IntPtr nativeObj);
  595. // C++: void cv::VideoCapture::release()
  596. [DllImport(LIBNAME)]
  597. private static extern void videoio_VideoCapture_release_10(IntPtr nativeObj);
  598. // C++: bool cv::VideoCapture::grab()
  599. [DllImport(LIBNAME)]
  600. [return: MarshalAs(UnmanagedType.U1)]
  601. private static extern bool videoio_VideoCapture_grab_10(IntPtr nativeObj);
  602. // C++: bool cv::VideoCapture::retrieve(Mat& image, int flag = 0)
  603. [DllImport(LIBNAME)]
  604. [return: MarshalAs(UnmanagedType.U1)]
  605. private static extern bool videoio_VideoCapture_retrieve_10(IntPtr nativeObj, IntPtr image_nativeObj, int flag);
  606. [DllImport(LIBNAME)]
  607. [return: MarshalAs(UnmanagedType.U1)]
  608. private static extern bool videoio_VideoCapture_retrieve_11(IntPtr nativeObj, IntPtr image_nativeObj);
  609. // C++: bool cv::VideoCapture::read(Mat& image)
  610. [DllImport(LIBNAME)]
  611. [return: MarshalAs(UnmanagedType.U1)]
  612. private static extern bool videoio_VideoCapture_read_10(IntPtr nativeObj, IntPtr image_nativeObj);
  613. // C++: bool cv::VideoCapture::set(int propId, double value)
  614. [DllImport(LIBNAME)]
  615. [return: MarshalAs(UnmanagedType.U1)]
  616. private static extern bool videoio_VideoCapture_set_10(IntPtr nativeObj, int propId, double value);
  617. // C++: double cv::VideoCapture::get(int propId)
  618. [DllImport(LIBNAME)]
  619. private static extern double videoio_VideoCapture_get_10(IntPtr nativeObj, int propId);
  620. // C++: String cv::VideoCapture::getBackendName()
  621. [DllImport(LIBNAME)]
  622. private static extern IntPtr videoio_VideoCapture_getBackendName_10(IntPtr nativeObj);
  623. // C++: void cv::VideoCapture::setExceptionMode(bool enable)
  624. [DllImport(LIBNAME)]
  625. private static extern void videoio_VideoCapture_setExceptionMode_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool enable);
  626. // C++: bool cv::VideoCapture::getExceptionMode()
  627. [DllImport(LIBNAME)]
  628. [return: MarshalAs(UnmanagedType.U1)]
  629. private static extern bool videoio_VideoCapture_getExceptionMode_10(IntPtr nativeObj);
  630. // native support for java finalize()
  631. [DllImport(LIBNAME)]
  632. private static extern void videoio_VideoCapture_delete(IntPtr nativeObj);
  633. }
  634. }