Because images looks very similar you could try matchTemplate. Cross Correlation is quite invariant to brightness variation and using TM_CCORR_NORMED method you can get a 0..1 score for the matching.
Using this code I get score=91.6%
comparing your images and score=79.4%
comparing 2 completely different images.
int main()
{
Mat img1, img2;
img1=imread("img1.jpg");
img2=imread("img2.jpg");
//with TM_CCORR, normalization doesn't improve score so much
//but convert to gray improves speed
cvtColor(img1, img1, CV_BGR2GRAY);
cvtColor(img2, img2, CV_BGR2GRAY);
//resize to the smallest
//resize big images to improve speed
//this steps can be optimized
if (img1.size().area() < img2.size().area())
cv::resize(img2, img2, img1.size());
else
cv::resize(img1, img1, img2.size());
if (img1.size().area() > 800 * 800)
{
cv::resize(img1, img1, Size(0, 0), 0.5, 0.5);
cv::resize(img2, img2, Size(0, 0), 0.5, 0.5);
}
Mat matchResult(Size(1, 1), CV_32F);
matchTemplate(img1, img2, matchResult, TM_CCORR_NORMED);
double score = matchResult.at<float>(0, 0);
// Sincerely match 2 completely different images gives score~0.8
if (score > 0.9)
cout << "Match with score " << 100.0*score << "%" << endl;
else
cout << "NOT match. score =" << 100.0*score << "%" << endl;
return 0;
}
This seems a Bag of Visual words - solvable problem. Tons of guides showing you how to do that!
Do I need to train the vocabulary for BoW descriptor
Yep you do :)