当前位置: 首页 > news >正文

网站建设情况说明网页设计的网网页设计的网站

网站建设情况说明,网页设计的网网页设计的网站,李沧做网站,电子商务以后的就业方向一、找轮廓 cv2.findContours() contours,hierarchy cv2.findContours(image*,mode*,method*) contours#xff1a;找到的所有轮廓数组#xff0c;数组内的元素为轮廓像素点坐标。 hierarchy#xff1a;轮廓间的层次关系。 image#xff1a;二值图像#xff08;cv2.t…一、找轮廓 cv2.findContours() contours,hierarchy cv2.findContours(image*,mode*,method*) contours找到的所有轮廓数组数组内的元素为轮廓像素点坐标。 hierarchy轮廓间的层次关系。 image二值图像cv2.threshold()。 mode轮廓检测模式常见方法如下 模式值解释RETR_EXTERNAL0只检测外部轮廓RETR_LIST1检测所有轮廓但不建立层级关系RETR_CCOMP2检测所有轮廓同时建立两个层级关系如果内部还有轮廓则此轮廓与最外层轮廓同级RETR_TREE3检测所有轮廓同时建立一个树状层级关系 method保存轮廓的方法常见方法如下 方法值解释CHAIN_APPROX_NONE1存储所有轮廓点坐标CHAIN_APPROX_SIMPLE2只保存轮廓顶点坐标CHAIN_APPROX_TC89L13使用CHAIN_APPROX_TC89L1 近视算法保存轮廓坐标CHAIN_APPROX_TC89KCOS4使用CHAIN_APPROX_TC89KCOS近视算法保存轮廓坐标 二、绘轮廓 cv2.drawContours() img cv2.drawContours(image*,contours,contourIdx*,color*,thickness*,lineType*,hierarchy*,maxLevel*,offset*)img目标图像。 image二值图像用于填画上轮廓。 contourscv2.findContours()函数返回的轮廓列表 list。 contourIdx需要绘制的轮廓在轮廓列表中的索引。-1 表示绘制列表中的所有轮廓。 colorBGR颜色。 thickness轮廓粗细-1 表示实心。 lineType线条类型。 hierarchycv2.findContours() 输出的层次关系。 maxLevel轮廓层次关系的深度0表示绘制第0层次关系的轮廓。 offset常数值轮廓偏移量相较于原轮廓坐标 三、检测模式  3.1 外轮廓 RETR_EXTERNAL import cv2 # 图像前处理 img cv2.imread(contours.png) # 原图 img_gray cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # GRAY thresh,img_threshold cv2.threshold(img_gray,150,255,cv2.THRESH_BINARY) # 二值contours,hierarchy cv2.findContours(img_threshold,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) img1 cv2.drawContours(img,contours,-1,(255,0,0),3)cv2.imshow(img,img) cv2.imshow(img_threshold,img_threshold) cv2.waitKey(0) cv2.destroyAllWindows() 3.2 所有轮廓 cv2.RETR_LIST import cv2 # 图像前处理 img cv2.imread(contours.png) # 原图 img_gray cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # GRAY thresh,img_threshold cv2.threshold(img_gray,150,255,cv2.THRESH_BINARY) # 二值contours,hierarchy cv2.findContours(img_threshold,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) img1 cv2.drawContours(img,contours,-1,(255,0,0),2)cv2.imshow(img,img) cv2.imshow(img_threshold,img_threshold) cv2.waitKey(0) cv2.destroyAllWindows() 3.3 RETR_CCOMP import cv2 import numpy as np# 图像前处理 img cv2.imread(m.png) # 原图 img_gray cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # GRAY thresh,img_threshold cv2.threshold(img_gray,150,255,cv2.THRESH_BINARY) # 二值contours,hierarchy cv2.findContours(img_threshold,cv2.RETR_CCOMP,cv2.CHAIN_APPROX_SIMPLE) print(hierarchy) img1 cv2.drawContours(img,contours,-1,(255,0,0),2)cv2.imshow(img,img) cv2.imshow(img_threshold,img_threshold) cv2.waitKey(0) cv2.destroyAllWindows() hierarchy详细解释请参考《OpenCV计算机视觉项目实战Python版---p265》 print(hierarchy)结果 [[[ 1 -1 -1 -1][-1 0 2 -1][ 3 -1 -1 1][-1 2 -1 1]]] 3.4 RETR_TREE import cv2 import numpy as np# 图像前处理 img cv2.imread(m.png) # 原图 img_gray cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # GRAY thresh,img_threshold cv2.threshold(img_gray,150,255,cv2.THRESH_BINARY) # 二值contours,hierarchy cv2.findContours(img_threshold,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) print(hierarchy) img1 cv2.drawContours(img,contours,-1,(255,0,0),2)cv2.imshow(img,img) cv2.imshow(img_threshold,img_threshold) cv2.waitKey(0) cv2.destroyAllWindows() hierarchy详细解释请参考《OpenCV计算机视觉项目实战Python版---p265》 print(hierarchy) 结果 [[[-1 -1 1 -1][ 3 -1 2 0][-1 -1 -1 1][-1 1 -1 0]]] 四、轮廓面积、周长 4.1 面积 cv2.contourArea() area cv2.contourArea(contour*,oriented*) area轮廓面积。 countour要计算轮廓。 oriented默认为False换回面积的绝对值。 import cv2 import numpy as np# 图像前处理 img cv2.imread(contours.png) # 原图 img_gray cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # GRAY thresh,img_threshold cv2.threshold(img_gray,150,255,cv2.THRESH_BINARY) # 二值contours,hierarchy cv2.findContours(img_threshold,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) img1 cv2.drawContours(img,contours,-1,(255,0,0),2) areas [] for i in range(len(contours)):area cv2.contourArea(contours[i])areas.append(area) print(areas) cv2.waitKey(0) cv2.destroyAllWindows() [8500.5, 15986.0, 11396.0, 11560.0, 7136.5] 4.2  面积 cv2.arcLength() arc cv2.arcLength(contours,closed*) arc轮廓周长。 countours要计算轮廓。 closedTure表示轮廓是封闭的。 import cv2 import numpy as np# 图像前处理 img cv2.imread(contours.png) # 原图 img_gray cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # GRAY thresh,img_threshold cv2.threshold(img_gray,150,255,cv2.THRESH_BINARY) # 二值contours,hierarchy cv2.findContours(img_threshold,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) img1 cv2.drawContours(img,contours,-1,(255,0,0),2) areas [] for i in range(len(contours)):arc cv2.arcLength(contours[i],closedTrue)areas.append(arc) print(areas) cv2.waitKey(0) cv2.destroyAllWindows() [437.9482728242874, 492.6173119544983, 696.3086559772491, 403.98989498615265, 558.1147834062576]
http://www.tj-hxxt.cn/news/130954.html

