Celebrandil / CudaSift

A CUDA implementation of SIFT for NVidia GPUs (1.2 ms on a GTX 1060)
MIT License
860 stars 285 forks source link

No matches found with pictures of same area but with slight perspective shift. #65

Closed HaiderAbasi closed 5 years ago

HaiderAbasi commented 5 years ago

Matcher Works where the images just have an affine shift in my opinion like if image was translated,rotated or resized but when there is a perspective transformation it fails giving 0 matches. 1) Either good features were not extracted. 2) Maybe Ransac Failed. 3) OpenCv SiftCpu version easily finds the matches and computes a homography matrix even OpenCV SurfGPU find the matches in these images. Need Someone to explain to me why matcher is not working 231_M2_921_M3_Match_1 match_result_1 match_result_2 231_M2_921_M3_Match_0

and how can i resolve it?

Celebrandil commented 5 years ago

Do you mind uploading the images and the parameters you used for the matching code? It seems weird, but maybe there is some logical explanation.

HaiderAbasi commented 5 years ago

@Celebrandil Link To the images. https://jmp.sh/8IvnR76

Parameters for SiftFeaturesDetection int numOctaves = 5; / Number of octaves in Gaussian pyramid / // 5 float initBlur = 1.0f; / Amount of initial Gaussian blurring in standard deviations / float thresh = 3.5f; / Threshold on difference of Gaussians for feature pruning /// 3.5 default float minScale = 0.0f; / Minimum acceptable scale to remove fine-scale features /// default 0.0 bool upScale = false; / Whether to upscale image before extraction /

Parameters for finding Homography FindHomography(siftData1, homography, &numMatches, 10000, 0.0f, 0.80f, 5.0);// max amb 0.80 int numFit = ImproveHomography(siftData1, homography, 5, 0.00f, 0.80f, 3.0);

Celebrandil commented 5 years ago

I would recommend you to change the maxAmbiguity parameter from 0.80f to 0.90f or even up to 1.00f to completely disregard it. The parameter sets the threshold for how similar two possible matches are allowed to be for a match to be accepted. For man-made structures where you have many corners that look similar (such as houses) and when you have a lot of features, you have lots of similar structures and it's too harsh to set the parameter to 0.80f. I believe that In OpenCV you don't have such a test at all unless you implement it yourself. I get about 800 matches or so, which seems a bit few. I might look at it a bit deep later. My hunch is that there are loads of false positive matches due to the similarities between structures.

HaiderAbasi commented 5 years ago

Changing the max ambiguity parameter improved the results considerably. 800 matches is much better than none.Increasing max ambiguity to more than or equal to 1 starts getting lesser matches 0.9 seems optimal at this stage Would now try comparing the homography computed from the SiftCPU Version and upload the results for comparison. Thank you for the effort btw.

Celebrandil commented 5 years ago

No problem. I'm looking forward to hearing about your comparison.