DiffPose icon indicating copy to clipboard operation
DiffPose copied to clipboard

How to make the animation gif file?

Open busyyang opened this issue 1 year ago • 2 comments

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.

busyyang avatar May 11 '24 02:05 busyyang

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

eigenvivek avatar May 20 '24 14:05 eigenvivek

So kind of you.

busyyang avatar May 21 '24 01:05 busyyang