VideoWriter.h 10 KB

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