From 373ca5936907d1dee725f81012bf5c83edb745eb Mon Sep 17 00:00:00 2001 From: MambaWong Date: Wed, 12 Jul 2017 02:11:06 +0800 Subject: [PATCH] Update webcam_face_pose_ex.cpp (#702) Test on a given video like this cv::VideoCapture cap("Sample.avi") may be broken when the video frames are not enough before the main window is closed by the user. --- examples/webcam_face_pose_ex.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/webcam_face_pose_ex.cpp b/examples/webcam_face_pose_ex.cpp index dbbf83047..e3b00d0f2 100644 --- a/examples/webcam_face_pose_ex.cpp +++ b/examples/webcam_face_pose_ex.cpp @@ -60,7 +60,10 @@ int main() { // Grab a frame cv::Mat temp; - cap >> temp; + if (!cap.read(temp)) + { + break; + } // Turn OpenCV's Mat into something dlib can deal with. Note that this just // wraps the Mat object, it doesn't copy anything. So cimg is only valid as // long as temp is valid. Also don't do anything to temp that would cause it