eigenvivek / DiffPose

[CVPR 2024] Intraoperative 2D/3D registration via differentiable X-ray rendering
http://vivekg.dev/DiffPose/
MIT License
90 stars 6 forks source link

How to make the animation gif file? #23

Open busyyang opened 1 month ago

busyyang commented 1 month ago

Nice registration work and nice visualization for registration process. I would like to make such a visualization file for registration process, but I cann't find the script for this.

I find a animate function in DiffDRR for DRR and x-rays. But in DiffPose, the CT could be fixed in the view and moving x-ray and camera makes the registration very clear. Is there possible to share this script to generate such visualization file? Or can you point out where I can find the scripts?

Thanks in advance.

eigenvivek commented 1 month ago

hi @busyyang sorry for the slow reply - that visualization was created with a combination of terminal scripting and ffmpeg, not sure if i have code saved to disk anywhere. i'll dig around, but in case it's helpful, here's an outline of how i generated it

use the 3D plotting code (based on pyvista) implemented in diffdrr - https://vivekg.dev/DiffDRR/tutorials/visualization.html

for each iteration in the test-time optimization run, render the CT, detector plane, camera, and rays intersecting the 3D fiducials. use pyvista to save a screenshot for each frame.

additionally, for each iteration, plot two DRRs (moving and target) and save a screenshot. this is very similar to the animate function, except you can also plot the 2D fiducials in this view.

now you have two animations, one in 3D and one in 2D, with an equal number of frames. using ffmpeg, you can stitch these together into a single GIF/mp4/etc. i don't remember exactly which command i used, but i found it on stackoverflow and it would've been something like this - https://stackoverflow.com/questions/42255139/ffmpeg-merge-two-videos-into-one-with-side-by-side-same-quality-output

busyyang commented 1 month ago

So kind of you.