OpenCv凹凸性缺陷
OpenCv Convexity Defects
我正在通过我在网上找到的一些例子来使用opencv c++ 2.4.4创建凸壳。我正在研究使用凸性缺陷,但遇到了这些类的c++实现问题
我已经按照下面的链接,因为它是最类似于我的问题,但仍然没有运气。在c++中使用OpenCV 2.4计算凸性缺陷
我收到下面的错误。
openCV Error: Assertion failed (mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0)) in create
另外,我在下面粘贴了当前代码。
谢谢你的帮助,
int c = 0;
VideoCapture cap(0);
Mat frame;
Mat edges;
Mat threshold_output;
cv::vector<cv::Vec4i> hierarchy;
std::vector<std::vector<cv::Point> > contours;
RNG rng(12345);
while( c != 27)
{
cap >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
threshold(edges, threshold_output, 100, 255, CV_THRESH_OTSU );
findContours( threshold_output, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
std::vector<Vec4i> defects;
vector<cv::vector<int> >hull( contours.size() );
for (int i = 0; i < contours.size(); i++)
{
convexHull(contours[i], hull[i], false );
if (contours[i].size() >3 )
{
convexityDefects(contours[i], hull[i], defects[i]);
}
}
}
std::vector<Vec4i> defects;
应为
std::vector< std::vector<Vec4i> > defects( contours.size() );
(每个轮廓/船体各一个)
相关文章:
- 当基类是依赖类型时,这是一个缺陷吗
- 在这个函数中是有缺陷的,因为取消引用 null 是无效的,所以我想更改代码
- 这是 basic.def.odr 部分的缺陷吗?
- 代码在 CodeSignal 中工作不正确。不确定这是否是我的代码缺陷
- 当子类需要在 c++ 中相互包含时,继承有缺陷
- 与纯 V8 相比,NodeJS 是否有任何性能缺陷或显著开销?
- 无法打印完整的二叉搜索树,因为我从最低节点向后迭代的逻辑有缺陷
- 为什么在解雇方面没有seg缺陷?unique_ptr
- 将 std::vector<char> 转换为字符* 会导致字符缺陷
- OpenGL 缺陷 - 不需要的插值
- 这个危险指针示例是否因为 ABA 问题而存在缺陷?
- 这是 std::get ( const<T> std::p air<const T, U>& ) 由于 const T 而无法编译的C++缺陷吗?
- clang实现char8_t的方式是否存在缺陷,或者标准的某个黑暗角落是否禁止优化?
- 关于模板参数推理的看似有缺陷的段落?
- 尝试在C++中"blur"矩阵;有缺陷的算法或代码?
- 一个c++凹凸缺陷包装器(OpenCV)
- 如何从OpenCV的凹凸缺陷点画出最小的圆
- 凹凸性缺陷c++ OpenCv
- OpenCv凹凸性缺陷
- OpenCV凹凸缺陷绘图