AlanNaoto / carla-dataset-runner

Data collector for CARLA 0.9.6
MIT License
60 stars 20 forks source link

Retrieving video from sensors #7

Closed tjzetty closed 3 years ago

tjzetty commented 3 years ago

Could you explain how you converted the rgb data into a video format? I would like this for presenting.

AlanNaoto commented 3 years ago

Hi @tjzetty, I'm using opencv to do that. Take a look at this method :) https://github.com/AlanNaoto/carla-dataset-runner/blob/master/utils/create_video_on_hdf5/create_content_on_hdf5.py#L55-L79

tjzetty commented 3 years ago

Awesome, thank you! So could I pass the hdf5 file as an argument to the python file like this: python3 create_content_on_hdf5.py datafile.hdf5

AlanNaoto commented 3 years ago

ATM the input to create_video_sample() is hardcoded to the path, so you'd have to change this string yourself in the python file and then do python3 create_content_on_hdf5.py

tjzetty commented 3 years ago

So is there a way to get the images with the bounding boxes as well? I imagine the timestamps and RGB data were gathered from an image.

AlanNaoto commented 3 years ago

I do save the bounding box images in the footage. Take a look on the "create_content_on_hdf5.py" file.

   # bb
    bb_vehicles = bb_vehicles_data
    bb_walkers = bb_walkers_data
    if all(bb_vehicles != -1):
        for bb_idx in range(0, len(bb_vehicles), 4):
            coordinate_min = (int(bb_vehicles[0 + bb_idx]), int(bb_vehicles[1 + bb_idx]))
            coordinate_max = (int(bb_vehicles[2 + bb_idx]), int(bb_vehicles[3 + bb_idx]))
            cv2.rectangle(rgb_data, coordinate_min, coordinate_max, (0, 255, 0), 1)
    if all(bb_walkers != -1):
        for bb_idx in range(0, len(bb_walkers), 4):
            coordinate_min = (int(bb_walkers[0 + bb_idx]), int(bb_walkers[1 + bb_idx]))
            coordinate_max = (int(bb_walkers[2 + bb_idx]), int(bb_walkers[3 + bb_idx]))

            cv2.rectangle(rgb_data, coordinate_min, coordinate_max, (0, 0, 255), 1)
tjzetty commented 3 years ago

All your suggestions worked for me, thank you!