我的问题是,当我使用 opencv 将视频提取到帧中时,有时我得到的帧会翻转,这在我的机器(窗口)和 VM(ubuntu)上都发生过,但是我测试的一些视频,帧不翻转。所以,我想知道应该在我的代码中更改/添加哪些因素或哪些内容,以使提取内容无需翻转即可修复
def extract_frame(video,folder):
global fps
os.mkdir('./green_frame/{folder}/'.format(folder=folder))
vidcap = cv2.VideoCapture(video)
success,image = vidcap.read()
fps = vidcap.get(cv2.CAP_PROP_FPS)
count = 0
success = True
while success: #os.path.join(pathOut,(name+'.png'))
cv2.imwrite(os.path.join('./green_frame/{folder}/'.format(folder=folder),"frame%d.png" % count), image)
success,image = vidcap.read()
print('Read a new frame: ', success)
count += 1
This is the example of frame I get from this code.
Which my orginal video that I used is upside down like this:
所以,就我而言,我必须改变什么才能使它不像我的第一张照片那样翻转。与视频的分辨率或帧率有关吗?我用 1280x720 分辨率的视频进行测试,提取的所有帧都上下翻转,但 568x320 视频中的帧是正常的
谢谢
Edit:
So, I look at the information of the video and I found out that in the metadata, it has rotate 180 for the video that extract to an upside down frame
But when I check with a normal video that produced a non upside-down frame, it does not have rotate:180
那么,如何处理具有旋转的视频呢?