Fix crash when eye roi outside of view
This commit is contained in:
parent
c06f6beae6
commit
57ad5cd47a
1
TODO.md
1
TODO.md
|
@ -9,7 +9,6 @@
|
||||||
- model copyright and authors
|
- model copyright and authors
|
||||||
|
|
||||||
## Bugs
|
## Bugs
|
||||||
- crash when eye goes outside of roi
|
|
||||||
- incorrect appdata location on Windows
|
- incorrect appdata location on Windows
|
||||||
|
|
||||||
# Whenever
|
# Whenever
|
||||||
|
|
|
@ -170,13 +170,20 @@ void cvFrame() {
|
||||||
cv::rectangle(frame, eyeRect, cv::Scalar(255, 255, 255));
|
cv::rectangle(frame, eyeRect, cv::Scalar(255, 255, 255));
|
||||||
|
|
||||||
cv::Mat eyeROI;
|
cv::Mat eyeROI;
|
||||||
|
glm::vec2 eyeVector(0,0);
|
||||||
|
|
||||||
|
// prevent assertion failed when eye is partly outside of image
|
||||||
|
if(eyeRect.x < 0 || eyeRect.x >= gray.cols || eyeRect.y < 0 || eyeRect.y >= gray.rows ||
|
||||||
|
eyeRect.x + eyeRect.width >= gray.cols || eyeRect.y - eyeRect.height >= gray.rows) goto noeye;
|
||||||
|
|
||||||
eyeROI = gray(eyeRect);
|
eyeROI = gray(eyeRect);
|
||||||
|
|
||||||
glm::vec2 eyeVector(0,0);
|
|
||||||
if (!optData.noEyes) {
|
if (!optData.noEyes) {
|
||||||
eyeVector = eyeDirection(eyeROI); // run pupil tracking algorithm and get look direction
|
eyeVector = eyeDirection(eyeROI); // run pupil tracking algorithm and get look direction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noeye:
|
||||||
|
|
||||||
//send control information to graphics
|
//send control information to graphics
|
||||||
float faceSize = landmarks[biggestFace][14].x - landmarks[biggestFace][2].x;
|
float faceSize = landmarks[biggestFace][14].x - landmarks[biggestFace][2].x;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue