Image processing 在Python中使用Google Vision API进行徽标检测-一种提高准确性的方法
我试图检测一些手袋图片上的标志使用谷歌视觉API标志检测。然而,性能不是我所期望的。我添加了一些图片的样本和下面的结果,这样你可以得到更好的感觉。 我正在寻找任何可以改善结果的想法。如果你看第2页的最后一张图片(路易斯·维顿包),这个标志有点浮雕,算法无法真正检测到它。这是一个主要问题,我有很多包这种类型的标志图案。 还有,page1的第一个包,彩色通道包的标志太明显了,对比度也很强,但我不知道为什么GV API不能检测到它。请倾诉你的美丽想法,因为我真的需要它们 以下是我使用的代码:Image processing 在Python中使用Google Vision API进行徽标检测-一种提高准确性的方法,image-processing,deep-learning,computer-vision,object-detection,google-vision,Image Processing,Deep Learning,Computer Vision,Object Detection,Google Vision,我试图检测一些手袋图片上的标志使用谷歌视觉API标志检测。然而,性能不是我所期望的。我添加了一些图片的样本和下面的结果,这样你可以得到更好的感觉。 我正在寻找任何可以改善结果的想法。如果你看第2页的最后一张图片(路易斯·维顿包),这个标志有点浮雕,算法无法真正检测到它。这是一个主要问题,我有很多包这种类型的标志图案。 还有,page1的第一个包,彩色通道包的标志太明显了,对比度也很强,但我不知道为什么GV API不能检测到它。请倾诉你的美丽想法,因为我真的需要它们 以下是我使用的代码: im
import io
from google.cloud import vision
from google.oauth2 import service_account
import os
import pandas as pd
import numpy as np
from PIL import Image as Img
import cv2
def get_logo(img_path):
with io.open(img_path, 'rb') as image_file:
content = image_file.read()
image = vision.Image(content=content)
bag_img = Img.open(img_path) #convert the image to PIL
# Detects logo and returns the size of the logo and vertices
response = client.logo_detection(image=image)
annotations = response.logo_annotations
if len(annotations) != 0:
for annotation in annotations:
vects = annotation.bounding_poly.vertices
else:
vects = []
#create a folder to save the cropped images
if not os.path.exists("cropped_logos"):
os.mkdir("cropped_logos")
img_name = img_path.split("\\")[-1].split("_cropped")[0] #store the image name
img_extension = img_path.split("\\")[-1].split(".")[1] # Store the image extension
#Save cropped images in the designated folder
cropped_logo_path = 'cropped_logos\\' + img_name + '_logo' + '.' + img_extension
if len(vects) > 0:
cropped_logo = bag_img.crop([vects[0].x, vects[0].y, vects[2].x - 1, vects[2].y - 1])
cropped_logo.save(cropped_logo_path)
return cropped_logo, cropped_logo_path
else:
return "Couldn't find the logo" , None