Ask Your Question

Gagazet's profile - activity

2018-08-13 05:12:00 -0600 received badge  Famous Question (source)
2018-03-21 07:48:50 -0600 received badge  Notable Question (source)
2018-02-12 01:54:01 -0600 received badge  Popular Question (source)
2017-10-03 22:22:17 -0600 asked a question Cant capture and work with any vide

Cant capture and work with any vide Hello everyone. Have a huge problem here. After my long holidays found, that now any

2017-08-02 17:12:06 -0600 received badge  Student (source)
2017-04-11 00:12:56 -0600 received badge  Supporter (source)
2017-04-11 00:12:55 -0600 commented answer How to resize frame's from video with aspect ratio

Thank you. I spend around 4 hours, but found another way how to do it with correct borders! Anyway thank you. And i am not sure, that you can resize by your way from 1080 to the 480 properly~

2017-04-10 19:53:48 -0600 asked a question 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: image description

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: image description

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.

2017-04-10 19:51:16 -0600 received badge  Scholar (source)
2017-02-01 00:56:40 -0600 asked a question Problem's with video output, newbi here~

Hello guys. Studying openCV now, for part time job and met problem, with what i can't deal. This is simply code, as at tutorial, but i am trying to have at output black&white video. Problem in codec, i think, because i tryed to use really a lot of them - DIVX, MP4V, M4S2 and etc., at output i have 1 kb video file just with name. I am using windows, 3.5Python. With image all great~ Will be happy in help, i tryed google about this problem and all advices couldn't help me. Sorry for English, not a native speaker, but trying to do my best~

import numpy as np
import cv2

cap = cv2.VideoCapture('VideoEX.mp4')

fourcc = cv2.VideoWriter_fourcc(*"MP4V")
out = cv2.VideoWriter('output1.mp4', fourcc , 20.0, (640,480))

while(cap.isOpened()):
    ret, frame = cap.read()
    if ret == True:
       gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
       out.write(gray)

       cv2.imshow('frame',frame)
       if cv2.waitKey(1) & 0xFF == ord('q'):
           break
    else:
        break

cap.release()
out.release()
cv2.destroyAllWindows()