Ignore empty frames to prevent crashes
This commit is contained in:
parent
735e27ac53
commit
325ff2ce7d
|
@ -26,6 +26,8 @@ void initCV() {
|
|||
facemark->loadModel (resolvePath("cvdata/lbfmodel.yaml"));
|
||||
|
||||
vid = cv::VideoCapture (0);
|
||||
|
||||
if(!vid.isOpened()) {std::cout << "Camera not opened!" << std::endl;}
|
||||
}
|
||||
|
||||
void dnnFaceDetect(cv::Mat inFrame, std::vector<cv::Rect>* faces) {
|
||||
|
@ -56,6 +58,8 @@ void dnnFaceDetect(cv::Mat inFrame, std::vector<cv::Rect>* faces) {
|
|||
void cvFrame() {
|
||||
vid.read(frame);
|
||||
|
||||
if(frame.empty()) return;
|
||||
|
||||
cv::cvtColor (frame, gray, cv::COLOR_BGR2GRAY);
|
||||
|
||||
std::vector<cv::Rect> faces;
|
||||
|
@ -157,6 +161,8 @@ void cvFrame() {
|
|||
}
|
||||
|
||||
void cvShowFrame() {
|
||||
if(frame.empty()) return;
|
||||
|
||||
cv::imshow("Video Input", frame);
|
||||
cv::waitKey(1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue