如何找到检测到的霍夫线的角度? [英] How to find angle of hough lines detected?

查看:51
本文介绍了如何找到检测到的霍夫线的角度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是使用 open cv 检测骨折的骨头.我尝试了以下代码.并得到了正确的精明检测边缘.还发现了霍夫线.但现在我的工作是检测图像中的断裂点.我不明白如何进一步进行.在一些博客中,我发现我们可以确定 houghlines 的角度来检测那条线不是直线.但不知道如何在我的代码中找到 houghline 的角度.有人可以帮忙吗?

My goal is to detect the fractured bone using open cv. I tried the following code. and got correct canny detection edges.and also found houghlines.But now my job is to detected the fractured spot in the image. Iam not understanding how to proceed further. In some blogs i found the we can determine angle of houghlines to detect that line is not staright. But not knowing how to find angle of houghline in my code. Can someone help?

import cv2
import numpy as np
import math
img = cv2.imread('bone2.jpg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray,100,400,apertureSize =3)
cv2.imshow('canny',edges)
kernel=np.ones((5,5),np.uint8)
boneEdges=cv2.morphologyEx(edges,cv2.MORPH_GRADIENT,kernel)
minLineLength =1000
maxLineGap = 10
lines = cv2.HoughLinesP(boneEdges,1,np.pi/180,100,minLineLength,maxLineGap)

for x1,y1,x2,y2 in lines[0]:
 cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
 slope=(y2-y1),(x2-x1)
 # print('slope',arctan(slope))
cv2.imwrite('houghlines5.jpg',img)
cv2.waitKey(0)

推荐答案

此函数返回一个 rho theta 集列表,其中 theta 是您要查找的角度.以下是文档.

This function returns a list of rho theta sets where theta is the angle you are looking for. Here are the docs.

这篇关于如何找到检测到的霍夫线的角度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