25 python 您所在的位置:网站首页 场内运输是什么意思 25 python

25 python

2022-06-10 18:11| 来源: 网络整理| 查看: 265

先可以读读这篇文章 使用 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()

这里写图片描述

img1 = img cv2.drawContours(img1,contours,-1,(0,0,255),3) from matplotlib import pyplot as plt plt.figure() plt.imshow(img1) plt.show()

这里写图片描述

ls hierarchy.shape (1, 317, 4)

(1, 317, 4)代表317个轮廓,每个轮廓四个属性

原来contours里面保存的是轮廓里面的点,CHAIN_APPROX_SIMPLE代表只保存角点

len(contours) 317 contours[0],type(contours) (array([[[525, 478]]], dtype=int32), list)


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有