遍历整图查找蝴蝶位置
2018/04/22
训练模型对于识别背景和蝴蝶有比较好的效果,基本对不会识别错误,接下来,将通过整图遍历的原始而又野蛮的方式对一张原始图片进行处理,进而查找到蝴蝶的具体位置。具体思路如下图。对原图进行缩放成理想大小,例如,
最小边长缩放为227*6像素,最大边长等比缩放:
设置滑动窗大小为227*227像素
设置滑动窗移动步长为
# 自动step_size
scale =min(img.shape[0],(227*6.0)/img.shape[1])*1.0
step_size = int(min(img.shape[0]*scale,img.shape[1]*scale))/20
print("scale",img.shape[0]*scale,img.shape[1]*scale)
#resize image
scale_img = cv2.resize(img,((int(img.shape[1] * scale), int(img.shape[0] * scale))))
然后通过模型预测每个滑动框的类别,若是蝴蝶(类别1)的概率大于99%,则记录滑动框位置,其后绘制在图片上
具体代码:
# 自动step_size
scale =min(img.shape[0],(227*6.0)/img.shape[1])*1.0
print(scale)
step_size = int(min(img.shape[0]*scale,img.shape[1]*scale))/20
print("scale",img.shape[0]*scale,img.shape[1]*scale)
#resize image
scale_img = cv2.resize(img,((int(img.shape[1] * scale), int(img.shape[0] * scale))))
temp2=scale_img[:]
print(scale_img.shape,temp2.shape,img.shape)
while x+227 < img.shape[0]*scale:
while y+227 <

目标检测第一步&spm=1001.2101.3001.5002&articleId=80043167&d=1&t=3&u=c10db0b50fd64665acaf312e0153904a)
4万+

被折叠的 条评论
为什么被折叠?



