OpenCV, SIFT: all functions of two different insects coincide

I want to create a classifier to identify an insect by its captured image. The first time I used HuMomemnts, but images shot in different resolutions gave incorrect results, since HuMoments is a large-scale option. After several searches on the Internet, I found that using SIFT and SURF could solve my problem, and so I tried to understand what happens when I use SIFT. The first two images below relate to different types of insects. The results were strange since all of the 400 functions were compared (see 3rd image).

enter image description hereenter image description hereenter image description here

int main() { Mat src = imread(firstInsect); Mat src2 = imread("secondInsect"); if(src.empty() || src2.empty()) { printf("Can not read one of the image\n"); return -1; } //Detect key point in the image SiftFeatureDetector detector(400); vector<KeyPoint> keypoints; detector.detect(src, keypoints); //cout << keypoints.size() << " of keypoints are found" << endl; cv::FileStorage fs(firstInsectXML, FileStorage::WRITE); detector.write(fs); fs.release(); SiftFeatureDetector detector2(400); vector<KeyPoint> keypoints2; detector.detect(src2, keypoints2); cv::FileStorage fs2(secondInsectXML, FileStorage::WRITE); detector.write(fs2); fs2.release(); //Compute the SIFT feature descriptors for the keypoints //Multiple features can be extracted from a single keypoint, so the result is a //matrix where row "i" is the list of features for keypoint "i" SiftDescriptorExtractor extractor; Mat descriptors; extractor.compute(src, keypoints, descriptors); SiftDescriptorExtractor extractor2; Mat descriptors2; extractor.compute(src2, keypoints2, descriptors2); //Print some statistics on the matrices returned //Size size = descriptors.size(); //cout<<"Query descriptors height: "<<size.height<< " width: "<<size.width<< " area: "<<size.area() << " non-zero: "<<countNonZero(descriptors)<<endl; //saveKeypoints(keypoints, detector); Mat output; drawKeypoints(src, keypoints, output, Scalar(0, 0, 255), DrawMatchesFlags::DEFAULT); imwrite(firstInsectPicture, output); Mat output2; drawKeypoints(src2, keypoints2, output2, Scalar(0, 0, 255), DrawMatchesFlags::DEFAULT); imwrite(secondInsectPicture, output2); //Corresponded points BFMatcher matcher(NORM_L2); vector<DMatch> matches; matcher.match(descriptors, descriptors2, matches); cout<< "Number of matches: "<<matches.size()<<endl; Mat img_matches; drawMatches(src, keypoints, src2, keypoints2, matches, img_matches); imwrite(resultPicture, img_matches); system("PAUSE"); waitKey(10000); return 0;} 

Question 1: Why do all functions correspond to these two images?

Question 2: (.xml file i.e.)? How can I store image features so that functions can be stored in order to train them in a classification tree (i.e. a random tree)

+4
source share
2 answers

SIFT essential takes a training image and retrieves items of interest. These points are filtered and the low contrast points are discarded. High contrast points after some calculations are used to describe an object or scene. These essentially ROIs can be used to identify similar patches, even if the uniform scale, orientation, etc. are changed.

We have a few problems here. First, you use SIFT for a non-rigid surface registration. This means that you are trying to classify various errors (intra-group) by their common functions, but in fact it has never been used for this purpose. In addition, the errors are actually quite different and seem to have little in common. Secondly, you are using SIFT with a very low quality input source (low quality points), which is essentially just a binary mask.

If you are experimenting with various methods of registering objects, it is probably recommended that you first use the well-known and widely used toy dataset simplifies your problem and allows you to see what works on simple cases and what doesn’t, after which you return to your real data set.

There are many interesting methods that seem more suitable for registering in a group.

+2
source

You can use the Shape Context , given that you have binary images with fairly clear borders.

+1
source

Source: https://habr.com/ru/post/1482470/


All Articles