I'm developing an opencv application in java where I need to detect the different marks on the product.I have attached the input image below In that image I need to identify the non veg mark.
Since i'm new to it, I need help to know which concepts can be used for it. I need to identify these marks on the input images
After quite a struggle I was able to come up with a rough solution.
First, I separated the veg and non-veg labels.
Now in order to get the perfect fit of the non-veg label over the image I resized it to a particular level:
small = cv2.resize(nveg, (0,0), fx=0.12, fy=0.12)
Now I performed Template matching as I stated in the comments' section. To learn more about this topic VISIT THIS PAGE.
Using it I obtained the 'maximum probable location' of the non-veg label in the image.
res = cv2.matchTemplate(food, small, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
In the following image pay attention to the bright spot in the position of the non-veg mark:
Now using the max_loc
variable, I added the tuple values to the size of the resized non-veg label and framed it with a rectangle as in the following:
You can see the black spot on the non-veg mark when I labelled it using max_loc
:
Hope this helped. :)