Forum Discussion
amitmarathe
Jun 17, 2021Copper Contributor
Percept - reading input video source instead of RTSP
I am trying to use a video file source as input into Percept, but this simple C++ code using OpenCV doesn’t work on the Percept (in the AzureEyeModule docker container). It is unable to open any vid...
christian-vorhemus
Microsoft
Jun 23, 2021amitmarathe If using Python is an option for you, you may want to look into using the "
opencv-python-headless" package which exists with prebuilt binaries for the aarch64 platform. Assuming you are running on the DK directly and not in a container, you can try the following:
1) Install pip3 with "sudo yum install pip3"
2) Install OpenCV (headless so we don't have additional dependencies for libGl or similar): "sudo pip3 install opencv-python-headless"
3) Prepare a Python script, this one is simply counting frames of a video
import cv2
import numpy as np
cap = cv2.VideoCapture("/path/to/your_video_file.mp4")
if not cap.isOpened():
print("Could not open file")
frame_count = 0
# Read until video is completed
while(cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
if ret == True:
frame_count += 1
else:
break
cap.release()
print(f"Frames: {frame_count}")
4) Run it, e.g. "sudo python3 video.py"