Ask Your Question

Yash99's profile - activity

2017-07-31 13:38:03 -0500 commented question Fail to divide circle into 8 equal parts

I can detect a pizza but unable to draw slices. Here is my code

import cv2 import cv2.cv as cv

import numpy as np

def main():

img = cv2.imread('testpizza.png',0)



#print(img)



img = cv2.medianBlur(img,5)

cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
circles = cv2.HoughCircles(img,cv.CV_HOUGH_GRADIENT, 1, 50)


circles = np.uint16(np.around(circles))

for i in circles[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.imwrite('detectedcircles',cimg)

cv2.waitKey(0)

cv2.destroyAllWindows()
2017-07-31 12:07:32 -0500 asked a question Fail to divide circle into 8 equal parts

I was trying to write code which detects circle in a pizza and divide circles into 8 equal parts (i.e 8 equal slices angle of 45 degrees). I try using cv2.line() but it is not working.

Can anyone help me out in code to detect slicesimage description

2017-07-19 15:24:29 -0500 asked a question Code to divide pizza into 8 equal slices by using Python Opencv

import cv2 import cv2.cv as cv

import numpy as np

def main():

img = cv2.imread('testpizza.png',0)



#print(img)



img = cv2.medianBlur(img,5)

cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
circles = cv2.HoughCircles(img, cv.CV_HOUGH_GRADIENT, 1, 20, param1=50, param2=30, minRadius=0, maxRadius=0)
#circles = cv2.HoughCircles(img,cv.CV_HOUGH_GRADIENT, 1, 50)


circles = np.uint16(np.around(circles))

for i in circles[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.imwrite('detectedcircles',cimg)

cv2.waitKey(0)

cv2.destroyAllWindows()

Note: It displays circles in a pizza but need to divide the circle into 8 equal slices