It may takes about 20 seconds... Be patient.
from pynq.overlays.base import BaseOverlay
from pynq.lib.video import *
base = BaseOverlay("base.bit")
width_in = 640
height_in = 480
# width_out = 640
# height_out = 480
width_out = 1920
height_out = 1080
bits_per_pixel = 24
You will see black screen on HDMI output
mode = VideoMode(width_out, height_out, 24)
hdmi_out = base.video.hdmi_out
hdmi_out.configure(mode, PIXEL_BGR)
hdmi_out.start()
It may takes a couple of seconds again.
import cv2
cap = cv2.VideoCapture(0)
n_retry = 3
for i in range(n_retry):
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width_in)
ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height_in)
if ret:
print("Video input configuration: done")
break
cap.release()
else:
print("Video input configuration: failed")
import numpy as np
import sys
import time
start_time = time.time()
last_printed_time = 0.0
n_frames = 0
while True:
ret, inframe = cap.read()
if ret:
outframe = hdmi_out.newframe()
outframe[0:height_in, 0:width_in, :] = inframe[0:height_in, 0:width_in, :]
hdmi_out.writeframe(outframe)
n_frames += 1
passed_time = time.time() - start_time
if int(last_printed_time) != int(passed_time):
sys.stdout.write("Frame rate so far: %.1f\r" % (n_frames / passed_time))
last_printed_time = passed_time
else:
print("Read error")
cap.release()
del cap
hdmi_out.stop()
del hdmi_out