Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visualization in R0 #5

Open
Sondosmohamed1 opened this issue Nov 28, 2023 · 0 comments
Open

visualization in R0 #5

Sondosmohamed1 opened this issue Nov 28, 2023 · 0 comments

Comments

@Sondosmohamed1
Copy link

Sondosmohamed1 commented Nov 28, 2023

Thank you very much for the great work. I wonder if there is source code that represents the visualization in S0 and S1 for the R0. I was trying to visualize the projected key point, but I got the wrong projection. I have attached my code.

import cv2
import json
import numpy as np
open("/home/sun/Downloads/a9_dataset_r00_s02/_labels/1616762521_089000000_s40_camera_basler_south_50mm.json", "r") as file:
data = json.load(file)

image=cv2.imread("/home/sun/Downloads/a9_dataset_r00_s02/_images/1616762521_089000000_s40_camera_basler_north_50mm.jpg")

for label in data["labels"]:

box3d_projected = label["box3d_projected"]
print("this is projected boxes ", box3d_projected)


points_order = [
    "bottom_left_front", "bottom_right_front", "top_right_front", "top_left_front",
    "bottom_left_back", "bottom_right_back", "top_right_back", "top_left_back"
]


corners_3d_img = np.array([box3d_projected[point] for point in points_order], dtype=np.float32)


corners_3d_img = corners_3d_img.reshape((-1, 1, 2))


scale_factor = 1000
corners_3d_img = (corners_3d_img * scale_factor).astype(np.int32)



color = (0, 255, 0) 
thickness = 2
cv2.line(image, tuple(corners_3d_img[0, 0]), tuple(corners_3d_img[1, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[1, 0]), tuple(corners_3d_img[2, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[2, 0]), tuple(corners_3d_img[3, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[3, 0]), tuple(corners_3d_img[0, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[4, 0]), tuple(corners_3d_img[5, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[5, 0]), tuple(corners_3d_img[6, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[6, 0]), tuple(corners_3d_img[7, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[7, 0]), tuple(corners_3d_img[4, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[0, 0]), tuple(corners_3d_img[4, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[1, 0]), tuple(corners_3d_img[5, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[2, 0]), tuple(corners_3d_img[6, 0]), color=color, thickness=thickness)
cv2.line(image, tuple(corners_3d_img[3, 0]), tuple(corners_3d_img[7, 0]), color=color, thickness=thickness)

cv2.imshow("Image with 3D lines", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

@Sondosmohamed1 Sondosmohamed1 changed the title visualization code for R0 visualization in R0 Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant