I am a newbie in using VS2012 & openCV for the completion of my FYP where I have to detect human bodies(Object detection) using Contours. I have installed successfully both (VS2012 & openCV) & had been doing some basic image processing without any unknown problem other than logical or syntactical until I came across using the findContours function where I am detained right now. My problem is:
When I do not use the Contour related stuff i.e. findContours , drawContours, by commenting it, every thing is fine and I can use trackbar to dilate/erode the image but as soon as I use Contour related stuff and press ‘F5’, the image showing contours around the detected objects is shown along with breakpoint saying Program.exe has triggered a break point and hence I can’t use it further.
For your convenience, following are the listings in stack trace:
Note 1: I have followed the instructions given by pbrandoli , but after loading the Un-Highlighted “ntdll.dll & msvcr” via Microsoft symbol servers gets highlighted & on restarting (Cntrl+Shift+F5) or debugging(F5) it again gets Un-highlighted indicating that it is missing.
Note 2: I have concised the list for convenience.
ntdll.dll!77ca5204() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!77c6fbae() Unknown
ntdll.dll!77c02b04() Unknown
KernelBase.dll!75ff7e27() Unknown
> msvcr110d.dll!_CrtIsValidHeapPointer(const void * pUserData) Line 2036 C++
msvcr110d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1322 C++
msvcr110d.dll!_free_dbg(void * pUserData, int nBlockUse) Line 1265 C++
msvcr110d.dll!operator delete(void * pUserData) Line 54 C++
binaryFrame.exe!std::allocator<cv::Point_<int> >::deallocate(cv::Point_<int> * _Ptr,
unsigned int __formal) Line 586 C++
binaryFrame.exe!std::_Wrap_alloc<std::allocator<cv::Point_<int> >
>::deallocate(cv::Point_<int> * _Ptr, unsigned int _Count) Line 888 C++
binaryFrame.exe!std::vector<cv::Point_<int>,std::allocator<cv::Point_<int> > >::_Tidy()
binaryFrame.exe!showBinImage() Line 66 C++
binaryFrame.exe!main(int __formal, char * * argv) Line 21 C++
binaryFrame.exe!__tmainCRTStartup() Line 536 C
binaryFrame.exe!mainCRTStartup() Line 377 C
kernel32.dll!763e1154() Unknown
ntdll.dll!77c3b299() Unknown
ntdll.dll!77c3b26c() Unknown
following is the code that i am using for contour detection in image:
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
void showBinImage();
int val=2;
int main( int, char** argv )
{
showBinImage();
return 0;
}
void showBinImage(){
Mat bin;
Mat im_gray;
Mat im_rgb = imread("nk5.jpg");
// Trackbar
namedWindow("ErodedImage",1);
createTrackbar("Erode", "ErodedImage", &val, 50);
cvtColor(im_rgb, im_gray,CV_RGB2GRAY);
threshold(im_gray, bin, 128.0, 255.0, THRESH_BINARY_INV);
//imwrite("bnasir.jpg", img_bw);
namedWindow("Binary",1);
imshow("Binary", bin);
while (true)
{
Mat erodeElement = getStructuringElement( MORPH_CROSS,Size(val*3,val*3));
Mat dilateElement = getStructuringElement( MORPH_RECT,Size(val*8,val*8));
Mat eroded; // the destination image
erode(bin,eroded,erodeElement+50);
dilate(eroded,eroded,dilateElement);
std::vector<std::vector<cv::Point>> contours;
findContours(eroded, contours, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
// Draw black contours on a white image
Mat result(eroded.size(),CV_8U,cv::Scalar(255));
drawContours(result,contours,-1, cv::Scalar(0), 2); // with a thickness of 2
imshow("ErodedImage",(eroded));
waitKey(10);
}
}
I switched from VS2012 to VS2010 and now every thing works fine! I don't know what is the problem with VS2012 because VS2013 also provides results as VS2010 but to use VS2013, u need Windows 8 OS. Hence i came back to Older version since i am using Windows 7 OS!