Using opencv4.7.0 cap.open(0) to open the camera is slow

I can use the opencv3.2.0 library to open the camera cap.open(0) can be opened normally and quickly, without modifying the code to replace the opencv4.7.0 library, open the camera becomes very slow, it takes tens of seconds, what is the reason

on which os ?
(if it’s win, might try to change the backend back to CAP_DSHOW, as it was back in 3.2. (default now is CAP_MSMF, which is slow sometimes))

In windowns, just now I tried to follow your method and successfully solved the problem of slow opening, thank you very much

There is note in doc now

Microsoft Media Foundation backend tries to use hardware accelerated transformations if possible. Environment flag “OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS” set to 0 disables it and may improve initialization time. More details: MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS attribute (Mfreadwrite.h) - Win32 apps | Microsoft Learn

1 Like