Bonjour à tous!
Alors voilà j'ai une erreur avec les fameux "const" mais même après avoir lu le cours je suis incapable de la résoudre !
Voici le code, l'erreur est en rouge :
fourier_mag.cpp:
fourier_mag.h :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 Vector<fourier_mag::Center> fourier_mag::mag_blob (Mat &img1, Mat &img2, Vector<Center> ¢ers) { fourier_mag::findBlobs(img1, img2, centers); return centers; } // ERREUR : impossible d'initialiser une référence de type "std::vector<cv::SimpleBlobDetector::Center, std::allocator<cv::SimpleBlobDetector::Center>> & "(non qualifié const) avec une valeur de type "const cv::Vector<cv::SimpleBlobDetector::Center>"
features2d.h :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 class fourier_mag : CV_EXPORTS_W SimpleBlobDetector { public: void shiftDFT(Mat& fImage ); Mat create_spectrum_magnitude_display(Mat& complexImg, bool rearrange); Mat DFT_mag(Mat& img); Mat mag_thres(Mat& mag); Vector<Center> mag_blob (Mat &img1, Mat &img2, Vector<Center> ¢ers); }; #endif
blobdetector.cpp:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 class CV_EXPORTS_W SimpleBlobDetector : public FeatureDetector { public: struct CV_EXPORTS_W_SIMPLE Params { CV_WRAP Params(); CV_PROP_RW float thresholdStep; CV_PROP_RW float minThreshold; CV_PROP_RW float maxThreshold; CV_PROP_RW size_t minRepeatability; CV_PROP_RW float minDistBetweenBlobs; CV_PROP_RW bool filterByColor; CV_PROP_RW uchar blobColor; CV_PROP_RW bool filterByArea; CV_PROP_RW float minArea, maxArea; CV_PROP_RW bool filterByCircularity; CV_PROP_RW float minCircularity, maxCircularity; CV_PROP_RW bool filterByInertia; CV_PROP_RW float minInertiaRatio, maxInertiaRatio; CV_PROP_RW bool filterByConvexity; CV_PROP_RW float minConvexity, maxConvexity; void read( const FileNode& fn ); void write( FileStorage& fs ) const; }; CV_WRAP SimpleBlobDetector(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params()); virtual void read( const FileNode& fn ); virtual void write( FileStorage& fs ) const; protected: struct CV_EXPORTS Center { Point2d location; double radius; double confidence; }; virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const; virtual void findBlobs(const cv::Mat &image, const cv::Mat &binaryImage, std::vector<Center> ¢ers) const; Params params; };
Voilà j'espère qu'il y a assez d'éléments !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryImage, vector<Center> ¢ers) const { (void)image; centers.clear(); vector < vector<Point> > contours; Mat tmpBinaryImage = binaryImage.clone(); findContours(tmpBinaryImage, contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE); #ifdef DEBUG_BLOB_DETECTOR // Mat keypointsImage; // cvtColor( binaryImage, keypointsImage, CV_GRAY2RGB ); // // Mat contoursImage; // cvtColor( binaryImage, contoursImage, CV_GRAY2RGB ); // drawContours( contoursImage, contours, -1, Scalar(0,255,0) ); // imshow("contours", contoursImage ); #endif for (size_t contourIdx = 0; contourIdx < contours.size(); contourIdx++) { Center center; center.confidence = 1; Moments moms = moments(Mat(contours[contourIdx])); if (params.filterByArea) { double area = moms.m00; if (area < params.minArea || area >= params.maxArea) continue; } //compute blob radius vector<double> dists; for (size_t pointIdx = 0; pointIdx < contours[contourIdx].size(); pointIdx++) { Point2d pt = contours[contourIdx][pointIdx]; dists.push_back(norm(center.location - pt)); } std::sort(dists.begin(), dists.end()); center.radius = (dists[(dists.size() - 1) / 2] + dists[dists.size() / 2]) / 2.; centers.push_back(center); #ifdef DEBUG_BLOB_DETECTOR // circle( keypointsImage, center.location, 1, Scalar(0,0,255), 1 ); #endif } #ifdef DEBUG_BLOB_DETECTOR // imshow("bk", keypointsImage ); // waitKey(); #endif }
En vous remerciant !
Partager