Google에 cvCalcPGH()를 사용하는 좋은 예나 윤곽 일치에 프리맨 코드를 사용하는 좋은 예가 없습니다. 문서화하지만 cvCalcPGH()가 실패로 실행됩니다cvCalcPGH with cvFindContours 사용
#include "opencv2/opencv.hpp"
#include "opencv2/legacy/legacy.hpp"
int
main(int argc, char* argv[]) {
IplImage* g_gray = cvLoadImage("lisa.png",CV_LOAD_IMAGE_GRAYSCALE);
cvThreshold(g_gray, g_gray, 100, 255, CV_THRESH_BINARY);
CvMemStorage* storage=cvCreateMemStorage(0);
CvSeq* firstContour=NULL;
int a=cvFindContours(g_gray, storage, &firstContour,sizeof(CvChain),CV_RETR_LIST, CV_CHAIN_CODE);
CvHistogram *hist;
int h_bins = 30, s_bins = 30;
float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 255 };
int hist_size[] = { h_bins, s_bins };
float* ranges[] = { h_ranges, s_ranges };
hist = cvCreateHist(2, hist_size, CV_HIST_ARRAY, ranges, 1);
if(CV_SEQ_ELTYPE(firstContour) != CV_32SC2) {
printf(":(\n");
}
cvCalcPGH((CvSeq *)firstContour,hist);
return 0;
}
cvFindContours() : 그래서 나는 그것을 만들려고
$ ./calcpgh
:(
OpenCV Error: Unsupported format or combination of formats (The contour is not valid or the point type is not supported) in cvCalcPGH, file /Users/tonu-samuel/OpenCV-2.4.2/modules/legacy/src/pgh.cpp, line 351
terminate called throwing an exceptionAbort trap: 6
$
OpenCV의이 2.4.2입니다 내가 확인 CV_SEQ_ELTYPE(contour) != CV_32SC2
입니다) (어설 표시 내 코드에서도. 어떻게 고칠 수 있는지.