블로그 이미지
Kanais
Researcher & Developer 퍼즐을 완성하려면 퍼즐 조각들을 하나 둘씩 맞춰나가야 한다. 인생의 퍼즐 조각들을 하나 둘씩 맞춰나가다 보면 인생이란 퍼즐도 완성되는 날이 오려나...?

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

05-10 10:45

Recent Post

Recent Comment

Recent Trackback

Archive

2015. 4. 27. 02:49 Programming/Error Clear!


개발환경

사용툴       : Visual Studio 2013

라이브러리 : openCV library 2.4.10

프로젝트    : Visual C++ console application

개발날짜    : 2015-04-26



참고 : stackoverflow - R6010 abort() has been called

       stackoverflow - opencv r6010 abort() has been called error in visual studio 2013





구조체를 쓰다보면... 위와 같은 오류가 날때가 있다.


난 cv::Rect 구조체를 쓰다 오류가 났었는데... 한두 곳을 쓴게 아니라 찾아내는데 시간이 좀 걸렸다.


Rect 의 x와 y 값이  IplImage 의 index에 해당하지 않는 값으로 접근하려다보니 에러가 발생한 것이다.


아래와 같이 예외처리를 해주니... 해결!



Rect face = faces->at(i);

c_x = face.x;

c_y = face.y;

c_w = face.width;

c_h = face.height;

// exception handling under 0                                                     

if (c_y - 5 + (min / 10) < 0){ t_region.y = 0; }

else{ t_region.y = c_y - 5 + (min / 10); }

if (c_x - 5 + (min % 10) < 0){ t_region.x = 0; }

else{ t_region.x = c_x - 5 + (min % 10); }

// exception handling over max height

if (c_y - 5 + (min / 10) > image->height - c_y){ t_region.y = image->height - c_y; }

else { t_region.y = c_y - 5 + (min / 10); }

if (c_x - 5 + (min % 10) > image->width - c_w){ t_region.x = image->width - c_w; }

else { t_region.x = c_x - 5 + (min % 10); }





posted by Kanais