Ask Your Question

Bloc123's profile - activity

2016-01-20 12:04:46 -0600 received badge  Student (source)
2015-10-18 02:33:32 -0600 asked a question Feature Detector SURF

Hello, I am using the SURF feature detection on my image, and am not finding success in getting it to find features be accurate, the image is only masked by the objects contour in the key point detection. Is there anything I could do to the image itself to help SURF getting better accurate feature detection? I had also tried not masking the object, and also tried equalizing the image, but none of it gave me accurate feature detection. None of the key points are are correct at all. Thank you for any suggestions and help!

Update: Okay I tried another image, and the feature detection works pretty good, (updated as third picture), is there any reason on why this is happening in the first picture?

Mat imsource2;
Mat imquery2;

imsource_crop.copyTo(imsource2);
imquery.copyTo(imquery2);

imshow("test", imsource2);
imshow("test2", imquery2);

Ptr<SURF> detector = SURF::create();
detector->setHessianThreshold(threshHaus);

vector<KeyPoint> keypoints_1, keypoints_2;
Mat descriptors_1, descriptors_2;

detector->detect(imsource2, keypoints_1, imsource_mask);
detector->detect(imquery2, keypoints_2, imquery_mask);

detector->compute(imsource2, keypoints_1, descriptors_1);
detector->compute(imquery2, keypoints_2, descriptors_2);

FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match(descriptors_1, descriptors_2, matches);

double max_dist = 0;
double min_dist = minHaus / 1000;

//-- Quick calculation of max and min distances between keypoints
for (int i = 0; i < descriptors_1.rows; i++)
{
    double dist = matches[i].distance;
    if (dist < min_dist) min_dist = dist;
    if (dist > max_dist) max_dist = dist;
}

printf("-- Max dist : %f \n", max_dist);
printf("-- Min dist : %f \n", min_dist);

//-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )

vector< DMatch > good_matches;

for (int i = 0; i < descriptors_1.rows; i++)
{
    if (matches[i].distance < 0.1)
    {
        good_matches.push_back(matches[i]);
    }
}

Mat img_matches;
drawMatches(imsource2, keypoints_1, imquery2, keypoints_2,
    good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
    vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);

cout << " Source Keypoint number:  " << keypoints_1.size() << endl;
cout << " Query Keypoint number: " << keypoints_2.size() << endl;
cout << "Number of good matches: " << good_matches.size() << endl;
//-- Show detected matches
imshow("Feature", img_matches);

image description

image description

image description

2015-10-12 04:38:03 -0600 commented question Feature Detector

Oh I see, I think I've got it now thanks you so much! I really appreciated your time and effort to help me. So basically what the URL i was following was doing was pretty much straining itself to match something, even though there wast a clear match right? I feel silly for not seeing that earlier. thank you again!

2015-10-12 04:04:39 -0600 commented question Feature Detector

Hey Berger! thanks for your quick reply, I have tried adding in the distance mathicng like you suggested using this as my guide. But now it seems to have made it a harder to detect, although as I increase the thresh to 4000, I get around 3 mathcing lines. but those matches are really really accurate, while with the 2nd image (skull), I am still getting a lot of matches :S

2015-10-12 03:14:01 -0600 asked a question Feature Detector

Hello, I am trying to compare two objects between each other, but am actually I am having a god at folowing this.

In the iamges I have uploaded beloew, the first one shows some similarities which is good, but when I run another image throrugh that looks nothing like the each other, I also get these matching lines? Is there something I am missing?

UPDATES IMAGES

image description

image description

UPDATED

    Mat imsource2;
Mat imquery2;

imsource_crop.copyTo(imsource2);
imquery.copyTo(imquery2);

Ptr<SURF> detector = SURF::create();
detector->setHessianThreshold(threshHaus);

std::vector<KeyPoint> keypoints_1, keypoints_2;
Mat descriptors_1, descriptors_2;

detector->detect(imsource2, keypoints_1, imsource_mask);
detector->detect(imquery2, keypoints_2, imquery_mask);

detector->compute(imsource2, keypoints_1, descriptors_1);
detector->compute(imquery2, keypoints_2, descriptors_2);

FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match(descriptors_1, descriptors_2, matches);

double max_dist = 0; double min_dist = 100;

//-- Quick calculation of max and min distances between keypoints
for (int i = 0; i < descriptors_1.rows; i++)
{
    double dist = matches[i].distance;
    if (dist < min_dist) min_dist = dist;
    if (dist > max_dist) max_dist = dist;
}

printf("-- Max dist : %f \n", max_dist);
printf("-- Min dist : %f \n", min_dist);

//-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
std::vector< DMatch > good_matches;

for (int i = 0; i < descriptors_1.rows; i++)
{
    if (matches[i].distance < 3 * min_dist)
    {
        good_matches.push_back(matches[i]);
    }
}

Mat img_matches;
drawMatches(imsource2, keypoints_1, imquery2, keypoints_2,
    good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
    vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);


//-- Show detected matches
imshow("Feature", img_matches);

Thank you!

2015-10-10 03:49:49 -0600 received badge  Editor (source)
2015-10-10 03:49:35 -0600 asked a question Telling apart differences

Hello, I just wanted some advice on different methods that would be able to tell the differences between two objects. 1st Object - Mask and Canny image description

2nd Object - Mask and Canny image description

EDIT: Grey scale image image description

These shapes are never the same and when they are they same, the mask and canny are never exactly the same. What are some good methods to get a general yet specific features from both object to compare?

thank you!

2015-09-29 21:06:48 -0600 asked a question line detection

image description

Hello, I was wondering if there was a better, more accurate way for detecting that line in my image above? It can detect it fine there, but sometimes, depending on the threshold value of both he canny and the HoughLines, the line does not come up consistently, I was going to make a loop to test it over several threshold values, but though I would turn to you guys to see if there is a better more accurate way of doing this? Thank you

2015-09-07 09:30:12 -0600 asked a question Detecting small differences in objects

Hello, I am fairly new to OpenCV library and was wondering what would be the best method find small differences in two images?

What I am working on is a software that detect small differences between two objects, although the compared object may not be fully completed yet, I have made two mock-ups of this and attached it below. Trying to get my program to detect that the object is the same, at the same time detecting that is is different.

I am planning on mainly using matchShapes, but am worried how well it would do with real world images. But I plan to divide my object into parts starting from the bottom, and matching it with the original image.

So what I am asking is if there is a method that I may have missed that you would recommend me looking. any help or ideas would be very greatly appreciated!

This would be the original image: image description

and this would be the compared image: image description

2015-09-04 04:15:13 -0600 received badge  Enthusiast
2015-08-31 00:27:05 -0600 asked a question Comparing Same object for small differences

Img1 Img2

Hello, I was wondering what are the best methods in detecting the small shift difference in these two objects?

thank you.