我如何迭代Malloc?(OpenCV)
How do I iterate across malloc? (opencv)
我正在使用此网站的代码
但是,该代码的一部分被删除了。
这是代码的相关部分
CvConvexityDefect* defectArray;
for (; defects; defects = defects->h_next)
{
int nomdef = defects->total; // defect amount
//outlet_float( m_nomdef, nomdef );
//printf(" defect no %d n",nomdef);
if (nomdef == 0)
continue;
// Alloc memory for defect set.
//fprintf(stderr,"mallocn");
defectArray = (CvConvexityDefect*)malloc(sizeof(CvConvexityDefect)*nomdef);
// Get defect set.
//fprintf(stderr,"cvCvtSeqToArrayn");
cvCvtSeqToArray(defects, defectArray, CV_WHOLE_SEQ);
// Draw marks for all defects.
//THIS IS WHERE THE MISTAKE IS
for (int i = 0; //THE REST OF THIS LINE IS MISSING
{ printf(" defect depth for defect %d %f n",i,defectArray[i].depth);
cvLine(img_8uc3, *(defectArray[i].start), *(defectArray[i].depth_point),CV_RGB(255,255,0),1, CV_AA, 0);
cvCircle(img_8uc3, *(defectArray[i].depth_point), 5, CV_RGB(0,0,164), 2, 8,0);
cvCircle(img_8uc3, *(defectArray[i].start), 5, CV_RGB(0,0,164), 2, 8,0);
cvLine(img_8uc3, *(defectArray[i].depth_point), *(defectArray[i].end),CV_RGB(255,255,0),1, CV_AA, 0);
}
如您所见,缺少for循环的一部分。我无法弄清楚如何完成for循环,以便通过 defectArray
我该怎么做?
for (int i = 0; i < nomdef; i++)
相关文章:
- 如果没有malloc,链表实现将失败
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将OpenCV C++重写为EmguCV C#-如何使用指针
- malloc() 可能出现内存泄漏
- OpenCV C++.快速计算混淆矩阵
- Cuda C++:设备上的Malloc类,并用来自主机的数据填充它
- 在C++代码中包含opencv时,使用ctypes创建.so文件
- 哪些库可以通过Opencv调整曝光率
- 安装opencv失败-粘贴CMakeError.log的内容
- C++中的openCV Mat访问冲突
- OpenCV Android C++ imwrite not found
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 无法解决 opencv 代码中的 malloc 错误
- 我如何迭代Malloc?(OpenCV)
- 在C++和OpenCV上出错:"malloc"
- Malloc Error: OpenCV/C++ while push_back Vector