Convex hull & Heap corruption with openCV
Convex hull & Heap corruption with openCV
我目前正在使用OpenCv开发英特尔感知相机。我可以从相机中获取图像,将它们转换为cv::Mat类型,然后应用皮肤和深度过滤器。现在我想用openCV中的"convexHull"函数来计算凸壳,但它会产生堆损坏。
下面是代码中有趣的部分: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);
其中skin是一个填充了255和0值的矩阵。
注意:这是在循环中。
有什么建议吗?
PS:我在使用PCL时遇到了同样的问题:当我试图计算法线时,出现了堆损坏。
对于堆损坏问题,如果您使用比VS 2010更新的VS,请尝试以下操作:转到VS201中的项目属性?确保配置设置为"所有配置"。然后,在"配置属性->通用->平台工具集"下选择"Visual Studio 2010 (v100)"。Open CV使用v100,因此如果您使用的IDE不支持v100,则存在兼容性问题。
我有同样的问题。内存损坏发生在矢量船体被摧毁的时候。
vector<int>* hull = new vector<int>();
convexHull(Mat(points), *hull, true);
delete hull; //memory corrupted
如果船体先调整尺寸,就能解决这个问题
vector<int> hull;
hull.resize(points.size());
convexHull(Mat(points), hull, true);
相关文章:
- OpenCV RTP-Stream with FFMPEG
- gstreamer with openCV in rpi4
- Compiling OpenCV 3.3 with CUDA 9.0RC
- opencv::meanStdDev with vector<vector<double>>
- Sysmalloc error with opencv
- 构建 OpenCV 时出错:"recompile with -fPIC"
- 断言失败 (size.width>0 && size.height>0) Qt with OpenCV
- Building OpenCV 2.4.11 on Linux with `libopencv_ffmpeg.so`
- AR with OpenCV & OpenGL
- OpenCV C++ with extern "C"
- OpenCV with VS2012 (Qt Support)
- Opencv Mat to opengl with OSVR
- OpenCV v3.1.0 with CRF-RNN
- Problems with OpenCV warpPerspective
- Qt with OpenCV - 下载哪一个
- VideoCapture select timeout with OpenCV 3.0.0-rc1
- OpenGL Support with OpenCV-3.0
- 如何使用 boost::geometry::d istance with opencv cv::P oint.
- Convex hull & Heap corruption with openCV
- Visual Studio with OpenCV:即使程序退出,我也能保持图像窗口打开吗