ln-12 / blainder-range-scanner

BlAInder range scanner is a Blender add-on to simulate Lidar and Sonar measurements. The result can be saved as annotated 2D image or 3D point cloud.
GNU General Public License v3.0
122 stars 25 forks source link

Export sensor poses (location and rotation) #31

Closed shayan-nikoo closed 1 year ago

shayan-nikoo commented 1 year ago

Thanks for the nice tool. I create a curve for the camera animation and create many frames (Blender autokeying) along the curve for a smooth sensor movement (animation) and skip every 2 to 5 frames. Is it possible to export the sensor trajectory including the sensor poses (locations, rotations)? How can we do that?

ln-12 commented 1 year ago

Hey @shayan-nikoo, thanks for your request. I think your idea should be quite straight forward to implement. I would start by getting the camera parameters from Blender in each frame here. You could then write the needed values to a .csv file (or any other format).

Another approach could be to extend the hit_info class by adding some camera parameter properties, read the camera parameters here and write them in the output file for each ray (if that's what you need) in any of the exporters like shown here.

Does that help?

shayan-nikoo commented 1 year ago

Thank you @ln-12, I don't need each ray but only the location and orientation in each frame, so the first solution should work. Do the below lines in the for loop do the job? and then I can save it in a list and export it:

print(bpy.data.objects["Camera"].location)
print(bpy.data.objects["Camera"].rotation_euler)

In lidar.py, I don't find a loop for frames, where in the code I can get properties per frame? Or only generic.py is enough? I'm using the Velodyne sensor to simulate scanning.

ln-12 commented 1 year ago

That looks good to me, but it has been quite some time since I last worked with Blenders Python API. If it delivers the desired outout, you are good to go.

For Lidar, this place is fine as from there, the lidar scanner is called for each frame. Sonar works a bit different. For that you would need to insert you code here.