{"action":"created","issue":{"url":"https://api.github.com/repos/fuenwang/3D-BoundingBox/issues/8","repository_url":"https://api.github.com/repos/fuenwang/3D-BoundingBox","labels_url":"https://api.github.com/repos/fuenwang/3D-BoundingBox/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/fuenwang/3D-BoundingBox/issues/8/comments","events_url":"https://api.github.com/repos/fuenwang/3D-BoundingBox/issues/8/events","html_url":"https://github.com/fuenwang/3D-BoundingBox/issues/8","id":375831047,"node_id":"MDU6SXNzdWUzNzU4MzEwNDc=","number":8,"title":"Scripts using for drawing 3d box, can test with only ground truth","user":{"login":"jinfagang","id":21303438,"node_id":"MDQ6VXNlcjIxMzAzNDM4","avatar_url":"https://avatars3.githubusercontent.com/u/21303438?v=4","gravatar_id":"","url":"https://api.github.com/users/jinfagang","html_url":"https://github.com/jinfagang","followers_url":"https://api.github.com/users/jinfagang/followers","following_url":"https://api.github.com/users/jinfagang/following{/other_user}","gists_url":"https://api.github.com/users/jinfagang/gists{/gist_id}","starred_url":"https://api.github.com/users/jinfagang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jinfagang/subscriptions","organizations_url":"https://api.github.com/users/jinfagang/orgs","repos_url":"https://api.github.com/users/jinfagang/repos","events_url":"https://api.github.com/users/jinfagang/events{/privacy}","received_events_url":"https://api.github.com/users/jinfagang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-10-31T07:24:48Z","updated_at":"2018-11-27T08:02:38Z","closed_at":null,"author_association":"NONE","body":"If anyone wanna test how to using kitti 3D label to draw a box on image, or using the model prediction to draw a final box on image, there is a scripts you can reference:\r\n\r\n```\r\ndef plot_3d_bbox(img, label_info):\r\n    print('current label info: ', label_info)\r\n    alpha = label_info['alpha']\r\n    # theta_ray = label_info['theta_ray']\r\n    box_3d = []\r\n    center = label_info['location']\r\n    dims = label_info['dimension']\r\n    cam_to_img = label_info['calib']\r\n    rot_y = alpha / 180 * np.pi + np.arctan(center[0] / center[2])\r\n    # import pdb; pdb.set_trace()\r\n\r\n    for i in [1, -1]:\r\n        for j in [1, -1]:\r\n            for k in [0, 1]:\r\n                point = np.copy(center)\r\n                point[0] = center[0] + i * dims[1] / 2 * np.cos(-rot_y + np.pi / 2) + (j * i) * dims[2] / 2 * np.cos(\r\n                    -rot_y)\r\n                point[2] = center[2] + i * dims[1] / 2 * np.sin(-rot_y + np.pi / 2) + (j * i) * dims[2] / 2 * np.sin(\r\n                    -rot_y)\r\n                point[1] = center[1] - k * dims[0]\r\n\r\n                point = np.append(point, 1)\r\n                point = np.dot(cam_to_img, point)\r\n                point = point[:2] / point[2]\r\n                point = point.astype(np.int16)\r\n                box_3d.append(point)\r\n\r\n    front_mark = []\r\n    for i in range(4):\r\n        point_1_ = box_3d[2 * i]\r\n        point_2_ = box_3d[2 * i + 1]\r\n        cv2.line(img, (point_1_[0], point_1_[1]), (point_2_[0], point_2_[1]), (0, 255, 0), 1)\r\n        if i == 0 or i == 3:\r\n            front_mark.append((point_1_[0], point_1_[1]))\r\n            front_mark.append((point_2_[0], point_2_[1]))\r\n\r\n    cv2.line(img, front_mark[0], front_mark[-1], (255, 0, 0), 1)\r\n    cv2.line(img, front_mark[1], front_mark[2], (255, 0, 0), 1)\r\n\r\n    for i in range(8):\r\n        point_1_ = box_3d[i]\r\n        point_2_ = box_3d[(i + 2) % 8]\r\n        cv2.line(img, (point_1_[0], point_1_[1]), (point_2_[0], point_2_[1]), (0, 255, 0), 1)\r\n\r\n    return img\r\n\r\n\r\ndef main():\r\n    for f in all_image:\r\n        image_file = os.path.join(image_dir, f)\r\n        calib_file = os.path.join(calib_dir, f.replace('png', 'txt'))\r\n        predi_file = os.path.join(predi_dir, f.replace('png', 'txt'))\r\n        label_file = os.path.join(label_dir, f.replace('png', 'txt'))\r\n        box3d_file = os.path.join(box3d_dir, f.replace('png', 'txt'))\r\n\r\n        image = cv2.imread(image_file, cv2.COLOR_BGR2RGB)\r\n\r\n        with open(label_file, 'r') as f:\r\n\r\n            label_info = dict()\r\n            for l in f.readlines():\r\n                l = l.strip().split(' ')\r\n\r\n                # this angle need a preprocess\r\n                label_info['alpha'] = float(l[3])\r\n                label_info['location'] = np.asarray(l[11: 14], dtype=float)\r\n                label_info['dimension'] = np.asarray(l[8: 11], dtype=float)\r\n                label_info['calib'] = get_calibration_cam_to_image(calib_file)\r\n\r\n                image = plot_3d_bbox(image, label_info)\r\n        cv2.imshow('rr', image)\r\n        cv2.waitKey(0)\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/fuenwang/3D-BoundingBox/issues/comments/441963014","html_url":"https://github.com/fuenwang/3D-BoundingBox/issues/8#issuecomment-441963014","issue_url":"https://api.github.com/repos/fuenwang/3D-BoundingBox/issues/8","id":441963014,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTk2MzAxNA==","user":{"login":"yuyijie1995","id":30818917,"node_id":"MDQ6VXNlcjMwODE4OTE3","avatar_url":"https://avatars0.githubusercontent.com/u/30818917?v=4","gravatar_id":"","url":"https://api.github.com/users/yuyijie1995","html_url":"https://github.com/yuyijie1995","followers_url":"https://api.github.com/users/yuyijie1995/followers","following_url":"https://api.github.com/users/yuyijie1995/following{/other_user}","gists_url":"https://api.github.com/users/yuyijie1995/gists{/gist_id}","starred_url":"https://api.github.com/users/yuyijie1995/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuyijie1995/subscriptions","organizations_url":"https://api.github.com/users/yuyijie1995/orgs","repos_url":"https://api.github.com/users/yuyijie1995/repos","events_url":"https://api.github.com/users/yuyijie1995/events{/privacy}","received_events_url":"https://api.github.com/users/yuyijie1995/received_events","type":"User","site_admin":false},"created_at":"2018-11-27T08:02:38Z","updated_at":"2018-11-27T08:02:38Z","author_association":"NONE","body":"![2018-11-27 11-18-44](https://user-images.githubusercontent.com/30818917/49066995-b8234680-f25d-11e8-8534-84baff8563b8.png)\r\nIt seems that something wrong .. bbox's direction is not right"}}
{"actor":{"display_login":"yuyijie1995"}}