I use my Logitec usb-webcam and the PYNQ-Z2 board. I want to create a video stream of the camera via hdmi out.
The code I am using is:
Capture_webcam_camera
from pynq.overlays.base import BaseOverlay
from pynq.lib.video import *
base = BaseOverlay(“base.bit”)
monitor configuration: 640*480 @ 60Hz
Mode = VideoMode(640,480,24)
hdmi_out = base.video.hdmi_out
hdmi_out.configure(Mode,PIXEL_BGR)
hdmi_out.start()
monitor (output) frame buffer size
frame_out_w = 1920
frame_out_h = 1080
camera (input) configuration
frame_in_w = 640
frame_in_h = 480
initialize camera from OpenCV
import cv2
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, frame_in_w);
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_in_h);
print("Capture device is open: " + str(cap.isOpened()))
Capture webcam video
while (True):
ret, frame = cap.read()
outframe = hdmi_out.newframe()
outframe[:] = frame
hdmi_out.writeframe(outframe)
cap.release()
cv2.destroyAllWindows()
The Problem is that the live video is starting, but it freezes in a couple of seconds and I get an Error
TypeError
TypeError Traceback (most recent call last)
in ()
5
6 outframe = hdmi_out.newframe()
----> 7 outframe[:] = frame
8 hdmi_out.writeframe(outframe)
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘NoneType’
Does anyone know why exactly this occurs?
Thanks