def tunnel_x(length, size, pos=None): if pos is None: pos = mc.player.getPos() x, y, z = pos points = taxicab_circle_x(size) for i in range(length): new_points = translate_points(points, x + i, y, z) set_points(new_points, mc, 17)
def tunnel_y(height, size, pos=None): if pos is None: pos = mc.player.getPos() x, y, z = pos points = taxicab_circle_y(size) for i in range(height): new_points = translate_points(points, x, y + i, z) set_points(new_points, mc, 17)
def tunnel_y(height, size, pos=None): if pos is None: pos = mc.player.getPos() x,y,z = pos points = taxicab_circle_y(size) for i in range(height): new_points = translate_points(points, x, y+i, z) set_points(new_points, mc, 17)
def tunnel_x(length, size, pos=None): if pos is None: pos = mc.player.getPos() x,y,z = pos points = taxicab_circle_x(size) for i in range(length): new_points = translate_points(points, x+i, y, z) set_points(new_points, mc, 17)
def get_head_area(img, mask, keypoints): assert img is not None and mask is not None head_point = keypoints[rap.kp_head] neck_point = keypoints[rap.kp_neck] left_elbow = keypoints[rap.kp_left_elbow] right_elbow = keypoints[rap.kp_right_elbow] # @todo: treat case when persons are viewed from the back; the left and right side are reversed if left_elbow[0] > right_elbow[0]: left_elbow, right_elbow = right_elbow, left_elbow # head bounding rect in format: [x, y, w, h] approx_head_brect = [ left_elbow[0], 0, right_elbow[0] - left_elbow[0], neck_point[1] ] head_area_mask = mask[approx_head_brect[1]:approx_head_brect[1] + approx_head_brect[3], approx_head_brect[0]:approx_head_brect[0] + approx_head_brect[2]] contours, _ = cv2.findContours( head_area_mask, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE ) # In recent version (4.1.2.30), this fcn returns two values # no head contours found if len(contours) == 0: return None, None, None head_contour = contours[0] head_contour = utils.translate_points( points=head_contour, translate_factor=(approx_head_brect[0], approx_head_brect[1])) # Find bounding rectangle for HEAD coordinates head_brect = cv2.boundingRect(head_contour) head_mask = np.zeros(mask.shape, dtype=np.uint8) cv2.drawContours(head_mask, [head_contour], -1, (255, 255, 255), -1) # cv2.destroyWindow('head contour') # cv2.imshow('head contour', head_mask) # cv2.waitKey(0) return head_brect, head_contour, head_mask