25 python | 您所在的位置:网站首页 › 场内运输是什么意思 › 25 python |
先可以读读这篇文章 使用 OpenCV 识别 QRCode,介绍了轮廓的概念,很好 http://ju.outofmemory.cn/entry/255695 import cv2 img = cv2.imread('frame.png') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) ret, binary = cv2.threshold(gray,127,255,cv2.THRESH_BINARY) contours, hierarchy = cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) img2 = img cv2.drawContours(img2,contours,10,(0,0,255),3) from matplotlib import pyplot as plt plt.figure() plt.imshow(img2) plt.show()(1, 317, 4)代表317个轮廓,每个轮廓四个属性 原来contours里面保存的是轮廓里面的点,CHAIN_APPROX_SIMPLE代表只保存角点 len(contours) 317 contours[0],type(contours) (array([[[525, 478]]], dtype=int32), list) |
CopyRight 2018-2019 实验室设备网 版权所有 |