I want to develop a sketch matching game using OpenCV. What I am trying to do is match an image and user's drawing using the Shape Context matching. I can successfully compile and run my project but when I call the findContour function the program will crash and will produce
**First-chance exception at 0x5C78DE7A (msvcp120d.dll) in DTPproject.exe: 0xC0000005: Access violation writing location 0x00000010** error.
here is my code
vector CComputeDistance::simpleContour(const Mat& currentQuery, int n = 300)
{
vector> _contoursQuery;
vector contoursQuery;
findContours(currentQuery, _contoursQuery, RETR_LIST, CHAIN_APPROX_NONE);
for (size_t border = 0; border<_contoursQuery.size(); border++)
{
for (size_t p = 0; p<_contoursQuery[border].size(); p++)
{
contoursQuery.push_back(_contoursQuery[border][p]);
}
}
// In case actual number of points is less than n
int dummy = 0;
for (int add = (int)contoursQuery.size() - 1; add cont;
for (int i = 0; i mySC = createShapeContextDistanceExtractor();
vector a = simpleContour(image);
vector b = simpleContour(drawing);
result = mySC->computeDistance(a, b);
}
void CComputeDistance::loopCompute(Mat image, Mat drawing, float &sum)
{
int p = 20;
for (int i = 0; i < 5; i++)
{
float shapeDistance;
computeShapeDistance(image, drawing, shapeDistance);
sum = sum + shapeDistance;
p = p + 20;
}
}
what I am really trying to achieve is get the value of "sum" after calling the method **loopCompute** in which it iterates 5x in loop.
Here is the code that call will the method
CComputeDistance::loopCompute( image, drawing, sum);
Im using visual studio 2013 community and this is what the local variable looks like after the break on debug mode.

The program above runs perfectly if I run it in android but it fails on windows. I think it has something to do with the configuration of Visual Studio to OpenCV.
Any ideas?
↧