简体   繁体   中英

OpenCV - Identifying particular object in image using Java

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. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM