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

**URL:** <https://forum.opencv.org/t/using-opencv4-7-0-cap-open-0-to-open-the-camera-is-slow/13954>\
**Category:** C++\
**Tags:** videoio\
**Created:** [July 20, 2023, 2:14am UTC](https://forum.opencv.org/t/using-opencv4-7-0-cap-open-0-to-open-the-camera-is-slow/13954 "2023-07-20T02:14:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NOERROR](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@NOERROR](https://forum.opencv.org/u/NOERROR)\
**Post date:** [July 20, 2023, 2:14am UTC](https://forum.opencv.org/t/using-opencv4-7-0-cap-open-0-to-open-the-camera-is-slow/13954/1 "2023-07-20T02:14:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [July 20, 2023, 5:39am UTC](https://forum.opencv.org/t/using-opencv4-7-0-cap-open-0-to-open-the-camera-is-slow/13954/2 "2023-07-20T05:39:19Z")

</div>

> [@NOERROR](#):
>
> 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))

---

<div class="post-metadata">

**Author:** ![NOERROR](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@NOERROR](https://forum.opencv.org/u/NOERROR)\
**Post date:** [July 20, 2023, 5:52am UTC](https://forum.opencv.org/t/using-opencv4-7-0-cap-open-0-to-open-the-camera-is-slow/13954/3 "2023-07-20T05:52:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![laurent.berger](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@laurent.berger](https://forum.opencv.org/u/laurent.berger)\
**Post date:** [July 20, 2023, 7:03am UTC](https://forum.opencv.org/t/using-opencv4-7-0-cap-open-0-to-open-the-camera-is-slow/13954/4 "2023-07-20T07:03:42Z")

</div>

> [@berak](#):
>
> (default now is CAP\_MSMF, which is slow sometimes)

There is note in [doc](https://docs.opencv.org/4.x/d4/d15/group __videoio__ flags__base.html#ga023786be1ee68a9105bf2e48c700294d) 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](https://learn.microsoft.com/en-us/windows/win32/medfound/mf-readwrite-enable-hardware-transforms)
