나는이 자른 이미지에서 houghcircles()를 사용하여 작은 원을 탐지하려고합니다. houghCircles (OpenCV)를 사용하여 작은 원을 감지했습니다.
그리고 : 나는 그것의 매개 변수를 변경하려하지만 난 50 위 PARAM2을 증가시키고 그 값이 100보다 작은 경우 maxRadius 또한 오류를 얻을 지금은하지만 나쁜 성능을 실행하면이 오류를 얻을 수 이 원본 이미지 이 결과 이미지 :
그리고 이것은 내 코드입니다 :
from imutils.perspective import four_point_transform
from imutils import contours
import numpy as np
import argparse
import imutils
import cv2
im = cv2.imread('crop.png')
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray, 200, 255,cv2.THRESH_BINARY)
cimg = cv2.cvtColor(thresh,cv2.COLOR_GRAY2BGR)
c = cv2.HoughCircles(thresh, cv2.HOUGH_GRADIENT, 0.5, 41, param1=70,
param2=30, minRadius=10,maxRadius=175)
c = np.uint16(np.around(c))
for i in c[0,:]:
# draw the outer circle
cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
# draw the center of the circle
cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
cv2.namedWindow('img',cv2.WINDOW_NORMAL)
cv2.resizeWindow('img', 800,800)
cv2.imshow('img',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()
, 내가 어떻게이 매개 변수를 변경해야하세요?
이 도움을 주셔서 감사합니다 :) 도움이 있지만, 그것은 나에게 오류 제공 :'contours.sort (키 = 람다 X : cv2.boundingRect (X) [0]) 형식 오류를 ' = 10 출처 = cv2.boundingRect (윤곽) 반환 tolerance_factor ((: 키 '내가이 기능'데프 get_contour_precedence (윤곽, COLS)를 추가 그것은 나를 위해 일한 ' –
감사 작정이 기능에 대해 잘못된 키워드 인수는 원점 [1] // tolerance_factor) * tolerance_factor) * cols + origin [0]' –
등고선 + minEnclosingC를 사용하는 것이 좋습니다. ircle 함수를 선택하고 원 경계/면적을 검출 된 윤곽과 비교하여 비원 형상을 필터링합니다 – Micka