I will like to show multiple mp4 video files one-after-the-other, while overlaying the video with a user controlled circle. After reading this, I started using ffpyplayer's MediaPlayer to play the audio and get the video frames, and playing this via cv2.imshow.
But the video I get is super hazy and for cv.circle I get the following error:
> Overload resolution failed: - img is not a numpy array, neither a scalar
Expected Ptr<cv::UMat> for argument 'img'
Any help on how to fix these issues is greatly appreciated.
def video():
output=open('out.txt','a')
player = MediaPlayer('Isi_B1.mp4')
val =''
while (val!='eof'):
frame,val= player.get_frame() # capture frame-by-frame audio
if val =='eof':
break
if val!= 'eof' and frame is not None:
img, t = frame
w= img.get_size()[0]
h=img.get_size()[1]
arr=np.uint8(np.asarray(list(img.to_bytearray()[0])).reshape(w,h,3))
key_pressed = cv.waitKey(1)
if key_pressed == ord(' '): #pressing space bar ends the video
out('video 1 is changed',output)
break
elif key_pressed == 2: #left key pressed changes circle to letter
circle_is_left = True
out('left',output)
elif key_pressed == 3: # right key pressed changes circle to right
circle_is_left = False
out('Right ',output)
circle(img, circle_is_left) #display the circle at all times
cv.imshow('player',arr) #display resulting frame
output.close()
cv.destroyAllWindows()
player.close_player()