VideoWriter.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. @class Size2i;
  15. NS_ASSUME_NONNULL_BEGIN
  16. // C++: class VideoWriter
  17. /**
  18. * Video writer class.
  19. *
  20. * The class provides C++ API for writing video files or image sequences.
  21. *
  22. * Member of `Videoio`
  23. */
  24. CV_EXPORTS @interface VideoWriter : NSObject
  25. #ifdef __cplusplus
  26. @property(readonly)cv::Ptr<cv::VideoWriter> nativePtr;
  27. #endif
  28. #ifdef __cplusplus
  29. - (instancetype)initWithNativePtr:(cv::Ptr<cv::VideoWriter>)nativePtr;
  30. + (instancetype)fromNative:(cv::Ptr<cv::VideoWriter>)nativePtr;
  31. #endif
  32. #pragma mark - Methods
  33. //
  34. // cv::VideoWriter::VideoWriter()
  35. //
  36. /**
  37. * Default constructors
  38. *
  39. * The constructors/functions initialize video writers.
  40. * - On Linux FFMPEG is used to write videos;
  41. * - On Windows FFMPEG or MSWF or DSHOW is used;
  42. * - On MacOSX AVFoundation is used.
  43. */
  44. - (instancetype)init;
  45. //
  46. // cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, bool isColor = true)
  47. //
  48. /**
  49. *
  50. * @param filename Name of the output video file.
  51. * @param fourcc 4-character code of codec used to compress the frames. For example,
  52. * VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G')
  53. * is a motion-jpeg codec etc. List of codes can be obtained at
  54. * [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page
  55. * or with this [archived page](https://web.archive.org/web/20220316062600/http://www.fourcc.org/codecs.php)
  56. * of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses
  57. * other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs),
  58. * so you may receive a warning message from OpenCV about fourcc code conversion.
  59. * @param fps Framerate of the created video stream.
  60. * @param frameSize Size of the video frames.
  61. * @param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it
  62. * will work with grayscale frames.
  63. *
  64. * @b Tips:
  65. * - With some backends `fourcc=-1` pops up the codec selection dialog from the system.
  66. * - To save image sequence use a proper filename (eg. `img_%02d.jpg`) and `fourcc=0`
  67. * OR `fps=0`. Use uncompressed image format (eg. `img_%02d.BMP`) to save raw frames.
  68. * - Most codecs are lossy. If you want lossless video file you need to use a lossless codecs
  69. * (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...)
  70. * - If FFMPEG is enabled, using `codec=0; fps=0;` you can create an uncompressed (raw) video file.
  71. */
  72. - (instancetype)initWithFilename:(NSString*)filename fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize isColor:(BOOL)isColor;
  73. /**
  74. *
  75. * @param filename Name of the output video file.
  76. * @param fourcc 4-character code of codec used to compress the frames. For example,
  77. * VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G')
  78. * is a motion-jpeg codec etc. List of codes can be obtained at
  79. * [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page
  80. * or with this [archived page](https://web.archive.org/web/20220316062600/http://www.fourcc.org/codecs.php)
  81. * of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses
  82. * other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs),
  83. * so you may receive a warning message from OpenCV about fourcc code conversion.
  84. * @param fps Framerate of the created video stream.
  85. * @param frameSize Size of the video frames.
  86. * will work with grayscale frames.
  87. *
  88. * @b Tips:
  89. * - With some backends `fourcc=-1` pops up the codec selection dialog from the system.
  90. * - To save image sequence use a proper filename (eg. `img_%02d.jpg`) and `fourcc=0`
  91. * OR `fps=0`. Use uncompressed image format (eg. `img_%02d.BMP`) to save raw frames.
  92. * - Most codecs are lossy. If you want lossless video file you need to use a lossless codecs
  93. * (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...)
  94. * - If FFMPEG is enabled, using `codec=0; fps=0;` you can create an uncompressed (raw) video file.
  95. */
  96. - (instancetype)initWithFilename:(NSString*)filename fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize;
  97. //
  98. // cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true)
  99. //
  100. /**
  101. *
  102. * The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation
  103. * if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER.
  104. */
  105. - (instancetype)initWithFilename:(NSString*)filename apiPreference:(int)apiPreference fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize isColor:(BOOL)isColor;
  106. /**
  107. *
  108. * The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation
  109. * if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER.
  110. */
  111. - (instancetype)initWithFilename:(NSString*)filename apiPreference:(int)apiPreference fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize;
  112. //
  113. // cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, vector_int params)
  114. //
  115. /**
  116. *
  117. * The `params` parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .)
  118. * see cv::VideoWriterProperties
  119. */
  120. - (instancetype)initWithFilename:(NSString*)filename fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize params:(IntVector*)params;
  121. //
  122. // cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params)
  123. //
  124. - (instancetype)initWithFilename:(NSString*)filename apiPreference:(int)apiPreference fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize params:(IntVector*)params;
  125. //
  126. // bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, bool isColor = true)
  127. //
  128. /**
  129. * Initializes or reinitializes video writer.
  130. *
  131. * The method opens video writer. Parameters are the same as in the constructor
  132. * VideoWriter::VideoWriter.
  133. * @return `true` if video writer has been successfully initialized
  134. *
  135. * The method first calls VideoWriter::release to close the already opened file.
  136. */
  137. - (BOOL)open:(NSString*)filename fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize isColor:(BOOL)isColor NS_SWIFT_NAME(open(filename:fourcc:fps:frameSize:isColor:));
  138. /**
  139. * Initializes or reinitializes video writer.
  140. *
  141. * The method opens video writer. Parameters are the same as in the constructor
  142. * VideoWriter::VideoWriter.
  143. * @return `true` if video writer has been successfully initialized
  144. *
  145. * The method first calls VideoWriter::release to close the already opened file.
  146. */
  147. - (BOOL)open:(NSString*)filename fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize NS_SWIFT_NAME(open(filename:fourcc:fps:frameSize:));
  148. //
  149. // bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true)
  150. //
  151. - (BOOL)open:(NSString*)filename apiPreference:(int)apiPreference fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize isColor:(BOOL)isColor NS_SWIFT_NAME(open(filename:apiPreference:fourcc:fps:frameSize:isColor:));
  152. - (BOOL)open:(NSString*)filename apiPreference:(int)apiPreference fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize NS_SWIFT_NAME(open(filename:apiPreference:fourcc:fps:frameSize:));
  153. //
  154. // bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, vector_int params)
  155. //
  156. - (BOOL)open:(NSString*)filename fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize params:(IntVector*)params NS_SWIFT_NAME(open(filename:fourcc:fps:frameSize:params:));
  157. //
  158. // bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params)
  159. //
  160. - (BOOL)open:(NSString*)filename apiPreference:(int)apiPreference fourcc:(int)fourcc fps:(double)fps frameSize:(Size2i*)frameSize params:(IntVector*)params NS_SWIFT_NAME(open(filename:apiPreference:fourcc:fps:frameSize:params:));
  161. //
  162. // bool cv::VideoWriter::isOpened()
  163. //
  164. /**
  165. * Returns true if video writer has been successfully initialized.
  166. */
  167. - (BOOL)isOpened NS_SWIFT_NAME(isOpened());
  168. //
  169. // void cv::VideoWriter::write(Mat image)
  170. //
  171. /**
  172. * Writes the next video frame
  173. *
  174. * @param image The written frame. In general, color images are expected in BGR format.
  175. *
  176. * The function/method writes the specified image to video file. It must have the same size as has
  177. * been specified when opening the video writer.
  178. */
  179. - (void)write:(Mat*)image NS_SWIFT_NAME(write(image:));
  180. //
  181. // bool cv::VideoWriter::set(int propId, double value)
  182. //
  183. /**
  184. * Sets a property in the VideoWriter.
  185. *
  186. * @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY)
  187. * or one of REF: videoio_flags_others
  188. *
  189. * @param value Value of the property.
  190. * @return `true` if the property is supported by the backend used by the VideoWriter instance.
  191. */
  192. - (BOOL)set:(int)propId value:(double)value NS_SWIFT_NAME(set(propId:value:));
  193. //
  194. // double cv::VideoWriter::get(int propId)
  195. //
  196. /**
  197. * Returns the specified VideoWriter property
  198. *
  199. * @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY)
  200. * or one of REF: videoio_flags_others
  201. *
  202. * @return Value for the specified property. Value 0 is returned when querying a property that is
  203. * not supported by the backend used by the VideoWriter instance.
  204. */
  205. - (double)get:(int)propId NS_SWIFT_NAME(get(propId:));
  206. //
  207. // static int cv::VideoWriter::fourcc(char c1, char c2, char c3, char c4)
  208. //
  209. /**
  210. * Concatenates 4 chars to a fourcc code
  211. *
  212. * @return a fourcc code
  213. *
  214. * This static method constructs the fourcc code of the codec to be used in the constructor
  215. * VideoWriter::VideoWriter or VideoWriter::open.
  216. */
  217. + (int)fourcc:(char)c1 c2:(char)c2 c3:(char)c3 c4:(char)c4 NS_SWIFT_NAME(fourcc(c1:c2:c3:c4:));
  218. //
  219. // String cv::VideoWriter::getBackendName()
  220. //
  221. /**
  222. * Returns used backend API name
  223. *
  224. * NOTE: Stream should be opened.
  225. */
  226. - (NSString*)getBackendName NS_SWIFT_NAME(getBackendName());
  227. @end
  228. NS_ASSUME_NONNULL_END