Webcam Not Functioning on Zybo Z7-10 with PYNQ 3.0.1

Could anyone identify the cause? The situation is as follows:

  • Zybo Z7-10, PYNQ 3.0.1
  • Using the PYNQ image from Nick Petrovsky ( GitHub - nick-petrovsky/PYNQ-ZYBO: PYNQ for Zybo board) Zybo-Z7-10-3.0.1-fix-havege.img.xz
  • Confirmed that the USB-connected camera is recognized using the lsusb command
  • Running the following in Jupyter Notebook:
import cv2
cap = cv2.VideoCapture(0, cv2.CAP_V4L2)
print(cap.isOpened())
print(cap.grab())
print(cap.read())
  • The result is as follows, and it is unable to read the image:
True
False
(False, None)

Hi,
I think cv2.VideoCapture starts the connection between the board and the webcam, so cap.isOpened=True. But you did not specify the resolution of the stream, so the stream is existing but not running. Thus cap.read= (False,None).

You select a resolution via:
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)

For Full HD 1920*1080.

Also, is your webcam functionning, not defective?

Thank you for your prompt response.

I think I have done everything I can to set it on Python, including the resolution and frame rate. Maybe something is missing in the PYNQ environment setup.

When I ran the fswebcam command on Linux, I got the following error.

% fswebcam test.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Adjusting resolution from 384x288 to 352x288.
Error starting stream.
VIDIOC_STREAMON: Cannot allocate memory
Unable to use mmap. Using read instead.
Unable to use read.

By the way, both the Python program and fswebcam worked without any problems on the KV260 PYNQ.

Is your webcam working, have you tested it on your Computer?

Can you please try with a low resolution, like 240*160, or lower? To see if you still have the memory problem when there is less to save.

Is your kernel up-to-date, via sudo apt upgrade? Do you have libraries that do not want to update?

I think I’ve checked all the basic settings, including the ones you pointed out.
I’ve also set the external power supply and the USB HOST jumper pin (JP2) correctly.

Thinking that the problem was caused by Linux, I’ve made various edits to “pynq.cfg” and “system-user.dtsi” and then rebuilt the system, but the result remains the same. I’m really feeling stuck right now.

Just to be sure, Have you checked the webcam, and is your kernel up-to-date via sudo apt upgrade?

The WEBCAM has been confirmed to work. I also ran “apt apgrade” at an early stage.
However, the situation has not changed.

Hi @Cobac,

Welcome to the PYNQ community. Unfortunately, I do not have a Zybo board.

Have you tried with different backends? For instance, removing cv2.CAP_V4L2

Would you have another camera to try?

The issues you’re seeing indicate that something is missing in the image, probably a driver for that camera or similar.

What is the camera model?

Maybe for sound check, what happens if you try to read from a video file?

Mario

Thank you for your quick response.

・cap = cv2.VideoCapture(0) The result is the same
・WEBCAM: BAFFALO BSWHD06M (720P)
・This camera works fine with PYNQ on KV260

I think the problem lies with the PYNQ environment on the Zybo Z7-10 or with Ubuntu.
I’ll try reading from a video file if necessary, but will that help pinpoint the cause?

The root file system for Zynq is different to Kria.

I’ll try reading from a video file if necessary, but will that help pinpoint the cause?

At least would clarify if OpenCV works.

Mario

I posted an issue on Github to ask about the PYNQ image creator. The creator was able to reproduce the problem, but the cause is unclear.

He suggested updating the kernel or applying a V4L2 patch, but I don’t have the skills to do so, so I’m starting to give up.

https://github.com/nick-petrovsky/PYNQ-ZYBO/issues/4