Expression: __acrt_first_block == header
void MatTestVector(Mat *pProcImg)
{
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
cv::findContours(*pProcImg, contours, hierarchy,
RetrievalModes::RETR_EXTERNAL,
ContourApproximationModes::CHAIN_APPROX_NONE);
}
분석.
- vector가 선언되고 findcontoures()가 실행 후 발생.
(Release Mode에서는 미 발생.)
-OpneCV 3.2.0에서 IplImage와 CvSeq사용 시 미 발생.
void MatTestVector(IplImage *pTargetImg)
{
CvMemStorage *storage = cvCreateMemStorage();
CvSeq *contours = nullptr;
CvSeq *contour = nullptr;
cvFindContours(pTargetImg, storage, &contours, sizeof(CvContour),
CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE, cvPoint(0, 0));
}
방법.
1. Vector의 선언을 전역으로 변경.
2. Vector의 선언을 1번과 같은 방법 이지만 "static"으로 선언.(사용중)
void MatTestVector(Mat *pProcImg)
{
static vector<vector<Point> > contours;
static vector<Vec4i> hierarchy;
cv::findContours(*pProcImg, contours, hierarchy,
RetrievalModes::RETR_EXTERNAL,
ContourApproximationModes::CHAIN_APPROX_NONE);
}
*정확한 원인과 해결 방법을 아시는 분은 댓글 부탁드립니다.
<참고>
STL에 객체가 선언되고, DLL 내부에서 메모리를 할당 메모리 해제 순서에 의해 발생.
==> Expression: __acrt_first_block == header
App와 DLL의 메모리 관리
* App 메모리 생성 -> DLL에서 사용 -> App에서 해지.
* App DLL 함수 호출 -> DLL안에서 메모리 생성 -> DLL안에서 사용 -> DLL 안에서 메모리 해지 -> APP의 결과 전달.
즉, 메모리를 생성한 곳에서 해지 하자.
(App에서 생성하였으면 App에서, DLL에서 생성한 것이면 DLL에서 해지 하자~~!!!)
Expression: __acrt_first_block == header
'작업 > OpenCV' 카테고리의 다른 글
CvvImage 추가 3.4 까지 (0) | 2021.11.09 |
---|---|
처리시간 측정 (0) | 2020.07.17 |
OpneCV Test(4.1.2, 3.8.4, 3.4.0) (0) | 2019.11.22 |
OpenCV 컴파일(3.4.0, 3.4.8, 4.1.2) (0) | 2019.11.21 |
OpenCV Memory Leak (0) | 2019.11.20 |