- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试学习图像特征检测技术。
我已经设法检测到水平线(不间断/连续),但是我无法检测到图像中的所有虚线/断线。
这是我的测试图片,你可以看到有虚线和一些文本/框等。
到目前为止,我使用了以下代码,它只检测到一条虚线。
import cv2
import numpy as np
img=cv2.imread('test.jpg')
img=functions.image_resize(img,1000,1000) #function from a script to resize image to fit my screen
imgGray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
imgEdges=cv2.Canny(imgGray,100,250)
imgLines= cv2.HoughLinesP(imgEdges,2,np.pi/100,60, minLineLength = 10, maxLineGap = 100)
for x1,y1,x2,y2 in imgLines[0]:
cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
cv2.imshow('Final Image with dotted Lines detected',img)
我的输出图像如下。如您所见,我只设法检测到最后一条虚线。我玩过参数 rho、theta、min/max 线,但没有运气。
非常感谢任何建议:)
最佳答案
这个解决方案:
import cv2
import numpy as np
img=cv2.imread('test.jpg')
kernel1 = np.ones((3,5),np.uint8)
kernel2 = np.ones((9,9),np.uint8)
imgGray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
imgBW=cv2.threshold(imgGray, 230, 255, cv2.THRESH_BINARY_INV)[1]
img1=cv2.erode(imgBW, kernel1, iterations=1)
img2=cv2.dilate(img1, kernel2, iterations=3)
img3 = cv2.bitwise_and(imgBW,img2)
img3= cv2.bitwise_not(img3)
img4 = cv2.bitwise_and(imgBW,imgBW,mask=img3)
imgLines= cv2.HoughLinesP(img4,15,np.pi/180,10, minLineLength = 440, maxLineGap = 15)
for i in range(len(imgLines)):
for x1,y1,x2,y2 in imgLines[i]:
cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
cv2.imshow('Final Image with dotted Lines detected', img)
关于python - 仅使用 OpenCV 检测图像中的虚线(断线),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61239652/
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve th
请参阅以下玩具示例。 任何帮助将不胜感激!谢谢! shinyApp( ui = fluidPage( actionButton("btnId", "I want a line break he
我收到如下 JSON 响应: Lorem ipsum ¦dolor sit amet 我想做的是替换所有broken bars (|)。 我尝试过 .replaceAll("\u00A6", "");
我正在尝试学习图像特征检测技术。 我已经设法检测到水平线(不间断/连续),但是我无法检测到图像中的所有虚线/断线。 这是我的测试图片,你可以看到有虚线和一些文本/框等。 到目前为止,我使用了以下代码,
我有一个 json 文件,其中包含一些文本,其中一些文本可能有一些断线 "surchargeNoteText":"Please note \r \n that pre-payments will ta
我正在尝试制作一个 html + css 网站,我试图为一个跨度(具有 .float 类)制作一个正确的 float ,但它打破了一条线,我想知道如何防止它打破一个线?我尝试了 display:inl
我有 2 个 float div,我想将它们放在同一行上,它们加起来超过 1024 像素宽,因此它们需要水平窗口滚动,但尽管它们用 white-space:nowrap;
我是一名优秀的程序员,十分优秀!