I am trying to extract frames from a video in OpenCV. This video technically has a 16:9 ratio but actually has a 2.39:1 ratio, so fairly large black bars. When using cv2.VideoCapture.read(), opencv produces frames that are strecthed into 16:9 ones.
Is there any way to avoid resizing using cv2.resize() ? As that is causing a huge slowdown, from 52ms to get 60s of frames without to 6s with it. Another, faster way of reszing would be fine as well but I was thinking there has to be a way to directly input aspect ratio or size before even reading the frames, right?
What i currently have:
success=1
count = 0
dim = (int(oriwidth), int(newheight))
time1=time()
imglist = []
while success:
success, image = video.read()
try:
image2 = cv2.resize(image, dim, fx=0, fy=0, interpolation = cv2.INTER_NEAREST)
imglist.append(image)
except:
break
count += 1