Skip to content

KBMOD (Kernel-Based Moving Object Detection)

License

Notifications You must be signed in to change notification settings

DinoBektesevic/kbmod

 
 

Repository files navigation

logo

An image processing library for moving object detection implemented with GPUs.
Based on a Maximum Likelihood detection algorithm for moving astronomical objects.

Build Status LicenseDOI

KBMOD is a set of Python tools to search astronomical images for moving objects based upon method of maximum likelihood detection.

Updates and Changes

For a list of major changes, including breaking changes to the code, please see the Major-Changes wiki page.

Requirements

To build kbmod The packages required to build the code are:

  • Cuda Toolkit >= 8.0
  • CMake >= 3.12

Ensure that the NVIDIA's nvcc compiler is available on your system, for example:

nvcc --version

It is possible that the compiler is installed but not discoverable. In that case add its location to PATH. For example, if using bash do export PATH=/path/to/cuda:$PATH. The default location for CUDA Toolkit installation is usually /usr/local/cuda-XY.Z** where XY.Zrepresent the CUDA Toolkit version that was installed. If usingbashadd the appropriate command to~/.bashrc` in order to avoid having to set it repeatedly.

If CUDA Toolkit is not availible on your system follow their offical installation instructions. Optionally, if you use Anaconda virtual environments, the CUDA Toolkit is also availible as conda install cudatoolkit-dev.

Installation

Clone this repository, including all of its submodules:

git clone --recursive https://github.com/dirac-institute/kbmod.git

Build

cd kbmod
pip install .

This builds the package and all the dependencies required to test, run KBMoD on images and read the results. To use the additional analysis tools available in the analysis module it is necessary to install additional dependencies:

pip install .[analysis]

Note, however, that some of the dependencies in the analysis module require packages and supplementary data that are not installed nor provided by KBMoD.

To verify that the installation was successful run the tests:

cd tests/
bash run_tests.bash

For Developers

If you want to contribute to the development of KBMoD, it is recommended that you install it in editable mode:

pip install -e .

Changes you make to the Python source files will then take immediate effect. To recompile the C++ code it's easiest to re-install the package in editable mode again.

It is possible to build only the C++ code via cmake.

cmake -B src/kbmod -S .
cmake --build src/kbmod --clean-first

To rebuild, it is sufficient to just re-run the cmake --build command. Optionally, invoke the cmake generated Makefile as make clean && make from the src/kbmod directory.

Usage

A short example injecting a simulated object into a stack of images, and then recovering it.

from kbmodpy import kbmod as kb
import numpy as np

# Create a point spread function
psf = kb.psf(1.5)

# load images from list of file paths
imgs =  [ kb.layered_image(file, psf) for file in example_files ]

# Specify an artificial object
flux = 175.0
position = (100.7, 150.3)
velocity = (50, 35)

# Inject object into images
for im in imgs:
    im.add_object(position[0]+im.get_time()*velocity[0], 
                  position[1]+im.get_time()*velocity[1], 
                  flux)

# Recover the object by searching a wide region
velocity_guess = (40, 40)
radius = 20
min_lh = 9.0
min_obs = 10
stack = kb.image_stack(imgs)
search = kb.stack_search(stack)
results = search.region_search(*velocity_guess, radius, min_lh, min_obs)

Short Demonstration

Processing Real Images

Reference

API Reference.

License

The software is open source and available under the BSD license.

About

KBMOD (Kernel-Based Moving Object Detection)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 90.9%
  • Python 4.9%
  • C++ 2.0%
  • C 1.8%
  • Cuda 0.4%
  • CMake 0.0%