How to do the image detection with opencv?
double Detector::getColorDiff(const cv::Mat& current_image, const cv::Mat& target_image) {
auto current_image_color_means = mean(current_image);
auto target_image_color_means = mean(target_image);
double diff = 0;
for (int i = 0; i < 3; i++) {
diff += abs(current_image_color_means.val[i] - target_image_color_means.val[i]);
}
return (diff * 100) / (255 * 3);
}
If 0 <= diff <= 20, we’ll consider it matchs. the smaller the similar.