実際のところ
import cv2 import numpy as np img = cv2.imread('gauge.jpg') #img = cv2.imread('test3.png') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) edges = cv2.Canny(gray,150,200,apertureSize = 3) lines = cv2.HoughLines(edges,1, 1* np.pi/180,100) print(lines) for rho,theta in lines[0]: a = np.cos(theta) b = np.sin(theta) x0 = a*rho y0 = b*rho #中心線 x1 = 313 y1 = 276 #線 x2 = int(x1 - ( 200 * -b )) y2 = int(y1 - ( 200 * a )) # コンソールに角度を表示 print(int(np.rad2deg(theta))) #線を描画 cv2.line(img,(x2,y2),(x1,y1),(0,0,255),2) # 表示 cv2.imshow("Show BINARIZATION Image", img) cv2.waitKey() cv2.destroyAllWindows()