Ask Your Question

RohitSam's profile - activity

2016-08-06 13:24:24 -0600 received badge  Editor (source)
2016-07-05 04:49:26 -0600 answered a question How can I get one single frame from a video file?

I have done it this and i don't know if this is the the best way to do it ..

while(cap.isOpened()):
ret,frames=cap.read()
gray = cv2.cvtColor(frames, cv2.COLOR_BGR2GRAY)
retval,threshold=cv2.threshold(gray,50,100,cv2.THRESH_BINARY)
k=k+1
print k


if k%2==0:
   frame2=threshold
elif k%3==0:
   frame3=threshold  
else:
   frame1=threshold

sub=frame1-frame3
sub=0.9*threshold+0.1*sub

cv2.imshow('original',gray)
cv2.imshow('frame diff',sub)

if cv2.waitKey(1) & 0xFF == ord('q'):
    end=time.time()
    break