# Cannot Open the Camera on Nvidia Jetson Nano and Raspberry V2.1 Camera via OpenCV and Phyton Code

**URL:** <https://forum.opencv.org/t/cannot-open-the-camera-on-nvidia-jetson-nano-and-raspberry-v2-1-camera-via-opencv-and-phyton-code/9515>\
**Category:** Python\
**Tags:** raspberrypi, videoio, nvidia\
**Created:** [July 15, 2022, 5:50pm UTC](https://forum.opencv.org/t/cannot-open-the-camera-on-nvidia-jetson-nano-and-raspberry-v2-1-camera-via-opencv-and-phyton-code/9515 "2022-07-15T17:50:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/m_7/32/4435_2.png) [@M\_7](https://forum.opencv.org/u/M_7)\
**Post date:** [July 15, 2022, 5:50pm UTC](https://forum.opencv.org/t/cannot-open-the-camera-on-nvidia-jetson-nano-and-raspberry-v2-1-camera-via-opencv-and-phyton-code/9515/1 "2022-07-15T17:50:18Z")

</div>

Hi, I am using Nvidia Jetson Nano and Raspberry Pi V2.1 Camera for color detection via Python and OpenCV. However, the codes that worked on my computer do not work on Jetson Nano and I keep getting errors. The code is so simple, I just wanted to open the camera and get the real time view.

This is my code:

import cv2  
print(cv2. **version** )  
dispW=320  
dispH=240  
flip=2  
camSet=‘nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method=’+str(flip)+’ ! video/x-raw, width=‘+str(dispW)+’, height=‘+str(dispH)+’, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink’

cam=cv2.VideoCapture(camSet)

while True:  
ret, frame=cam.read()  
cv2.imshow(“camera”,frame)  
if cv2.waitKey(1) ==ord(“q”):  
break  
cam.release()  
cv2.destroyAllWindows()

And this is the error:

3.2.0

OpenCV Error: Assertion failed (size.width\>0 &&

size.height\>0) in imshow, file /build/opencv-XDqSFW/opencv 3.2.0+dfsg/modules/highgui/src/window.cpp, line 304

Traceback (most recent call last): File “camera.py”, line 12, in

cv2.imshow(“camera”,frame)

cv2.error: /build/opencv-XDqSFW/opencv

3.2.0+dfsg/modules/highgui/src/window.cpp:304: error: (-215)

size.width\>0&& size.height\>0 in function imshow

---

<div class="post-metadata">

**Author:** ![matti.vuori](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@matti.vuori](https://forum.opencv.org/u/matti.vuori)\
**Post date:** [July 16, 2022, 12:40pm UTC](https://forum.opencv.org/t/cannot-open-the-camera-on-nvidia-jetson-nano-and-raspberry-v2-1-camera-via-opencv-and-phyton-code/9515/2 "2022-07-16T12:40:24Z")

</div>

You try to imshow an empty Mat. Now, you need to figure out how to check that the read() succeeded before doing anything with the frame
