PAL/NpuYoloV5/03_rk3588_hdmi_in_out_py/hdminVideo.py

24 lines
700 B
Python
Raw Permalink Normal View History

cap = cv2.VideoCapture('/dev/video10')
frames, loopTime, initTime = 0, time.time(), time.time()
fps = 0
while True:
frames += 1
ret, frame = cap.read()
if not ret:
break
# 现在应该可以直接使用frame不需要reshape
if frames % 30 == 0:
print("30帧平均帧率:\t", 30 / (time.time() - loopTime), "")
fps = 30 / (time.time() - loopTime)
loopTime = time.time()
cv2.putText(frame, "FPS: {:.2f}".format(fps), (10, 30),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
cv2.imshow("MIPI Camera", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()