What does ret and frame mean here?

When to use ret and frame? What values ​​do these variables have? I just started with image processing, so if there are more changes, let me know.

thank

import numpy as np
import cv2
cap = cv2.VideoCapture('Sample Lap HUL_OB_1.56.641_Graphic.mpg')

# Define the codec and create VideoWriter object
# fourcc = cv2.cv.CV_FOURCC(*'MJPG')
out = cv2.VideoWriter('output.mpg',0, 60.0, (640,480))
while(cap.isOpened()):
    ret, frame = cap.read()
    if ret==True:
         # frame = cv2.flip(frame,0)
         # write the flipped frame
        out.write(frame)
        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
             break
     else:
        break
# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()
+7
source share
4 answers

The “frame” will receive the next frame in the camera (through the “cap”). "Ret" will receive the return value from receiving the camera frame, either true or false. I recommend that you read OpenCV tutorials (which are very detailed) like this for face recognition: http://docs.opencv.org/modules/contrib/doc/facerec/facerec_tutorial.html

+7
source

cap.read docs. cap VideoCapture, Google "VideoCapture opencv Read" openCV. read doc grab, retval:

/ ...

+1

, .

:

cap.read() bool (True/False). , True. , , .

0

- , , "" "", , .

- . .

, .

0

All Articles