Imgcodecs.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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/imgcodecs.hpp"
  8. #else
  9. #define CV_EXPORTS
  10. #endif
  11. #import <Foundation/Foundation.h>
  12. @class ByteVector;
  13. @class IntVector;
  14. @class Mat;
  15. // C++: enum ImreadModes (cv.ImreadModes)
  16. typedef NS_ENUM(int, ImreadModes) {
  17. IMREAD_UNCHANGED = -1,
  18. IMREAD_GRAYSCALE = 0,
  19. IMREAD_COLOR = 1,
  20. IMREAD_ANYDEPTH = 2,
  21. IMREAD_ANYCOLOR = 4,
  22. IMREAD_LOAD_GDAL = 8,
  23. IMREAD_REDUCED_GRAYSCALE_2 = 16,
  24. IMREAD_REDUCED_COLOR_2 = 17,
  25. IMREAD_REDUCED_GRAYSCALE_4 = 32,
  26. IMREAD_REDUCED_COLOR_4 = 33,
  27. IMREAD_REDUCED_GRAYSCALE_8 = 64,
  28. IMREAD_REDUCED_COLOR_8 = 65,
  29. IMREAD_IGNORE_ORIENTATION = 128
  30. };
  31. // C++: enum ImwriteEXRCompressionFlags (cv.ImwriteEXRCompressionFlags)
  32. typedef NS_ENUM(int, ImwriteEXRCompressionFlags) {
  33. IMWRITE_EXR_COMPRESSION_NO = 0,
  34. IMWRITE_EXR_COMPRESSION_RLE = 1,
  35. IMWRITE_EXR_COMPRESSION_ZIPS = 2,
  36. IMWRITE_EXR_COMPRESSION_ZIP = 3,
  37. IMWRITE_EXR_COMPRESSION_PIZ = 4,
  38. IMWRITE_EXR_COMPRESSION_PXR24 = 5,
  39. IMWRITE_EXR_COMPRESSION_B44 = 6,
  40. IMWRITE_EXR_COMPRESSION_B44A = 7,
  41. IMWRITE_EXR_COMPRESSION_DWAA = 8,
  42. IMWRITE_EXR_COMPRESSION_DWAB = 9
  43. };
  44. // C++: enum ImwriteEXRTypeFlags (cv.ImwriteEXRTypeFlags)
  45. typedef NS_ENUM(int, ImwriteEXRTypeFlags) {
  46. IMWRITE_EXR_TYPE_HALF = 1,
  47. IMWRITE_EXR_TYPE_FLOAT = 2
  48. };
  49. // C++: enum ImwriteFlags (cv.ImwriteFlags)
  50. typedef NS_ENUM(int, ImwriteFlags) {
  51. IMWRITE_JPEG_QUALITY = 1,
  52. IMWRITE_JPEG_PROGRESSIVE = 2,
  53. IMWRITE_JPEG_OPTIMIZE = 3,
  54. IMWRITE_JPEG_RST_INTERVAL = 4,
  55. IMWRITE_JPEG_LUMA_QUALITY = 5,
  56. IMWRITE_JPEG_CHROMA_QUALITY = 6,
  57. IMWRITE_JPEG_SAMPLING_FACTOR = 7,
  58. IMWRITE_PNG_COMPRESSION = 16,
  59. IMWRITE_PNG_STRATEGY = 17,
  60. IMWRITE_PNG_BILEVEL = 18,
  61. IMWRITE_PXM_BINARY = 32,
  62. IMWRITE_EXR_TYPE = (3 << 4) + 0,
  63. IMWRITE_EXR_COMPRESSION = (3 << 4) + 1,
  64. IMWRITE_EXR_DWA_COMPRESSION_LEVEL = (3 << 4) + 2,
  65. IMWRITE_WEBP_QUALITY = 64,
  66. IMWRITE_HDR_COMPRESSION = (5 << 4) + 0,
  67. IMWRITE_PAM_TUPLETYPE = 128,
  68. IMWRITE_TIFF_RESUNIT = 256,
  69. IMWRITE_TIFF_XDPI = 257,
  70. IMWRITE_TIFF_YDPI = 258,
  71. IMWRITE_TIFF_COMPRESSION = 259,
  72. IMWRITE_JPEG2000_COMPRESSION_X1000 = 272,
  73. IMWRITE_AVIF_QUALITY = 512,
  74. IMWRITE_AVIF_DEPTH = 513,
  75. IMWRITE_AVIF_SPEED = 514
  76. };
  77. // C++: enum ImwriteHDRCompressionFlags (cv.ImwriteHDRCompressionFlags)
  78. typedef NS_ENUM(int, ImwriteHDRCompressionFlags) {
  79. IMWRITE_HDR_COMPRESSION_NONE = 0,
  80. IMWRITE_HDR_COMPRESSION_RLE = 1
  81. };
  82. // C++: enum ImwriteJPEGSamplingFactorParams (cv.ImwriteJPEGSamplingFactorParams)
  83. typedef NS_ENUM(int, ImwriteJPEGSamplingFactorParams) {
  84. IMWRITE_JPEG_SAMPLING_FACTOR_411 = 0x411111,
  85. IMWRITE_JPEG_SAMPLING_FACTOR_420 = 0x221111,
  86. IMWRITE_JPEG_SAMPLING_FACTOR_422 = 0x211111,
  87. IMWRITE_JPEG_SAMPLING_FACTOR_440 = 0x121111,
  88. IMWRITE_JPEG_SAMPLING_FACTOR_444 = 0x111111
  89. };
  90. // C++: enum ImwritePAMFlags (cv.ImwritePAMFlags)
  91. typedef NS_ENUM(int, ImwritePAMFlags) {
  92. IMWRITE_PAM_FORMAT_NULL = 0,
  93. IMWRITE_PAM_FORMAT_BLACKANDWHITE = 1,
  94. IMWRITE_PAM_FORMAT_GRAYSCALE = 2,
  95. IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA = 3,
  96. IMWRITE_PAM_FORMAT_RGB = 4,
  97. IMWRITE_PAM_FORMAT_RGB_ALPHA = 5
  98. };
  99. // C++: enum ImwritePNGFlags (cv.ImwritePNGFlags)
  100. typedef NS_ENUM(int, ImwritePNGFlags) {
  101. IMWRITE_PNG_STRATEGY_DEFAULT = 0,
  102. IMWRITE_PNG_STRATEGY_FILTERED = 1,
  103. IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY = 2,
  104. IMWRITE_PNG_STRATEGY_RLE = 3,
  105. IMWRITE_PNG_STRATEGY_FIXED = 4
  106. };
  107. NS_ASSUME_NONNULL_BEGIN
  108. // C++: class Imgcodecs
  109. /**
  110. * The Imgcodecs module
  111. *
  112. * Member of `Imgcodecs`
  113. * Member enums: `ImreadModes`, `ImwriteFlags`, `ImwriteJPEGSamplingFactorParams`, `ImwriteEXRTypeFlags`, `ImwriteEXRCompressionFlags`, `ImwritePNGFlags`, `ImwritePAMFlags`, `ImwriteHDRCompressionFlags`
  114. */
  115. CV_EXPORTS @interface Imgcodecs : NSObject
  116. #pragma mark - Methods
  117. //
  118. // Mat cv::imread(String filename, int flags = IMREAD_COLOR)
  119. //
  120. /**
  121. * Loads an image from a file.
  122. *
  123. * imread
  124. *
  125. * The function imread loads an image from the specified file and returns it. If the image cannot be
  126. * read (because of missing file, improper permissions, unsupported or invalid format), the function
  127. * returns an empty matrix ( Mat::data==NULL ).
  128. *
  129. * Currently, the following file formats are supported:
  130. *
  131. * - Windows bitmaps - \*.bmp, \*.dib (always supported)
  132. * - JPEG files - \*.jpeg, \*.jpg, \*.jpe (see the *Note* section)
  133. * - JPEG 2000 files - \*.jp2 (see the *Note* section)
  134. * - Portable Network Graphics - \*.png (see the *Note* section)
  135. * - WebP - \*.webp (see the *Note* section)
  136. * - AVIF - \*.avif (see the *Note* section)
  137. * - Portable image format - \*.pbm, \*.pgm, \*.ppm \*.pxm, \*.pnm (always supported)
  138. * - PFM files - \*.pfm (see the *Note* section)
  139. * - Sun rasters - \*.sr, \*.ras (always supported)
  140. * - TIFF files - \*.tiff, \*.tif (see the *Note* section)
  141. * - OpenEXR Image files - \*.exr (see the *Note* section)
  142. * - Radiance HDR - \*.hdr, \*.pic (always supported)
  143. * - Raster and Vector geospatial data supported by GDAL (see the *Note* section)
  144. *
  145. * NOTE:
  146. * - The function determines the type of an image by the content, not by the file extension.
  147. * - In the case of color images, the decoded images will have the channels stored in **B G R** order.
  148. * - When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available.
  149. * Results may differ to the output of cvtColor()
  150. * - On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg,
  151. * libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs,
  152. * and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware
  153. * that currently these native image loaders give images with different pixel values because of
  154. * the color management embedded into MacOSX.
  155. * - On Linux\*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for
  156. * codecs supplied with an OS image. Install the relevant packages (do not forget the development
  157. * files, for example, "libjpeg-dev", in Debian\* and Ubuntu\*) to get the codec support or turn
  158. * on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake.
  159. * - In the case you set *WITH_GDAL* flag to true in CMake and REF: IMREAD_LOAD_GDAL to load the image,
  160. * then the [GDAL](http://www.gdal.org) driver will be used in order to decode the image, supporting
  161. * the following formats: [Raster](http://www.gdal.org/formats_list.html),
  162. * [Vector](http://www.gdal.org/ogr_formats.html).
  163. * - If EXIF information is embedded in the image file, the EXIF orientation will be taken into account
  164. * and thus the image will be rotated accordingly except if the flags REF: IMREAD_IGNORE_ORIENTATION
  165. * or REF: IMREAD_UNCHANGED are passed.
  166. * - Use the IMREAD_UNCHANGED flag to keep the floating point values from PFM image.
  167. * - By default number of pixels must be less than 2^30. Limit can be set using system
  168. * variable OPENCV_IO_MAX_IMAGE_PIXELS
  169. *
  170. * @param filename Name of file to be loaded.
  171. * @param flags Flag that can take values of cv::ImreadModes
  172. */
  173. + (Mat*)imread:(NSString*)filename flags:(int)flags NS_SWIFT_NAME(imread(filename:flags:));
  174. /**
  175. * Loads an image from a file.
  176. *
  177. * imread
  178. *
  179. * The function imread loads an image from the specified file and returns it. If the image cannot be
  180. * read (because of missing file, improper permissions, unsupported or invalid format), the function
  181. * returns an empty matrix ( Mat::data==NULL ).
  182. *
  183. * Currently, the following file formats are supported:
  184. *
  185. * - Windows bitmaps - \*.bmp, \*.dib (always supported)
  186. * - JPEG files - \*.jpeg, \*.jpg, \*.jpe (see the *Note* section)
  187. * - JPEG 2000 files - \*.jp2 (see the *Note* section)
  188. * - Portable Network Graphics - \*.png (see the *Note* section)
  189. * - WebP - \*.webp (see the *Note* section)
  190. * - AVIF - \*.avif (see the *Note* section)
  191. * - Portable image format - \*.pbm, \*.pgm, \*.ppm \*.pxm, \*.pnm (always supported)
  192. * - PFM files - \*.pfm (see the *Note* section)
  193. * - Sun rasters - \*.sr, \*.ras (always supported)
  194. * - TIFF files - \*.tiff, \*.tif (see the *Note* section)
  195. * - OpenEXR Image files - \*.exr (see the *Note* section)
  196. * - Radiance HDR - \*.hdr, \*.pic (always supported)
  197. * - Raster and Vector geospatial data supported by GDAL (see the *Note* section)
  198. *
  199. * NOTE:
  200. * - The function determines the type of an image by the content, not by the file extension.
  201. * - In the case of color images, the decoded images will have the channels stored in **B G R** order.
  202. * - When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available.
  203. * Results may differ to the output of cvtColor()
  204. * - On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg,
  205. * libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs,
  206. * and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware
  207. * that currently these native image loaders give images with different pixel values because of
  208. * the color management embedded into MacOSX.
  209. * - On Linux\*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for
  210. * codecs supplied with an OS image. Install the relevant packages (do not forget the development
  211. * files, for example, "libjpeg-dev", in Debian\* and Ubuntu\*) to get the codec support or turn
  212. * on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake.
  213. * - In the case you set *WITH_GDAL* flag to true in CMake and REF: IMREAD_LOAD_GDAL to load the image,
  214. * then the [GDAL](http://www.gdal.org) driver will be used in order to decode the image, supporting
  215. * the following formats: [Raster](http://www.gdal.org/formats_list.html),
  216. * [Vector](http://www.gdal.org/ogr_formats.html).
  217. * - If EXIF information is embedded in the image file, the EXIF orientation will be taken into account
  218. * and thus the image will be rotated accordingly except if the flags REF: IMREAD_IGNORE_ORIENTATION
  219. * or REF: IMREAD_UNCHANGED are passed.
  220. * - Use the IMREAD_UNCHANGED flag to keep the floating point values from PFM image.
  221. * - By default number of pixels must be less than 2^30. Limit can be set using system
  222. * variable OPENCV_IO_MAX_IMAGE_PIXELS
  223. *
  224. * @param filename Name of file to be loaded.
  225. */
  226. + (Mat*)imread:(NSString*)filename NS_SWIFT_NAME(imread(filename:));
  227. //
  228. // bool cv::imreadmulti(String filename, vector_Mat& mats, int flags = IMREAD_ANYCOLOR)
  229. //
  230. /**
  231. * Loads a multi-page image from a file.
  232. *
  233. * The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
  234. * @param filename Name of file to be loaded.
  235. * @param mats A vector of Mat objects holding each page.
  236. * @param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.
  237. * @see `cv::imread`
  238. */
  239. + (BOOL)imreadmulti:(NSString*)filename mats:(NSMutableArray<Mat*>*)mats flags:(int)flags NS_SWIFT_NAME(imreadmulti(filename:mats:flags:));
  240. /**
  241. * Loads a multi-page image from a file.
  242. *
  243. * The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
  244. * @param filename Name of file to be loaded.
  245. * @param mats A vector of Mat objects holding each page.
  246. * @see `cv::imread`
  247. */
  248. + (BOOL)imreadmulti:(NSString*)filename mats:(NSMutableArray<Mat*>*)mats NS_SWIFT_NAME(imreadmulti(filename:mats:));
  249. //
  250. // bool cv::imreadmulti(String filename, vector_Mat& mats, int start, int count, int flags = IMREAD_ANYCOLOR)
  251. //
  252. /**
  253. * Loads a of images of a multi-page image from a file.
  254. *
  255. * The function imreadmulti loads a specified range from a multi-page image from the specified file into a vector of Mat objects.
  256. * @param filename Name of file to be loaded.
  257. * @param mats A vector of Mat objects holding each page.
  258. * @param start Start index of the image to load
  259. * @param count Count number of images to load
  260. * @param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.
  261. * @see `cv::imread`
  262. */
  263. + (BOOL)imreadmulti:(NSString*)filename mats:(NSMutableArray<Mat*>*)mats start:(int)start count:(int)count flags:(int)flags NS_SWIFT_NAME(imreadmulti(filename:mats:start:count:flags:));
  264. /**
  265. * Loads a of images of a multi-page image from a file.
  266. *
  267. * The function imreadmulti loads a specified range from a multi-page image from the specified file into a vector of Mat objects.
  268. * @param filename Name of file to be loaded.
  269. * @param mats A vector of Mat objects holding each page.
  270. * @param start Start index of the image to load
  271. * @param count Count number of images to load
  272. * @see `cv::imread`
  273. */
  274. + (BOOL)imreadmulti:(NSString*)filename mats:(NSMutableArray<Mat*>*)mats start:(int)start count:(int)count NS_SWIFT_NAME(imreadmulti(filename:mats:start:count:));
  275. //
  276. // size_t cv::imcount(String filename, int flags = IMREAD_ANYCOLOR)
  277. //
  278. /**
  279. * Returns the number of images inside the give file
  280. *
  281. * The function imcount will return the number of pages in a multi-page image, or 1 for single-page images
  282. * @param filename Name of file to be loaded.
  283. * @param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.
  284. */
  285. + (size_t)imcount:(NSString*)filename flags:(int)flags NS_SWIFT_NAME(imcount(filename:flags:));
  286. /**
  287. * Returns the number of images inside the give file
  288. *
  289. * The function imcount will return the number of pages in a multi-page image, or 1 for single-page images
  290. * @param filename Name of file to be loaded.
  291. */
  292. + (size_t)imcount:(NSString*)filename NS_SWIFT_NAME(imcount(filename:));
  293. //
  294. // bool cv::imwrite(String filename, Mat img, vector_int params = std::vector<int>())
  295. //
  296. /**
  297. * Saves an image to a specified file.
  298. *
  299. * The function imwrite saves the image to the specified file. The image format is chosen based on the
  300. * filename extension (see cv::imread for the list of extensions). In general, only 8-bit unsigned (CV_8U)
  301. * single-channel or 3-channel (with 'BGR' channel order) images
  302. * can be saved using this function, with these exceptions:
  303. *
  304. * - With OpenEXR encoder, only 32-bit float (CV_32F) images can be saved.
  305. * - 8-bit unsigned (CV_8U) images are not supported.
  306. * - With Radiance HDR encoder, non 64-bit float (CV_64F) images can be saved.
  307. * - All images will be converted to 32-bit float (CV_32F).
  308. * - With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
  309. * - With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
  310. * - With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
  311. * - PNG images with an alpha channel can be saved using this function. To do this, create
  312. * 8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels
  313. * should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535 (see the code sample below).
  314. * - With PGM/PPM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
  315. * - With TIFF encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U),
  316. * 32-bit float (CV_32F) and 64-bit float (CV_64F) images can be saved.
  317. * - Multiple images (vector of Mat) can be saved in TIFF format (see the code sample below).
  318. * - 32-bit float 3-channel (CV_32FC3) TIFF images will be saved
  319. * using the LogLuv high dynamic range encoding (4 bytes per pixel)
  320. *
  321. * If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way.
  322. *
  323. * If the format, depth or channel order is different, use
  324. * Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O
  325. * functions to save the image to XML or YAML format.
  326. *
  327. * The sample below shows how to create a BGRA image, how to set custom compression parameters and save it to a PNG file.
  328. * It also demonstrates how to save multiple images in a TIFF file:
  329. * INCLUDE: snippets/imgcodecs_imwrite.cpp
  330. * @param filename Name of the file.
  331. * @param img (Mat or vector of Mat) Image or Images to be saved.
  332. * @param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags
  333. */
  334. + (BOOL)imwrite:(NSString*)filename img:(Mat*)img params:(IntVector*)params NS_SWIFT_NAME(imwrite(filename:img:params:));
  335. /**
  336. * Saves an image to a specified file.
  337. *
  338. * The function imwrite saves the image to the specified file. The image format is chosen based on the
  339. * filename extension (see cv::imread for the list of extensions). In general, only 8-bit unsigned (CV_8U)
  340. * single-channel or 3-channel (with 'BGR' channel order) images
  341. * can be saved using this function, with these exceptions:
  342. *
  343. * - With OpenEXR encoder, only 32-bit float (CV_32F) images can be saved.
  344. * - 8-bit unsigned (CV_8U) images are not supported.
  345. * - With Radiance HDR encoder, non 64-bit float (CV_64F) images can be saved.
  346. * - All images will be converted to 32-bit float (CV_32F).
  347. * - With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
  348. * - With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
  349. * - With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
  350. * - PNG images with an alpha channel can be saved using this function. To do this, create
  351. * 8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels
  352. * should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535 (see the code sample below).
  353. * - With PGM/PPM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
  354. * - With TIFF encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U),
  355. * 32-bit float (CV_32F) and 64-bit float (CV_64F) images can be saved.
  356. * - Multiple images (vector of Mat) can be saved in TIFF format (see the code sample below).
  357. * - 32-bit float 3-channel (CV_32FC3) TIFF images will be saved
  358. * using the LogLuv high dynamic range encoding (4 bytes per pixel)
  359. *
  360. * If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way.
  361. *
  362. * If the format, depth or channel order is different, use
  363. * Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O
  364. * functions to save the image to XML or YAML format.
  365. *
  366. * The sample below shows how to create a BGRA image, how to set custom compression parameters and save it to a PNG file.
  367. * It also demonstrates how to save multiple images in a TIFF file:
  368. * INCLUDE: snippets/imgcodecs_imwrite.cpp
  369. * @param filename Name of the file.
  370. * @param img (Mat or vector of Mat) Image or Images to be saved.
  371. */
  372. + (BOOL)imwrite:(NSString*)filename img:(Mat*)img NS_SWIFT_NAME(imwrite(filename:img:));
  373. //
  374. // bool cv::imwritemulti(String filename, vector_Mat img, vector_int params = std::vector<int>())
  375. //
  376. + (BOOL)imwritemulti:(NSString*)filename img:(NSArray<Mat*>*)img params:(IntVector*)params NS_SWIFT_NAME(imwritemulti(filename:img:params:));
  377. + (BOOL)imwritemulti:(NSString*)filename img:(NSArray<Mat*>*)img NS_SWIFT_NAME(imwritemulti(filename:img:));
  378. //
  379. // Mat cv::imdecode(Mat buf, int flags)
  380. //
  381. /**
  382. * Reads an image from a buffer in memory.
  383. *
  384. * The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or
  385. * contains invalid data, the function returns an empty matrix ( Mat::data==NULL ).
  386. *
  387. * See cv::imread for the list of supported formats and flags description.
  388. *
  389. * NOTE: In the case of color images, the decoded images will have the channels stored in **B G R** order.
  390. * @param buf Input array or vector of bytes.
  391. * @param flags The same flags as in cv::imread, see cv::ImreadModes.
  392. */
  393. + (Mat*)imdecode:(Mat*)buf flags:(int)flags NS_SWIFT_NAME(imdecode(buf:flags:));
  394. //
  395. // bool cv::imdecodemulti(Mat buf, int flags, vector_Mat& mats)
  396. //
  397. /**
  398. * Reads a multi-page image from a buffer in memory.
  399. *
  400. * The function imdecodemulti reads a multi-page image from the specified buffer in the memory. If the buffer is too short or
  401. * contains invalid data, the function returns false.
  402. *
  403. * See cv::imreadmulti for the list of supported formats and flags description.
  404. *
  405. * NOTE: In the case of color images, the decoded images will have the channels stored in **B G R** order.
  406. * @param buf Input array or vector of bytes.
  407. * @param flags The same flags as in cv::imread, see cv::ImreadModes.
  408. * @param mats A vector of Mat objects holding each page, if more than one.
  409. */
  410. + (BOOL)imdecodemulti:(Mat*)buf flags:(int)flags mats:(NSMutableArray<Mat*>*)mats NS_SWIFT_NAME(imdecodemulti(buf:flags:mats:));
  411. //
  412. // bool cv::imencode(String ext, Mat img, vector_uchar& buf, vector_int params = std::vector<int>())
  413. //
  414. /**
  415. * Encodes an image into a memory buffer.
  416. *
  417. * The function imencode compresses the image and stores it in the memory buffer that is resized to fit the
  418. * result. See cv::imwrite for the list of supported formats and flags description.
  419. *
  420. * @param ext File extension that defines the output format. Must include a leading period.
  421. * @param img Image to be written.
  422. * @param buf Output buffer resized to fit the compressed image.
  423. * @param params Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.
  424. */
  425. + (BOOL)imencode:(NSString*)ext img:(Mat*)img buf:(ByteVector*)buf params:(IntVector*)params NS_SWIFT_NAME(imencode(ext:img:buf:params:));
  426. /**
  427. * Encodes an image into a memory buffer.
  428. *
  429. * The function imencode compresses the image and stores it in the memory buffer that is resized to fit the
  430. * result. See cv::imwrite for the list of supported formats and flags description.
  431. *
  432. * @param ext File extension that defines the output format. Must include a leading period.
  433. * @param img Image to be written.
  434. * @param buf Output buffer resized to fit the compressed image.
  435. */
  436. + (BOOL)imencode:(NSString*)ext img:(Mat*)img buf:(ByteVector*)buf NS_SWIFT_NAME(imencode(ext:img:buf:));
  437. //
  438. // bool cv::haveImageReader(String filename)
  439. //
  440. /**
  441. * Returns true if the specified image can be decoded by OpenCV
  442. *
  443. * @param filename File name of the image
  444. */
  445. + (BOOL)haveImageReader:(NSString*)filename NS_SWIFT_NAME(haveImageReader(filename:));
  446. //
  447. // bool cv::haveImageWriter(String filename)
  448. //
  449. /**
  450. * Returns true if an image with the specified filename can be encoded by OpenCV
  451. *
  452. * @param filename File name of the image
  453. */
  454. + (BOOL)haveImageWriter:(NSString*)filename NS_SWIFT_NAME(haveImageWriter(filename:));
  455. @end
  456. NS_ASSUME_NONNULL_END