代码拉取完成,页面将自动刷新
同步操作将从 北京智云视图科技有限公司/Mobilenet-SSD-License-Plate-Detection 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import cv2 as cv
import cv2
import numpy as np
import os
from align import *
cvNet = cv2.dnn.readNetFromCaffe("tmp/mssd512_voc.prototxt" , "tmp/mssd512_voc.caffemodel" )
def detect(im):
#im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB)
to_draw = im.copy()
pixel_means=[0.406, 0.456, 0.485]
pixel_stds=[0.225, 0.224, 0.229]
pixel_scale=255.0
rows,cols,c = im.shape
im_tensor = np.zeros((1, 3, im.shape[0], im.shape[1]))
im = im.astype(np.float32)
for i in range(3):
im_tensor[0, i, :, :] = (im[:, :, 2 - i]/pixel_scale - pixel_means[2 - i])/pixel_stds[2-i]
cvNet.setInput(im_tensor)
print(im_tensor.shape)
import time
cvOut = cvNet.forward()
for _ in range(1):
t0 =time.time()
cvOut = cvNet.forward()
print(time.time() -t0)
for detection in cvOut[0,0,:,:]:
score = float(detection[2])
if score > 0.6:
left =int( detection[3] * cols)
top =int( detection[4] * rows)
right = int(detection[5] * cols)
bottom = int(detection[6] * rows)
cropped = to_draw[top:bottom, left:right]
#cropped = align(cropped)
cv2.imshow("cropped" , cropped)
cv2.waitKey(0)
#cv2.rectangle(to_draw, (left,top) , (right,bottom) , (0,255,0) , 1)
cv2.imshow('image' , to_draw)
cv2.waitKey(0)
folderk = ""
for filename in os.listdir(folderk):
path = os.path.join(folderk, filename)
if filename.lower().endswith(".bmp"):
image = cv2.imread(path)
#image = align(image)
detect(image)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。