안녕하세요, C++/C 개발자 코드를 디버깅하려고합니다. 그는 기본적으로 웹캠 그리드로 사진을 찍는 어도비 네이티브 확장 프로그램에서 dll을 사용하고 있습니다. 얼굴 검색은 이미지를 자르고 디스크에 기록하는 것으로 가정합니다. 그러나 앱이 항상 결국 중단 및OpenCV 및 C로 이미지 자르기
이 라인에 충돌 :
smallFrame = image(Rect(x, y, CROPPING_WIDTH, CROPPING_HEIGHT));
내가 주위 시도/캐치를 던져이 라인에 좁혀하고 밖으로 뱉어 예외가 매우 도움이되지 않습니다, 그것은 단지 ??????? n을 예외로 말합니다. 그래서 같은
:
Mat cropFaceFrame(Mat frame)
{
std::vector<Rect> faces;
Mat frame_gray, smallFrame;
int height = 0;
unsigned index, i;
cvtColor(frame, frame_gray, CV_BGR2GRAY);
equalizeHist(frame_gray, frame_gray);
face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(60, 60));
index = faces.size();
wsprintf (str, L
for (i = 0; i < faces.size(); i++)
{
if (height < faces[i].height)
{
height = faces[i].height;
index = i;
}
}
Mat image(frame);
int maxRight, maxDown;
maxRight = IMAGE_WIDTH-CROPPING_WIDTH -1;
// right margin
maxDown = IMAGE_HEIGHT-CROPPING_HEIGHT-1;
// down margin
if (index == faces.size())
{
// crop the center part if no face found
try
{
smallFrame = image(Rect(maxRight/2, maxDown/2, CROPPING_WIDTH, CROPPING_HEIGHT));
}
catch(exception ex)
{
smallFrame = frame;
}
}
else
{
int x, y;
x = faces[index].x - (CROPPING_WIDTH-faces[index].width)/2;
if (x < 0) x = 0;
else if (x > maxRight) x = maxRight;
y = faces[index].y - (CROPPING_HEIGHT-faces[index].height)/3;
if (y < 0) y = 0;
else if (y > maxDown) y = maxDown;
try
{
smallFrame = image(Rect(x, y, CROPPING_WIDTH, CROPPING_HEIGHT));
}
catch(exception ex)
{
wsprintf (str, L
"Exception Occured during no Face Found : %s", ex.what());
WriteLogFile(str);
smallFrame = frame;
}
}
return smallFrame;
}