# Difference between cv2..VideoCapture(0) and imutils VideoStream(src = 0).start()

**URL:** <https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454>\
**Category:** Python\
**Tags:** imutils\
**Created:** [February 10, 2021, 7:19am UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454 "2021-02-10T07:19:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maheswari.R](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Maheswari.R](https://forum.opencv.org/u/Maheswari.R)\
**Post date:** [February 10, 2021, 7:19am UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/1 "2021-02-10T07:19:57Z")

</div>

Hi, I am using opencv VideoCapture() method and imutils VideoStream() functions to capture video from webcam. This two functions output is different. Position of the camera is fixed. However coverage area differs a lot. what functionality behind this functions? I can set the frame resolution in VideoCapture(). Likewise how to set frame resolution in imutils VideoStream()?

---

<div class="post-metadata">

**Author:** ![Maheswari.R](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Maheswari.R](https://forum.opencv.org/u/Maheswari.R)\
**Post date:** [February 10, 2021, 7:22am UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/2 "2021-02-10T07:22:32Z")

</div>

snap of image captured via VideoCapture()

 ![cv2.snap.PNG](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/1X/33e30ee6fdc0568a39ccec75097b6d9195e274fa.jpeg) !

snap of image captured via imutils VideoStream()  
[vs.snap.PNG|627x500](https://forum.opencv.org/uploads/short-url/fuTNDlGI8HMFsL2wNV752xMu67r.jpeg)

---

<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:** [February 10, 2021, 8:11am UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/3 "2021-02-10T08:11:38Z")

</div>

> [@Maheswari.R](#):
>
> imutils VideoStream()

Hi,  
May be somebody can help you about imutils but this forum is about opencv. You can explore source code too I think it’s [here](https://github.com/jrosebr1/imutils/tree/master/imutils/video)

---

<div class="post-metadata">

**Author:** ![Maheswari.R](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Maheswari.R](https://forum.opencv.org/u/Maheswari.R)\
**Post date:** [February 10, 2021, 10:57am UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/4 "2021-02-10T10:57:24Z")

</div>

ok @laurent.berger. thank you

---

<div class="post-metadata">

**Author:** ![furas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/furas/32/706_2.png) [@furas](https://forum.opencv.org/u/furas)\
**Post date:** [February 13, 2021, 9:29pm UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/5 "2021-02-13T21:29:51Z")

</div>

`VideoStream()` can use `VideoCapture()` or `PiCamera()` (on Raspberry Pi) and it runs in thread so it can run faster.

In source code you can see it uses `resolution=(320, 240)` and this may change output but only for `PiCamera`. For `VideoCapture()` it should use default resolution.

You would have to show code which you use. Maybe you set different resolutin in `VideoCapture` and you use non-default value.

---

<div class="post-metadata">

**Author:** ![Maheswari.R](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Maheswari.R](https://forum.opencv.org/u/Maheswari.R)\
**Post date:** [February 15, 2021, 4:37am UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/6 "2021-02-15T04:37:04Z")

</div>

Thanks @furas . I have set the resolution(1920, 1080) of VideoCapture. But not for videostream. I think it’s taking default resolution. How to set the resolution in videostream?

---

<div class="post-metadata">

**Author:** ![furas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/furas/32/706_2.png) [@furas](https://forum.opencv.org/u/furas)\
**Post date:** [February 15, 2021, 12:28pm UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/7 "2021-02-15T12:28:11Z")

</div>

I don’t see any method to set resolution for **VideoCapture** in **VideoStream**

It assigns **VideoCapture** to **VideoStream.stream** so you may try to use

```
 s = VideoStream()
 s.stream.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
 s.stream.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)

```

but `s.stream` is already reading one frame and I don’t know if you can change resolution during reading frames.

Eventually: **VideoStream** uses class **WebCamVideoStream** which uses **VideoCapture** - so you can copy source code of **WebCamVideoStream** add `set()` in ` __init__ ` before first `.read()` in this class and use this **WebCamVideoStream** instead of **VideoStream**

[imutils/webcamvideostream.py at master · jrosebr1/imutils · GitHub](https://github.com/jrosebr1/imutils/blob/master/imutils/video/webcamvideostream.py)

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 15, 2021, 3:44pm UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/8 "2021-02-15T15:44:58Z")

</div>

I would strongly suggest seeking support for imutils from the imutils author, on the given github. he knows best what his library is doing.

---

<div class="post-metadata">

**Author:** ![Maheswari.R](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Maheswari.R](https://forum.opencv.org/u/Maheswari.R)\
**Post date:** [February 16, 2021, 5:29am UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/9 "2021-02-16T05:29:35Z")

</div>

> [@furas](#):
>
> **WebCamVideoStream**

I have tried the above method. but it didn’t change width and height.

---

<div class="post-metadata">

**Author:** ![Maheswari.R](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Maheswari.R](https://forum.opencv.org/u/Maheswari.R)\
**Post date:** [February 16, 2021, 5:30am UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/10 "2021-02-16T05:30:51Z")

</div>

ok @crackwitz . I will post the question in github imutils page

---

<div class="post-metadata">

**Author:** ![Ahmed\_Magaji](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/ahmed_magaji/32/4245_2.png) [@Ahmed\_Magaji](https://forum.opencv.org/u/Ahmed_Magaji)\
**Post date:** [January 15, 2022, 1:45pm UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/11 "2022-01-15T13:45:16Z")

</div>

The VideoStream class can be constructed with the new resolution.

> VideoStream(src=0, usePiCamera=False, resolution=(320, 240), framerate=32, \*\*kwargs)

---

<div class="post-metadata">

**Author:** ![Maheswari.R](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Maheswari.R](https://forum.opencv.org/u/Maheswari.R)\
**Post date:** [August 23, 2022, 7:53am UTC](https://forum.opencv.org/t/difference-between-cv2-videocapture-0-and-imutils-videostream-src-0-start/1454/12 "2022-08-23T07:53:42Z")

</div>

thanks @Ahmed_Magaji. i will check it
