this OOP를 만들려고 했으므로 트랙 바에 대한 콜백 함수를 구현하는 클래스를 만들었습니다. OOP opencv 트랙 바
이
내 클래스class Contours
{
public:
static Mat src_gray;
static int thresh;
Contours(Mat, int);
~Contours(void);
static void callback(int, void*);
private:
};
Contours::Contours(Mat src_gray,int thresh){
this->src_gray=src_gray;
this->thresh=thresh;
}
Contours::~Contours(void){}
void Contours::callback(int, void*)
{int largest_area=0;
int largest_contour_index=0;
Mat canny_output;
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
/// Detect edges using canny
Canny(src_gray, canny_output, thresh, thresh*2, 3);
/// Find contours
findContours(canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
/// Draw contours
Mat drawing = Mat::zeros(canny_output.size(), CV_8UC3);
cout<<contours.size()<<endl;
for(int i = 0; i< contours.size(); i++)
{
double a=contourArea(contours[i],false); // Find the area of contour
if(a>largest_area){
largest_area=a;
largest_contour_index=i; } //Store the index of largest contour
//Scalar color = Scalar(255,255,255);
//drawContours(drawing, contours, i, color, 2, 8, hierarchy, 0, Point());
}
cout<<"cnt maxim: "<<largest_contour_index<<endl;
Scalar color = Scalar(255,255,255);
drawContours(drawing, contours, largest_contour_index, color, 2, 8, hierarchy, 0, Point());
/// Show in a window
namedWindow("Contours", CV_WINDOW_AUTOSIZE);
imshow("Contours", drawing);
//imwrite("sada.png",drawing);
}
내가
오류 5 오류 LNK2001 얻을
createTrackbar(" Canny thresh:", "Source", &thresh, max_thresh, &Contours::callback);
함수를 호출 할 수 있습니다 : 확인되지 않은 외부 기호를 "공공 정적 클래스 이력서 :: 매트 윤곽 :: src_gray "(? src_gray @ Contours @@ 2VMat @ cv @@ A) D : \ Licenta \ 손 기호 인식 \ Algoritmi.obj 손 기호 인식
오류 6 오류 LNK2001 : 확인되지 않은 외부 기호 "공공 정적 INT 윤곽선 :: 타작"D (윤곽 @@ 2HA @ 타작은?) : \ Licenta \ 손
어떤 아이디어 인식에 서명 Algoritmi.obj 손 \ 인식에 서명 왜?
사람들은 링커 오류입니다. 코드가 컴파일되고 아마도 프로젝트 설정 문제 일 것입니다. Visual Studio에서 좋은 점은 오류 코드가 의미하는 바를 찾기 위해 검색 할 수 있다는 것입니다 (예 : LNK2001). – Simon
imgproc 및 highui 라이브러리를 포함 시켰습니까? – GPPK
@GPPK 예, 했어요. –