I am currently working on the Intel Perceptual camera with OpenCv. I can get images from the camera, converting them into cv::Mat types, then applying a skin and a depth filter.
Now I want to calculate a convex hull with the "convexHull" function from openCV, but it creates a heap corruption.
Here is the interesting part of the code :
Mat skin = curr.GetSkin()
vector<Point> points;
for(int i=0; i<skin.rows; i++)
{
for(int j=0; j<skin.cols; j++)
{
if ((int) skin.at<unsigned char>(i,j) > 0 )
{
Point pt ;
pt.x = j ;
pt.y = i ;
points.push_back(pt);
}
}
}
Mat img(skin.rows, skin.cols, CV_8UC3);
vector<int> hull;
convexHull(Mat(points), hull, true);
Where skin is a Matrix that is filled with 255 and 0 values.
NB : This is inside a loop.
Any suggestion ?
PS : I had the same problem using PCL : As soon as I tried to calculate normals, a heap corruption appeared.