I compiled and installed OpenCV 4.1 using https://github.com/mdegans/nano_build_opencv, a script which is linked in the Jetson Zoo.
I’ve been trying to process video with OpenCV on the nano, and ran into a problem. Whenever I try to write to an AVI (MJPG) video, I get a slim line of properly rendered pixels across the top of the video, while the rest is solid green. I can’t seem to find anyone with this problem online. Does anyone have an idea of why this is happening?
My code has run on non-ARM machines and worked fine. Here is what I’m running:
import cv2
import numpy as np
cap = cv2.VideoCapture("video.mp4")
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))
out = cv2.VideoWriter('out.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 10, (frame_width,frame_height))
i = 0
while(True):
ret, frame = cap.read()
if ret == True:
out.write(frame)
i+=1
print(i)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break