D-Alex / ropencv

ffi ruby wrapper for opencv
Other
67 stars 14 forks source link

VideoCapture loops infinitely #21

Closed ahsandar closed 10 years ago

ahsandar commented 10 years ago

Referring to the code below grab() or retrieve() never return false on reaching the end of file , instead restart reading the file causing an infinite loop

video_file = cv::VideoCapture.new(video_path)

while video_file.grab frame = cv::Mat.new output = video_file.retrieve(frame) break unless output framename = Time.now.strftime('frame%Y%m%d%H%M%S%L.jpg') cv::imwrite(File.join(output_path,frame_name),frame) end

D-Alex commented 10 years ago

It seems that this is the default behavior of grab (loop over the video file). You can use video_file.read returning false in the case of end of file.