# Slow camera initialization

**URL:** <https://forum.opencv.org/t/slow-camera-initialization/12179>\
**Category:** Python\
**Tags:** camera\
**Created:** [February 28, 2023, 6:45pm UTC](https://forum.opencv.org/t/slow-camera-initialization/12179 "2023-02-28T18:45:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanni47](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sanni47/32/7281_2.png) [@Sanni47](https://forum.opencv.org/u/Sanni47)\
**Post date:** [February 28, 2023, 6:45pm UTC](https://forum.opencv.org/t/slow-camera-initialization/12179/1 "2023-02-28T18:45:18Z")

</div>

Hi, trying to start simple code to show in the window video from webcam, but window with video appear only after 5 minutes, what is wrong?

```auto
import cv2

# Open camera
cap = cv2.VideoCapture(0)

# Changing size of slide
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)

# Frame showing
while True:
    # Read frame
    ret, frame = cap.read()

    # If frame exceed ->read it
    if ret:
        cv2.imshow('Webcam', frame)

    # break key
    key = cv2.waitKey(1)
    if key == 27: # press ESC to break
        break

# clear all
cap.release()
cv2.destroyAllWindows()

```

---

<div class="post-metadata">

**Author:** ![Sanni47](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sanni47/32/7281_2.png) [@Sanni47](https://forum.opencv.org/u/Sanni47)\
**Post date:** [February 28, 2023, 7:04pm UTC](https://forum.opencv.org/t/slow-camera-initialization/12179/2 "2023-02-28T19:04:03Z")

</div>

I find solution:  
`cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)`
