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

站内推广优书网首页

站内推广,优书网首页,广饶网站制作,网店运营怎么学图形检测 demo1 # 绘制几何图像的轮廓 import cv2img cv2.imread("./shape1.png")gray cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # 将图像二值化 t, binary cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)# 检测图像中的所有轮廓 contours, hierarchy cv2.f…

图形检测

demo1
# 绘制几何图像的轮廓
import cv2img = cv2.imread("./shape1.png")gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# 将图像二值化
t, binary = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)# 检测图像中的所有轮廓
contours, hierarchy = cv2.findContours(binary, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)cv2.drawContours(img, contours, 3, (0, 0, 255), 5)
cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()
demo2
# 绘制花朵的轮廓
import cv2img = cv2.imread("flower.png")cv2.imshow("img", img)
img = cv2.medianBlur(img, 5)gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
t, binary = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)cv2.imshow("binary", binary)contours, hierarchy = cv2.findContours(binary, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
cv2.drawContours(img, contours, -1, (0, 0, 255), 2)
cv2.imshow("contours", img)
cv2.waitKey()
cv2.destroyAllWindows()
demo3
import cv2
# 矩形包围框img = cv2.imread("./shape2.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
t, binary = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)contours, hierarchy = cv2.findContours(binary, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
# 获取第一个轮廓的最小矩形边框
x, y, w, h = cv2.boundingRect(contours[0])
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 2)
cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()
demo4
import cv2
# 圆形包围框
img = cv2.imread("./shape2.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
t, binary = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)contours, hierarchy = cv2.findContours(binary, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
# 获取第一个轮廓的最小矩形边框
center, radius = cv2.minEnclosingCircle(contours[0])
x = int(round(center[0]))
y = int(round(center[1]))
cv2.circle(img, (x, y), int(radius), (0, 0, 255), 2)
cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()
demo5
import cv2
# 凸包
img = cv2.imread("./shape2.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
t, binary = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)contours, hierarchy = cv2.findContours(binary, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
# 获取第一个轮廓的最小矩形边框
hull = cv2.convexHull(contours[0])
cv2.polylines(img, [hull], True, (0, 0, 255), 2)
cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()
demo6
# Canny边缘检测
import cv2img = cv2.imread("flower.png")r1 = cv2.Canny(img, 10, 50)
r2 = cv2.Canny(img, 100, 200)
r3 = cv2.Canny(img, 400, 600)cv2.imshow("img", img)
cv2.imshow("r1", r1)
cv2.imshow("r2", r2)
cv2.imshow("r3", r3)
cv2.waitKey()
cv2.destroyAllWindows()
demo7
# 检测笔图像中出现的直线
import cv2
import numpy as npimg = cv2.imread("./pen.jpg")o = img.copy()o = cv2.medianBlur(o, 5)gray = cv2.cvtColor(o, cv2.COLOR_BGR2GRAY)binary = cv2.Canny(o, 50, 150)lines = cv2.HoughLinesP(binary, 1, np.pi/180, 15, minLineLength=100, maxLineGap=18)for line in lines:x1, y1, x2, y2 = line[0]cv2.line(img, (x1, y1), (x2, y2), (0, 0, 255), 2)cv2.imshow("canny", binary)
cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()
demo8
# 圆环检测
import cv2
import numpy as npimg = cv2.imread("coin.jpg")o = img.copy()
o = cv2.medianBlur(o, 5)
gray = cv2.cvtColor(o, cv2.COLOR_BGR2GRAY)circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 70, param1=100, param2=25, minRadius=10, maxRadius=50)
circles = np.uint(np.around(circles))
for c in circles[0]:x, y, r = ccv2.circle(img, (x, y), r, (0, 0, 255), 3)cv2.circle(img, (x, y), 2, (0, 0, 255), 3)cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()
http://www.mmbaike.com/news/97215.html

相关文章:

  • 做猎头要用的网站知乎关键词推广技巧
  • 电商网站推广常见问题手机优化软件哪个好
  • 微网站与移动开发是做什么的免费广告网
  • 柳市网站建设公司网站怎么收录到百度
  • 如何设计旅游网站百度关键词快速排名方法
  • 网站发展历程nba最新新闻新浪
  • 郑州做品牌网站好的公司seo新人怎么发外链
  • 网站改版多少钱如何制作一个网页链接
  • 手机版网站刷粉网站推广免费
  • 网站建设信息发布搜索引擎优化需要多少钱
  • 做外贸做的很好的网站网站域名ip地址查询
  • 网站顺序优化加速
  • 福建省建设厅网站信用评分怎么注册自己公司的网址
  • 提升网站排名交换免费连接
  • 什么是网站开发中的分页搜索引擎营销有哪些
  • 网上怎么找房屋设计师360seo关键词优化
  • 微网站 微官网的区别淘宝权重查询入口
  • 外贸网站做SEO外贸推广平台哪个好
  • 完善电子商务网站建设自动推广引流app
  • 西安网站建设维护赣州是哪个省
  • 网站开发的业务需求分析网站推广技巧和方法
  • 自己搭建一个网站需要多少钱?网站关键词快速排名软件
  • b2c代表平台有哪些百度优化插件
  • 网站模板免费下载网站seo和点击付费的区别
  • 网站搭建制作公司网页设计师
  • 广州网络营销选择网站seo是干什么的
  • 网站程序调试模式怎么做app制作公司
  • 公司企业网站设计尺寸seo sem是指什么意思
  • 去年做哪个网站致富百度校招
  • 宁波网站制作与推广南京百度快照优化排名