相关文章:

  • 南京装饰公司网站建设流量精灵
  • 网站开发标准建设网站的软件
  • 企业官网网站建设报价安装discuz x 3.1 网站虚拟主机的要求
  • 小程序网站建设y021长沙网站建设费用
  • 满城区城乡建设局网站百度竞价推广代运营话术
  • 无锡网站关键词优化软件咨询广告营销案例100例
  • 福州建设人才网站南京知名网站建设公司
  • 广东汽车品牌网站建设长沙网上商城开发
  • 想自己做个公司网站不知道怎么做阿里云备案 网站备案域名
  • 西安网站设计开发人才淘宝客 wordpress网站
  • 大理网上商城网站建设新浪网站用什么语言做的
  • 摄影作品投稿网站学做网站论坛vip共享
  • 网站开发用什么工具好英文网站标题字体
  • 网站图片加载优化怎么用动图做网站背景
  • 如何给网站做外部优化怎么优化一个网站
  • 自己使用原生php做网站性能江苏省建设主管部门网站
  • 用境外服务器做网站精品资料
  • 上海网站设计开发网站备案产品信息错误
  • 网站建设百度推广企业网站备案号密码忘记
  • 模具公司网站中品质见证怎么做人力资源公司名称大全简单大气
  • 一般网站的后台网上书店网站建设方案策划
  • 数据库与网站建设网络推广方案撰写
  • 网站建设四川推来客网站系统广告公司简介简短大气
  • 长沙公司网站的建设站长工具国产2023
  • 镇江网站优化哪家好如何在建设部网站查企业资质
  • 科技部网站建设合同成都专业网站建设价格低
  • 网站建设与单位干部作风的关系做网站如何盈利
  • html 手机网站开发网站建设用哪个好
  • 网站环境搭建做视频搬运哪个网站最赚钱
  • 北京出名做网站的公司wordpress超级排版