This document explains how SOD (an embedded computer vision & machine learning library) is integrated into LightNVR and how to build the project with or without SOD support.
SOD provides embedded motion and object detection that runs inside LightNVR, with no external detection service. It is built as a separate shared library (libsod.so) and is optional.
By default, LightNVR is built with SOD support. This means:
- SOD is compiled as a shared library (
libsod.so) - LightNVR is linked against this library
- The SOD code is directly accessible to LightNVR
To build with SOD support:
# Using the standard build script (SOD is enabled by default)
./scripts/build.sh --release
# Or explicitly enable SOD
./scripts/build.sh --release --with-sod
# Or manually
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_SOD=ON ..
make -j$(nproc)You can also build LightNVR without SOD support. In this case:
- SOD is not compiled
- LightNVR is not linked against SOD
- LightNVR will attempt to dynamically load
libsod.soat runtime if it's available
To build without SOD support:
# Using the standard build script with the --without-sod option
./scripts/build.sh --release --without-sod
# Or manually
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_SOD=OFF ..
make -j$(nproc)When LightNVR is built with SOD support:
- All SOD functionality is available
- Detection models that require SOD can be loaded and used
When LightNVR is built without SOD support:
- The system will attempt to dynamically load
libsod.soat runtime - If
libsod.sois found, SOD functionality will be available - If
libsod.sois not found, SOD functionality will be disabled, but LightNVR will still run - Detection models that require SOD will not be loadable if SOD is not available
By default, the installation script will install both LightNVR and the SOD library:
# Build with SOD support first
./scripts/build.sh --release
# Install with SOD support (default)
sudo ./scripts/install.sh
# Or explicitly specify SOD installation
sudo ./scripts/install.sh --with-sodYou can also install LightNVR without the SOD library:
# Build without SOD support first
./scripts/build.sh --release --without-sod
# Install without SOD
sudo ./scripts/install.sh --without-sodIf you build LightNVR without SOD support, you can still install SOD separately:
# Clone the repository
git clone https://github.com/opensensor/lightNVR.git
cd lightNVR
# Build just the SOD library
mkdir -p build_sod
cd build_sod
cmake ../src/sod
make -j$(nproc)
# Install the SOD library
sudo cp lib/libsod.so.1.1.9 /usr/local/lib/
sudo ln -sf /usr/local/lib/libsod.so.1.1.9 /usr/local/lib/libsod.so.1
sudo ln -sf /usr/local/lib/libsod.so.1 /usr/local/lib/libsod.so
sudo ldconfigThis will make SOD available to LightNVR at runtime, even if it was built without SOD support.
The following detection model types are supported:
- SOD models (
.sodextension) - SOD RealNet models (
.realnet.sodextension) - TensorFlow Lite models (
.tfliteextension)
SOD and SOD RealNet models require SOD to be available (either built-in or dynamically loaded).
TensorFlow Lite models run on the in-process LiteRT engine, which needs a build with -DENABLE_LITERT=ON and [detection_engine] enabled = true (see Configuration). For larger models, an external detector such as light-object-detect is usually the better fit; see Detection Engines.
LightNVR now includes a unified detection interface that supports both RealNet and CNN model architectures. This allows you to use either model type with the same API, making it easy to switch between models based on your requirements.
For more information, see SOD Unified Detection.
test_sod_unified runs a RealNet or CNN model against a still image, detecting the model
type automatically. It is built with the test suite (-DBUILD_TESTS=ON) when SOD is enabled:
./test_sod_unified test.jpg face.realnet.sod output.jpg
./test_sod_unified test.jpg face_cnn.sod output.jpg