The following code "works" to roate the video however, I get an error. Also, it seems like the scale is off.
Any recommendations for how to fix?
Final output:
import numpy as np
import cv2
# capture video
cap = cv2.VideoCapture("c:/sandbox/temp.mp4")
# calculate the center of the image
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
center = (w / 2, h/ 2)
angle270 = 270
scale = 1.0
#descripe a loop
#read video frame by frame
while True:
ret,img = cap.read()
#rotate frames of video
M = cv2.getRotationMatrix2D(center, angle270, scale)
img2 = cv2.warpAffine(img, M, (w, h))
cv2.imshow('rotated video',img2)
k=cv2.waitKey(30) & 0xff
#once you inter Esc capturing will stop
if k==27:
break
cap.release()
cv2.destroyAllWindows()
Message=OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\imgwarp.cpp:2611: error: (-215:Assertion failed) src.cols > 0 && src.rows > 0 in function 'cv::warpAffine'