def test_visualize_bin_contents(): json_file = osp.join(_this_dir, 'data', 'f2.json') bin_contents, work_order = jsk_apc2015_common.load_json(json_file) # work_order is None img = jsk_apc2015_common.visualize_bin_contents(bin_contents) assert_equal(img.shape, (2435, 2067, 3)) assert_equal(img.dtype, np.uint8) # work_order is not None img = jsk_apc2015_common.visualize_bin_contents(bin_contents, work_order) assert_equal(img.shape, (2435, 2067, 3)) assert_equal(img.dtype, np.uint8)
def visualize_stow_json(json_file): """Visualize json file for Stow Task in APC2016. Args: json_file (str): Path to the json file. Returns: dest (~numpy.ndarray): Image of objects in bins and tote. """ bin_contents, tote_contents = _load_stow_json(json_file) # set extra image paths that is added in APC2016 rp = rospkg.RosPack() pkg_path = rp.get_path(PKG) extra_img_paths = {} for entry in get_object_data(): obj = entry['name'] extra_img_paths[obj] = osp.join(pkg_path, 'models', obj, 'image.jpg') # draw bin contents kiva_pod_img = jsk_apc2015_common.visualize_bin_contents( bin_contents, extra_img_paths=extra_img_paths) # draw tote contents tote_img = visualize_stow_contents(tote_contents) # merge two images kiva_w = kiva_pod_img.shape[1] tote_w, tote_h = tote_img.shape[1], tote_img.shape[0] tote_img = cv2.resize(tote_img, (kiva_w, tote_h * kiva_w // tote_w)) dest = np.concatenate((kiva_pod_img, tote_img), axis=0) return dest
def visualize_stow_json(json_file): """Visualize json file for Stow Task in APC2016. Args: json_file (str): Path to the json file. Returns: dest (~numpy.ndarray): Image of objects in bins and tote. """ bin_contents, tote_contents = _load_stow_json(json_file) # set extra image paths that is added in APC2016 rp = rospkg.RosPack() pkg_path = rp.get_path(PKG) extra_img_paths = {} for entry in get_object_data(): obj = entry['name'] extra_img_paths[obj] = osp.join(pkg_path, 'models', obj, 'image.jpg') # draw bin contents kiva_pod_img = jsk_apc2015_common.visualize_bin_contents( bin_contents, extra_img_paths=extra_img_paths) # draw tote contents tote_img = visualize_stow_contents(tote_contents) # merge two images kiva_w = kiva_pod_img.shape[1] tote_w, tote_h = tote_img.shape[1], tote_img.shape[0] tote_img = cv2.resize(tote_img, (kiva_w, tote_h*kiva_w//tote_w)) dest = np.concatenate((kiva_pod_img, tote_img), axis=0) return dest
def visualize_stow_json(json_file): bin_contents, work_order = _load_stow_json(json_file) # draw bin contents kiva_pod_img = jsk_apc2015_common.visualize_bin_contents(bin_contents) # draw tote contents tote_img = visualize_stow_contents(work_order) # merge two images kiva_w,kiva_h = kiva_pod_img.shape[1],kiva_pod_img.shape[0] tote_w,tote_h = tote_img.shape[1],tote_img.shape[0] tote_img = cv2.resize(tote_img,(kiva_w,tote_h*kiva_w//tote_w)) dest = np.concatenate((kiva_pod_img,tote_img),axis=0) return dest
def test_visualize_bin_contents(): json_file = osp.join(_this_dir, 'data', 'f2.json') bin_contents, work_order = jsk_apc2015_common.load_json(json_file) # work_order is None img = jsk_apc2015_common.visualize_bin_contents(bin_contents) assert_equal(img.shape, (2435, 2067, 3)) assert_equal(img.dtype, np.uint8) # work_order is not None img = jsk_apc2015_common.visualize_bin_contents(bin_contents, work_order) assert_equal(img.shape, (2435, 2067, 3)) assert_equal(img.dtype, np.uint8) # extra_img_paths are passed rp = rospkg.RosPack() pkg_path = rp.get_path('jsk_apc2015_common') extra_img_paths = { 'safety_works_safety_glasses': osp.join(pkg_path, 'models/safety_works_safety_glasses/image.jpg') } img = jsk_apc2015_common.visualize_bin_contents( bin_contents, extra_img_paths=extra_img_paths) assert_equal(img.shape, (2435, 2067, 3)) assert_equal(img.dtype, np.uint8)
def visualize_stow_json(json_file): """Visualize json file for Stow Task in APC2016. Args: json_file (str): Path to the json file. Returns: dest (~numpy.ndarray): Image of objects in bins and tote. """ bin_contents, work_order = _load_stow_json(json_file) # draw bin contents kiva_pod_img = jsk_apc2015_common.visualize_bin_contents(bin_contents) # draw tote contents tote_img = visualize_stow_contents(work_order) # merge two images kiva_w = kiva_pod_img.shape[1] tote_w, tote_h = tote_img.shape[1], tote_img.shape[0] tote_img = cv2.resize(tote_img, (kiva_w, tote_h*kiva_w//tote_w)) dest = np.concatenate((kiva_pod_img, tote_img), axis=0) return dest
def visualize_pick_json(json_file): """Visualize json file for Pick Task in APC2016 Args: json_file (``str``): Path to the json file. Returns: kiva_pod_img (~numpy.ndarray): visualized image of listed objects over the Kiva Pod image. """ # load data from json bin_contents, work_order = jsk_apc2015_common.load_json(json_file) # set extra image paths that is added in APC2016 rp = rospkg.RosPack() pkg_path = rp.get_path(PKG) extra_img_paths = {} for entry in get_object_data(): obj = entry['name'] extra_img_paths[obj] = osp.join(pkg_path, 'models', obj, 'image.jpg') # generate visualized image img = jsk_apc2015_common.visualize_bin_contents( bin_contents, work_order, extra_img_paths) return img
def visualize_pick_json(json_file): """Visualize json file for Pick Task in APC2016 Args: json_file (``str``): Path to the json file. Returns: kiva_pod_img (~numpy.ndarray): visualized image of listed objects over the Kiva Pod image. """ # load data from json bin_contents, work_order = jsk_apc2015_common.load_json(json_file) # set extra image paths that is added in APC2016 rp = rospkg.RosPack() pkg_path = rp.get_path(PKG) extra_img_paths = {} for entry in get_object_data(): obj = entry['name'] extra_img_paths[obj] = osp.join(pkg_path, 'models', obj, 'image.jpg') # generate visualized image img = jsk_apc2015_common.visualize_bin_contents(bin_contents, work_order, extra_img_paths) return img