001// 002// This file is auto-generated. Please don't modify it! 003// 004package org.opencv.videoio; 005 006import java.util.ArrayList; 007import java.util.List; 008import org.opencv.core.Mat; 009import org.opencv.core.MatOfInt; 010import org.opencv.core.Size; 011import org.opencv.utils.Converters; 012 013// C++: class VideoWriter 014/** 015 * Video writer class. 016 * 017 * The class provides C++ API for writing video files or image sequences. 018 */ 019public class VideoWriter { 020 021 protected final long nativeObj; 022 protected VideoWriter(long addr) { nativeObj = addr; } 023 024 public long getNativeObjAddr() { return nativeObj; } 025 026 // internal usage only 027 public static VideoWriter __fromPtr__(long addr) { return new VideoWriter(addr); } 028 029 // 030 // C++: cv::VideoWriter::VideoWriter() 031 // 032 033 /** 034 * Default constructors 035 * 036 * The constructors/functions initialize video writers. 037 * <ul> 038 * <li> 039 * On Linux FFMPEG is used to write videos; 040 * </li> 041 * <li> 042 * On Windows FFMPEG or MSWF or DSHOW is used; 043 * </li> 044 * <li> 045 * On MacOSX AVFoundation is used. 046 * </li> 047 * </ul> 048 */ 049 public VideoWriter() { 050 nativeObj = VideoWriter_0(); 051 } 052 053 054 // 055 // C++: cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, bool isColor = true) 056 // 057 058 /** 059 * 060 * @param filename Name of the output video file. 061 * @param fourcc 4-character code of codec used to compress the frames. For example, 062 * VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') is a 063 * motion-jpeg codec etc. List of codes can be obtained at [Video Codecs by 064 * FOURCC](http://www.fourcc.org/codecs.php) page. FFMPEG backend with MP4 container natively uses 065 * other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), 066 * so you may receive a warning message from OpenCV about fourcc code conversion. 067 * @param fps Framerate of the created video stream. 068 * @param frameSize Size of the video frames. 069 * @param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it 070 * will work with grayscale frames. 071 * 072 * <b>Tips</b>: 073 * <ul> 074 * <li> 075 * With some backends {@code fourcc=-1} pops up the codec selection dialog from the system. 076 * </li> 077 * <li> 078 * To save image sequence use a proper filename (eg. {@code img_%02d.jpg}) and {@code fourcc=0} 079 * OR {@code fps=0}. Use uncompressed image format (eg. {@code img_%02d.BMP}) to save raw frames. 080 * </li> 081 * <li> 082 * Most codecs are lossy. If you want lossless video file you need to use a lossless codecs 083 * (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) 084 * </li> 085 * <li> 086 * If FFMPEG is enabled, using {@code codec=0; fps=0;} you can create an uncompressed (raw) video file. 087 * </li> 088 * </ul> 089 */ 090 public VideoWriter(String filename, int fourcc, double fps, Size frameSize, boolean isColor) { 091 nativeObj = VideoWriter_1(filename, fourcc, fps, frameSize.width, frameSize.height, isColor); 092 } 093 094 /** 095 * 096 * @param filename Name of the output video file. 097 * @param fourcc 4-character code of codec used to compress the frames. For example, 098 * VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') is a 099 * motion-jpeg codec etc. List of codes can be obtained at [Video Codecs by 100 * FOURCC](http://www.fourcc.org/codecs.php) page. FFMPEG backend with MP4 container natively uses 101 * other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), 102 * so you may receive a warning message from OpenCV about fourcc code conversion. 103 * @param fps Framerate of the created video stream. 104 * @param frameSize Size of the video frames. 105 * will work with grayscale frames. 106 * 107 * <b>Tips</b>: 108 * <ul> 109 * <li> 110 * With some backends {@code fourcc=-1} pops up the codec selection dialog from the system. 111 * </li> 112 * <li> 113 * To save image sequence use a proper filename (eg. {@code img_%02d.jpg}) and {@code fourcc=0} 114 * OR {@code fps=0}. Use uncompressed image format (eg. {@code img_%02d.BMP}) to save raw frames. 115 * </li> 116 * <li> 117 * Most codecs are lossy. If you want lossless video file you need to use a lossless codecs 118 * (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) 119 * </li> 120 * <li> 121 * If FFMPEG is enabled, using {@code codec=0; fps=0;} you can create an uncompressed (raw) video file. 122 * </li> 123 * </ul> 124 */ 125 public VideoWriter(String filename, int fourcc, double fps, Size frameSize) { 126 nativeObj = VideoWriter_2(filename, fourcc, fps, frameSize.width, frameSize.height); 127 } 128 129 130 // 131 // C++: cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true) 132 // 133 134 /** 135 * 136 * The {@code apiPreference} parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation 137 * if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. 138 * @param filename automatically generated 139 * @param apiPreference automatically generated 140 * @param fourcc automatically generated 141 * @param fps automatically generated 142 * @param frameSize automatically generated 143 * @param isColor automatically generated 144 */ 145 public VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, boolean isColor) { 146 nativeObj = VideoWriter_3(filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height, isColor); 147 } 148 149 /** 150 * 151 * The {@code apiPreference} parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation 152 * if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. 153 * @param filename automatically generated 154 * @param apiPreference automatically generated 155 * @param fourcc automatically generated 156 * @param fps automatically generated 157 * @param frameSize automatically generated 158 */ 159 public VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize) { 160 nativeObj = VideoWriter_4(filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height); 161 } 162 163 164 // 165 // C++: cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, vector_int params) 166 // 167 168 /** 169 * 170 * The {@code params} parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) 171 * see cv::VideoWriterProperties 172 * @param filename automatically generated 173 * @param fourcc automatically generated 174 * @param fps automatically generated 175 * @param frameSize automatically generated 176 * @param params automatically generated 177 */ 178 public VideoWriter(String filename, int fourcc, double fps, Size frameSize, MatOfInt params) { 179 Mat params_mat = params; 180 nativeObj = VideoWriter_5(filename, fourcc, fps, frameSize.width, frameSize.height, params_mat.nativeObj); 181 } 182 183 184 // 185 // C++: cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params) 186 // 187 188 public VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, MatOfInt params) { 189 Mat params_mat = params; 190 nativeObj = VideoWriter_6(filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height, params_mat.nativeObj); 191 } 192 193 194 // 195 // C++: bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, bool isColor = true) 196 // 197 198 /** 199 * Initializes or reinitializes video writer. 200 * 201 * The method opens video writer. Parameters are the same as in the constructor 202 * VideoWriter::VideoWriter. 203 * @return {@code true} if video writer has been successfully initialized 204 * 205 * The method first calls VideoWriter::release to close the already opened file. 206 * @param filename automatically generated 207 * @param fourcc automatically generated 208 * @param fps automatically generated 209 * @param frameSize automatically generated 210 * @param isColor automatically generated 211 */ 212 public boolean open(String filename, int fourcc, double fps, Size frameSize, boolean isColor) { 213 return open_0(nativeObj, filename, fourcc, fps, frameSize.width, frameSize.height, isColor); 214 } 215 216 /** 217 * Initializes or reinitializes video writer. 218 * 219 * The method opens video writer. Parameters are the same as in the constructor 220 * VideoWriter::VideoWriter. 221 * @return {@code true} if video writer has been successfully initialized 222 * 223 * The method first calls VideoWriter::release to close the already opened file. 224 * @param filename automatically generated 225 * @param fourcc automatically generated 226 * @param fps automatically generated 227 * @param frameSize automatically generated 228 */ 229 public boolean open(String filename, int fourcc, double fps, Size frameSize) { 230 return open_1(nativeObj, filename, fourcc, fps, frameSize.width, frameSize.height); 231 } 232 233 234 // 235 // C++: bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true) 236 // 237 238 public boolean open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, boolean isColor) { 239 return open_2(nativeObj, filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height, isColor); 240 } 241 242 public boolean open(String filename, int apiPreference, int fourcc, double fps, Size frameSize) { 243 return open_3(nativeObj, filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height); 244 } 245 246 247 // 248 // C++: bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, vector_int params) 249 // 250 251 public boolean open(String filename, int fourcc, double fps, Size frameSize, MatOfInt params) { 252 Mat params_mat = params; 253 return open_4(nativeObj, filename, fourcc, fps, frameSize.width, frameSize.height, params_mat.nativeObj); 254 } 255 256 257 // 258 // C++: bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params) 259 // 260 261 public boolean open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, MatOfInt params) { 262 Mat params_mat = params; 263 return open_5(nativeObj, filename, apiPreference, fourcc, fps, frameSize.width, frameSize.height, params_mat.nativeObj); 264 } 265 266 267 // 268 // C++: bool cv::VideoWriter::isOpened() 269 // 270 271 /** 272 * Returns true if video writer has been successfully initialized. 273 * @return automatically generated 274 */ 275 public boolean isOpened() { 276 return isOpened_0(nativeObj); 277 } 278 279 280 // 281 // C++: void cv::VideoWriter::release() 282 // 283 284 /** 285 * Closes the video writer. 286 * 287 * The method is automatically called by subsequent VideoWriter::open and by the VideoWriter 288 * destructor. 289 */ 290 public void release() { 291 release_0(nativeObj); 292 } 293 294 295 // 296 // C++: void cv::VideoWriter::write(Mat image) 297 // 298 299 /** 300 * Writes the next video frame 301 * 302 * @param image The written frame. In general, color images are expected in BGR format. 303 * 304 * The function/method writes the specified image to video file. It must have the same size as has 305 * been specified when opening the video writer. 306 */ 307 public void write(Mat image) { 308 write_0(nativeObj, image.nativeObj); 309 } 310 311 312 // 313 // C++: bool cv::VideoWriter::set(int propId, double value) 314 // 315 316 /** 317 * Sets a property in the VideoWriter. 318 * 319 * @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) 320 * or one of REF: videoio_flags_others 321 * 322 * @param value Value of the property. 323 * @return {@code true} if the property is supported by the backend used by the VideoWriter instance. 324 */ 325 public boolean set(int propId, double value) { 326 return set_0(nativeObj, propId, value); 327 } 328 329 330 // 331 // C++: double cv::VideoWriter::get(int propId) 332 // 333 334 /** 335 * Returns the specified VideoWriter property 336 * 337 * @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) 338 * or one of REF: videoio_flags_others 339 * 340 * @return Value for the specified property. Value 0 is returned when querying a property that is 341 * not supported by the backend used by the VideoWriter instance. 342 */ 343 public double get(int propId) { 344 return get_0(nativeObj, propId); 345 } 346 347 348 // 349 // C++: static int cv::VideoWriter::fourcc(char c1, char c2, char c3, char c4) 350 // 351 352 /** 353 * Concatenates 4 chars to a fourcc code 354 * 355 * @return a fourcc code 356 * 357 * This static method constructs the fourcc code of the codec to be used in the constructor 358 * VideoWriter::VideoWriter or VideoWriter::open. 359 * @param c1 automatically generated 360 * @param c2 automatically generated 361 * @param c3 automatically generated 362 * @param c4 automatically generated 363 */ 364 public static int fourcc(char c1, char c2, char c3, char c4) { 365 return fourcc_0(c1, c2, c3, c4); 366 } 367 368 369 // 370 // C++: String cv::VideoWriter::getBackendName() 371 // 372 373 /** 374 * Returns used backend API name 375 * 376 * <b>Note:</b> Stream should be opened. 377 * @return automatically generated 378 */ 379 public String getBackendName() { 380 return getBackendName_0(nativeObj); 381 } 382 383 384 @Override 385 protected void finalize() throws Throwable { 386 delete(nativeObj); 387 } 388 389 390 391 // C++: cv::VideoWriter::VideoWriter() 392 private static native long VideoWriter_0(); 393 394 // C++: cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, bool isColor = true) 395 private static native long VideoWriter_1(String filename, int fourcc, double fps, double frameSize_width, double frameSize_height, boolean isColor); 396 private static native long VideoWriter_2(String filename, int fourcc, double fps, double frameSize_width, double frameSize_height); 397 398 // C++: cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true) 399 private static native long VideoWriter_3(String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height, boolean isColor); 400 private static native long VideoWriter_4(String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height); 401 402 // C++: cv::VideoWriter::VideoWriter(String filename, int fourcc, double fps, Size frameSize, vector_int params) 403 private static native long VideoWriter_5(String filename, int fourcc, double fps, double frameSize_width, double frameSize_height, long params_mat_nativeObj); 404 405 // C++: cv::VideoWriter::VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params) 406 private static native long VideoWriter_6(String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height, long params_mat_nativeObj); 407 408 // C++: bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, bool isColor = true) 409 private static native boolean open_0(long nativeObj, String filename, int fourcc, double fps, double frameSize_width, double frameSize_height, boolean isColor); 410 private static native boolean open_1(long nativeObj, String filename, int fourcc, double fps, double frameSize_width, double frameSize_height); 411 412 // C++: bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true) 413 private static native boolean open_2(long nativeObj, String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height, boolean isColor); 414 private static native boolean open_3(long nativeObj, String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height); 415 416 // C++: bool cv::VideoWriter::open(String filename, int fourcc, double fps, Size frameSize, vector_int params) 417 private static native boolean open_4(long nativeObj, String filename, int fourcc, double fps, double frameSize_width, double frameSize_height, long params_mat_nativeObj); 418 419 // C++: bool cv::VideoWriter::open(String filename, int apiPreference, int fourcc, double fps, Size frameSize, vector_int params) 420 private static native boolean open_5(long nativeObj, String filename, int apiPreference, int fourcc, double fps, double frameSize_width, double frameSize_height, long params_mat_nativeObj); 421 422 // C++: bool cv::VideoWriter::isOpened() 423 private static native boolean isOpened_0(long nativeObj); 424 425 // C++: void cv::VideoWriter::release() 426 private static native void release_0(long nativeObj); 427 428 // C++: void cv::VideoWriter::write(Mat image) 429 private static native void write_0(long nativeObj, long image_nativeObj); 430 431 // C++: bool cv::VideoWriter::set(int propId, double value) 432 private static native boolean set_0(long nativeObj, int propId, double value); 433 434 // C++: double cv::VideoWriter::get(int propId) 435 private static native double get_0(long nativeObj, int propId); 436 437 // C++: static int cv::VideoWriter::fourcc(char c1, char c2, char c3, char c4) 438 private static native int fourcc_0(char c1, char c2, char c3, char c4); 439 440 // C++: String cv::VideoWriter::getBackendName() 441 private static native String getBackendName_0(long nativeObj); 442 443 // native support for java finalize() 444 private static native void delete(long nativeObj); 445 446}