Why does OpenCV need starting number?

Hello, recently, I’ve been working on a project to write in images from a file into a 3D environment while keeping its alpha channel.
I was able to do it successfully with AVIs, but when I used PNGs I would get the following error:
OpenCV(3.4.7) C:\build\3_4_winpack-build-win64-vc15\opencv\modules\videoio\src\cap_images.cpp:246: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): C:\Users\Project01\TestMovies\google.png in function 'cv::icvExtractPatte

I was able to fix the problem by appending a number (in this case google.png → 4google.png)

I was wondering if there is documentation regarding why a number is required in the file name so I can explain it if necessary.

i very much doubt, that you ever get images with an alpha channel from the VideoCapture.

use cv::imread("my.png", IMREAD_UNCHANGED)
for this instead, not the VideoCapture

there is indeed an image capture video backend, which expects numbered images like img00013.jpg to read sequences

1 Like

Apologies, I misspoke.
You are correct, I was able to read in AVIs, but they didn’t retain their transparencies. (PNGs did, however.) I could write them onto an opaque texture for transparency, but not exactly the same thing. Is it safe to assume that VideoCapture is not really capable of projecting the alpha channel from video files? If so, is there a better method for doing so within OpenCV?

Ah, I understand. I think in our solution we eventualy want to switch between a number of PNGs. Could we jump between different images in a sequence of PNGs if we read in a bunch of them?

Apologies if this is basic stuff, I’m really just starting out.

yes. there is no alpha in videos

also, having alpha in images for computer-vision is bad / terrible, bc the rgb part is basically undefined wherever you have opacity, so they mostly drop the alpha channel.

main problem here is: you tr to abuse a computer-vision library for something else it wasnt made for …

yes, you can, but you’re probably better off, using imread() , again.

Sadly, this is a running theme for the higher-ups I’m working with. :wink:

Ok, this is good enough information for me. Thanks a lot for the input!

1 Like