Avatar ·

Improving Coca-Cola can recognition algorithm: how to increase accuracy?

Hi everyone! I'm a beginner C++ developer working on a project to recognize Coca-Cola cans in images. I'm using OpenCV. Currently I have a simple algorithm that looks for contours and tries to match them against a reference by color and shape. But the accuracy is terrible — on a test set of 50 images, only 30-40% of cans are correctly recognized. Problems occur with different lighting, can rotation, presence of reflections, or partial occlusion. Here's my current code (simplified): ```cpp #include #include int main() { cv::Mat img = cv::imread("test.jpg"); cv::Mat hsv; cv::cvtColor(img, hsv, cv::COLOR_BGR2HSV); // Masks for red color of the can (two ranges due to HSV specifics) cv::Mat mask1, mask2; cv::inRange