def updatePoint(self, event, x, y, flags, param): #blur the image and get a new color if event == cv2.EVENT_LBUTTONUP or event == cv2.EVENT_LBUTTONDOWN: blur_radius = cv2.getTrackbarPos("blur", processed_win) point = (x, y) self.point = point if self.cur_img is None: return blur_img = common.blurImage(self.cur_img, blur_radius) if self.color is None: self.color = blur_img[self.point[1], self.point[0]] self.axes = []
def colorDetect(self, img): #Blur the image to get rid of those annoying speckles blur_radius = cv2.getTrackbarPos("blur", processed_win) radius = cv2.getTrackbarPos("radius", processed_win) open_radius = cv2.getTrackbarPos("open", processed_win) blur_img = common.blurImage(img, blur_radius) if self.color == None and self.point is not None: self.color = blur_img[self.point[1], self.point[0]] print "segmenting color:", self.color return common.colorSegmentation(blur_img, blur_radius, radius, open_radius, self.color)
def starDetect(self, img): #if self.color is None: gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) keypoints = self.detector.detect(gray) #Render the key points n = len(keypoints) if n == 0: print "no key points found" return gray # Average the color of the keypoints avg = numpy.zeros(4) blur_radius = cv2.getTrackbarPos("blur", processed_win) blur_img = common.blurImage(img, blur_radius) for point in keypoints: color = blur_img[point.pt[1], point.pt[0]] avg+=color/float(n) self.color = avg return self.colorDetect(img)