Ubuntu 20.04 + Raspberry pi camera

On my Jetson Nano 2GB I tested a Raspberry Pi streaming camera. That worked OK
Now I am trying the same program on a HP desktop with Ubuntu 20.04
Unfortunately, now the program does not see the camera.

Error message:
File “/home/henkoegema/Documents/StreamingIPCameraRPI0W/lesson62.py”, line 21, in
cv2.imshow(‘nanoCam’,frame)
cv2.error: OpenCV(4.5.5) /io/opencv/modules/highgui/src/window.cpp:1000: error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘imshow’

=======================================================================================
#AI ON THE JETSON NANO LESSON 62: CREATE A STREAMING IP CAMERA FROM A RASPBERRY PI ZERO W
#AI on the Jetson Nano LESSON 62: Make a Streaming IP Camera from a Raspberry Pi Zero W - YouTube

import cv2
print(cv2.version)
dispW=640
dispH=480
flip=2

camSet=’ tcpclientsrc host=192.168.2.100 port=8554 ! gdpdepay ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv flip-method=‘+str(flip)+’ ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw, width=‘+str(dispW)+’, height=‘+str(dispH)+’,format=BGR ! appsink drop=true sync=false ’

cam= cv2.VideoCapture(camSet)

while True:
ret, frame = cam.read()
cv2.imshow(‘nanoCam’,frame)
if cv2.waitKey(1)==ord(‘q’):
break
cam.release()
cv2.destroyAllWindows()

The following line activates the Raspberry Pi 0 W camera:

#raspivid -t 0 -w 1296 -h 730 -fps 30 -b 2000000 -awb auto -n -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=0.0.0.0 port=8554

As you can see it’s a very small program.
I hope somebody is willing to test this (both on a Jetson and on a Ubuntu 20.04), to see if you get the same result.

Best greetings.
Henk

This doesn’t have anything to do with CUDA programming. You’ve posted in the wrong forum. I suggest you post your question on a OpenCV forum.

1 Like