1 | initial version |
Your image #2 was too smaller 6060. You had before was 256256. There is nothing I couldn't do. Code:
#!usr/bin/env python3
import cv2 as cv
import numpy as np
im = cv.imread('holecan.png')
gray=cv.cvtColor(im,cv.COLOR_BGR2GRAY)
img = cv.medianBlur(gray,5)
cimg = cv.cvtColor(img,cv.COLOR_GRAY2BGR)
circles = cv.HoughCircles(img,cv.HOUGH_GRADIENT,
1,300,
param1=40,
param2=20,
minRadius=15,
maxRadius=30)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
cv.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
im = cv.resize(cimg, (320, 240))
cv.imwrite('hole.jpg', cimg)
cv.imshow('detected circles',im)
cv.waitKey(0)
cv.destroyAllWindows()
Output:
2 | No.2 Revision |
Your image #2 was too smaller 6060. 60x60. You had before was 256256. 256x256. There is nothing I couldn't do.
Code:
#!usr/bin/env python3
import cv2 as cv
import numpy as np
im = cv.imread('holecan.png')
gray=cv.cvtColor(im,cv.COLOR_BGR2GRAY)
img = cv.medianBlur(gray,5)
cimg = cv.cvtColor(img,cv.COLOR_GRAY2BGR)
circles = cv.HoughCircles(img,cv.HOUGH_GRADIENT,
1,300,
param1=40,
param2=20,
minRadius=15,
maxRadius=30)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
cv.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
im = cv.resize(cimg, (320, 240))
cv.imwrite('hole.jpg', cimg)
cv.imshow('detected circles',im)
cv.waitKey(0)
cv.destroyAllWindows()
Output: