Exemple #1
0
 def find_skin(self, img):
     img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
     mask = hsv_filter_mask(img_hsv)
     back_proj = calc_back_proj(img_hsv, self.hist.hist, hsv=True)
     back_proj &= mask
     skin_bin = cv2.threshold(back_proj, self.skin_threshold, 255, cv2.THRESH_BINARY)
     return (back_proj, skin_bin[1])
Exemple #2
0
 def get_contours(self, img, req):
     img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
     #if req.color == 'yellow':
         #Yellow Hue area tended to appear past the cube's area, so for Y. cubes move min. Saturation up to YELLOW_HSV_LOW[1]
         #mask = hsv_filter_mask(img_hsv, hsv_range_low = YELLOW_HSV_LOW)
     #else:
     mask = hsv_filter_mask(img_hsv, self.hsv_range_min[req.color], self.hsv_range_max[req.color])
     back = calc_back_proj(img_hsv, self.known_histograms[req.color][1].hist, True)
     back &= mask
     back_filt = cv2.medianBlur(back, 5)
     back_filt = back.copy()
     conts = cv2.findContours(back_filt, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
     if DEBUG:
         conts_img = self.img.copy()
     else:
         conts_img = None
     return conts, conts_img, back, back_filt
Exemple #3
0
 def calc_hist_from_fore(self, img, img_fore):
     hist = Histogram()
     hist.calc(img, user_mask = img_fore)
     back_proj = calc_back_proj(img, hist.hist)
     back_proj &= img_fore
     cv2.imwrite('img_back_%03d.png' % self.depth_frame_cnt, back_proj)