dirac-institute / kbmod

KBMOD (Kernel-Based Moving Object Detection)
BSD 2-Clause "Simplified" License
40 stars 14 forks source link

Remove copies for LayeredImage creation #650

Closed jeremykubica closed 3 weeks ago

jeremykubica commented 3 weeks ago

When given a set of RawImages the LayeredImage constructor does a copy. This PR adds a constructor that allows LayeredImage to take in the underlying Eigen data array (or numpy array from Python), claim ownership of the memory, and avoid the copy.

We also use ImageStack's new append_image() function to add images to the stack one on one instead of allocating a full list and copying them in. This slightly reduces the peak memory needed. We include a force_move option that allows the ImageStack to take ownership of the image and avoid doing a copy when it inserts it into the vector.