欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 建筑 > 10.31OpenCV_图像预处理习题

10.31OpenCV_图像预处理习题

2025/11/7 8:50:28 来源:https://blog.csdn.net/gs1we1/article/details/143439951  浏览:    关键词:10.31OpenCV_图像预处理习题

实现在图片里截取车牌并识别车牌内容

import cv2
import numpy as np
import paddlehub as hubdef get_text():img = cv2.imread("images/car.png")#加载模型ocr = hub.Module(name="chinese_ocr_db_crnn_server")#识别文本results = ocr.recognize_text(images=[img])for result in results:data = result['data']for x in data:print('文本: ', x['text'])if __name__ =="__main__":get_text()img = cv2.imread("images/car.png")hsv_img = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)lower = np.array([100,100,50])
height = np.array([140,255,255])mask = cv2.inRange(hsv_img,lower,height)ret,t_img = cv2.threshold(mask,20,255,cv2.THRESH_BINARY)myList,c = cv2.findContours(t_img,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)bgr_img = cv2.cvtColor(t_img,cv2.COLOR_GRAY2BGR)out_img = cv2.drawContours(bgr_img,myList,-1,(0,255,0),1);
for c in myList:x,y,w,h = cv2.boundingRect(c)if w > 100 and h >50:cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 1)cai_img = img[y:y + h, x:w + x]
cv2.imshow("a", cai_img)
cv2.waitKey(0)
cv2.destroyAllWindows()

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词