def test_load_json(): json_file = osp.join(_this_dir, 'data', 'f2.json') bin_contents, work_order = jsk_apc2015_common.load_json(json_file) assert_true(isinstance(bin_contents, dict)) assert_equal(bin_contents.keys(), ['f']) assert_true(isinstance(work_order, dict)) assert_equal(work_order.keys(), ['f'])
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 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_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