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]);
}
}
}