Legacy example · C++ · Python · Version 1.0
Endoscopy Out of Body Detection
| Authors | Holoscan Team (NVIDIA) |
|---|---|
| Supported platforms | x86_64, aarch64 |
| Language | C++, Python |
| Version | 1.0 |
| Compatibility | HSDK 4.6 |
| Contribution level | Level 1 · Very high-quality code |
| Source | HoloHub |
Legacy HoloHub application
This application comes from HoloHub and was last tested with Holoscan SDK (HSDK) 4.6. It runs with the HoloHub CLI, ./holohub.

Overview
This application performs real-time detection of whether an endoscope is inside or outside the body during endoscopic procedures. For each input frame, the application:
- Classifies the frame as either "in-body" or "out-of-body"
- Provides a confidence score for the classification
- Outputs either to the console or to a CSV file (when analytics is enabled)
Note: This application does not include visualization components.
Quick Start
Run the following command to build and launch the application on a supported Holoscan platform:
./holohub run endoscopy_out_of_body_detection --language=<cpp/python>
Prerequisites
- NVIDIA Holoscan SDK (version 0.5 or higher)
- A supported Holoscan platform or workstation with a CUDA-capable NVIDIA GPU
- CMake build system
- FFmpeg (for data conversion)
Data Requirements
Model and Sample Data
The endoscopy detection model and sample datasets are available on NGC. The package includes:
- Pre-trained ONNX model for out-of-body detection:
out_of_body_detection.onnx - Sample endoscopy video clips (MP4 format):
sample_clip_out_of_body_detection.mp4
Data Preparation (optional)
The application requires the input videos to be converted to GXF tensor format. This conversion happens automatically during building, but manual conversion can be done following these steps:
-
Download and extract the data:
unzip [NGC_DOWNLOAD].zip -d <data_dir> -
Convert the video to GXF tensor format using the provided script:
ffmpeg -i <INPUT_VIDEO_FILE> -fs 900M -pix_fmt rgb24 -f rawvideo pipe:1 | \ python convert_video_to_gxf_entities.py --width 256 --height 256 --channels 3 --framerate 30Note: The conversion script (
convert_video_to_gxf_entities.py) is available in the Holoscan SDK repository. -
Organize the data directory as follows:
data/ └── endoscopy_out_of_body_detection/ ├── LICENSE.md ├── out_of_body_detection.onnx ├── sample_clip_out_of_body_detection.gxf_entities ├── sample_clip_out_of_body_detection.gxf_index └── sample_clip_out_of_body_detection.mp4
Configuration
The application uses endoscopy_out_of_body_detection.yaml for configuration. Key settings include:
- Input video parameters in the
replayersection - Model parameters in the
inferencesection - Analytics settings for data export
Building
./holohub build-container endoscopy_out_of_body_detection
./holohub run-container endoscopy_out_of_body_detection
./holohub build endoscopy_out_of_body_detection --language=<cpp/python>
./holohub run endoscopy_out_of_body_detection --language=<cpp/python>
For more information, see the Holohub README.md.
Running the Application
Basic Usage
From your build directory:
C++:
applications/endoscopy_out_of_body_detection/endoscopy_out_of_body_detection \
--config endoscopy_out_of_body_detection.yaml \
--data ../data/endoscopy_out_of_body_detection
Python:
applications/endoscopy_out_of_body_detection/endoscopy_out_of_body_detection.py \
--config endoscopy_out_of_body_detection.yaml \
--data ../data/endoscopy_out_of_body_detection
Analytics Mode
To enable analytics and export results to CSV:
- Set
enable_analytics: truein the configuration file:
# endoscopy_out_of_body_detection.yaml
enable_analytics: true
- Configure analytics output (optional):
# Set output directory (default: current directory)
export HOLOSCAN_ANALYTICS_DATA_DIRECTORY="/path/to/output"
# Set output filename (default: data.csv)
export HOLOSCAN_ANALYTICS_DATA_FILE_NAME="results.csv"
The application will create:
- A directory named after the application
- Subdirectories with timestamps for each run
- CSV files containing frame-by-frame classification results
Output Format
-
Console Mode: Displays "Likely in-body" or "Likely out-of-body" along with confidence scores for each frame.
-
Analytics Mode: Outputs a CSV file with frame-by-frame classification results in the following format:
In-body,Out-of-body,Confidence Score
1,0,0.972432
1,0,0.902066