Tuesday, 15 September 2015

python-opencv, finding centroid of an image -



python-opencv, finding centroid of an image -

i studying pattern recognition. study purpose, extracted faces bunch of images, , meaningful features out of them. tried find centroid of each face image. however, of images, centroid coordinate (0,0). part of code used find centroid following:

################# find centroid of each faces ################# ret, threshold = cv2.threshold(image, 255/2, 255, cv2.thresh_binary) cont, hier = cv2.findcontours(threshold, 1, 2) moment = cv2.moments(cont[0]) if moment['m00'] == 0: m00 = 0.01 else: m00 = moment['m00'] cx, cy = int(moment['m10']/m00), int(moment['m01']/m00) ###################################################################

i assigning m00 = 0.01 because of value moment['m00'] gives zero. question doing right find centroid of image?? , if is, why of centroid (0,0)?? thought since each image not blank image, centroid coordinate should non-zero coordinate. thanks.

opencv

No comments:

Post a Comment