File List Extensions Supported by OpenCV

In OpenCV, I see that imread () and VideoCapture () take a string to the file path of several extensions. Is there a way to get a list of the extensions they support? For example, getting a list of "jpg", "png", "mov", "mpg", etc.? I assume this is system dependent, and others needed to request this at runtime.

In addition, how is support determined? If there is something like the code below and Mat I return, it always seems partially corrupted (I see a little image). It does not seem to change regardless of the frame number that I ask. I can play this video in the totem of the video player, but I'm not even sure that the totem and OpenCV even use the same codec for this file.

Mat fromVideo(std::string _videoPath, int frame) {
    VideoCapture capture(_videoPath);

    Mat f;
    for (int i = 0; i < frame; i++) {
        capture >> f;
    }
    return f;
}
+4
source share
3 answers

Forimread() (more info here ):

  • Windows bitmaps - * .bmp, * .dib (always supported)
  • JPEG files - * .jpeg, * .jpg, * .jpe (see "Notes" section)
  • JPEG 2000 files - * .jp2 (see "Notes" section)
  • Portable Network Graphics - * .png (see "Notes" section)
  • Portable Image Format - * .pbm, * .pgm, * .ppm (always supported)
  • Sun rasters - * .sr, * .ras (always supported)
  • TIFF files - * .tiff, * .tif (see "Notes" section)

For VideoCapture():

  • AVI Files - * .avi

    , AVI - - . . .

+3

cv::VideoCapture::isOpened(), , VideoCapture.

, OpenCV (, AVI, MKV) , ( , , ..). , , OpenCV, API OpenCV isOpened().

0

Just update:

cv::VideoCapture cap("D:\\test.mp4")

works for me.

0
source

All Articles