How to resize frame's from video with aspect ratio
At the head of question main idea. I am using Python 2.7, openCV for it. Finally, i have this code:
import cv2
vidcap = cv2.VideoCapture('myvid2.mp4')
success,image = vidcap.read()
count = 0;
print "I am in success"
while success:
success,image = vidcap.read()
resize = cv2.resize(image, (640, 480), interpolation = cv2.INTER_LINEAR)
cv2.imwrite("%03d.jpg" % count, resize)
if cv2.waitKey(10) == 27:
break
count += 1
We have video and cutting it on each frames, as a .jpg images. In the same time we making resize from any size to the 640x480. And all images has correct order of reading. There is no any problems with code and it work's well, but!...it doesn't save prev. image ratio. And this is big problem, because i am need in it.
For example how it look's like, resize from 1920x1080:
There is problem in ratio, as you can see. 1920x1080 16:9, but 640:480 4:3
And how it should be in my dream:
At first, thank you for your reading of it. I will be very glad if you can help to me solve this issue of my code~ Have a good day, my friend.