This project demonstrates an advanced plugin-based architecture for processing real-time video frames using OpenCV. The system allows for dynamically enabling or disabling features such as Kalman Filter, Optical Flow, and Face Detection. The features are implemented as shared libraries (DLL, SO, or DYLIB files) and are dynamically loaded by the main program at runtime. The configuration for enabling/disabling features is managed by a server and periodically fetched by the client application.
The system integrates computer vision with a plugin management system, allowing real-time frame processing and feature toggling without restarting the application.
- Dynamic Plugin Loading: Load and execute features like Kalman Filter, Optical Flow, and Face Detection as shared libraries.
- Real-time Video Processing: Process frames captured from a webcam in real time using OpenCV.
- Feature Management: Toggle features on/off via a REST API, enabling or disabling feature processing without application restart.
- Modular and Scalable: Easily add more features by creating additional shared libraries.
-
Client Application (C++):
- Captures video from the webcam.
- Dynamically loads and processes frames using features implemented in shared libraries.
- Displays processed frames in separate windows for each active feature.
-
Server (Node.js + Express):
- Manages feature configurations (enabled/disabled).
- Provides an API endpoint to retrieve the current feature configuration.
- The client periodically fetches the configuration from the server to update active features.
-
Plugin System:
- Plugins are shared libraries (DLL/SO/DYLIB files) with a standardized interface.
- Plugins process frames using a
processFramefunction exposed in each library.
-
Main Functionality:
- Captures video frames from the webcam using OpenCV (
cv::VideoCapture). - Fetches the current configuration from the server (
/api/get_subscription). - Loads and processes frames using enabled features.
- Displays the processed frames in separate windows.
- Captures video frames from the webcam using OpenCV (
-
Dependencies:
- OpenCV
- PluginLoader (Custom Class)
- cpr (for HTTP requests)
-
Main Functionality:
- Serves the
/api/get_subscriptionendpoint. - Allows the client to fetch the configuration for which features should be enabled/disabled.
- Serves the
-
Dependencies:
- Express.js
- JSON for feature configuration
-
Each feature (Kalman Filter, Optical Flow, Face Detection) is implemented in a shared library.
-
Common Interface: Each plugin must define the following C-compatible interface for the
processFramefunction:struct CPluginResult { unsigned char *data; int width; int height; int channels; int hasData; };
-
Face Detection Plugin: Uses OpenCV’s Haar Cascade Classifier to detect faces and display them in the processed frame.
-
Kalman Filter Plugin: Displays the Kalman filter label in the processed frame.
-
Optical Flow Plugin: Converts the frame to grayscale and displays the optical flow label.
Before running the system, ensure that the following dependencies are installed:
- OpenCV: Required for video capture and processing.
- Node.js: For running the server-side API.
- cpr: C++ HTTP client library used for making requests to the server.
-
Clone the Repository:
git clone https://github.com/orbitalisvoid/HyperSight.git cd feature-management-plugin -
Install Server Dependencies: Navigate to the server directory and install the required Node.js packages:
cd server npm install -
Build the Client Application:
- If you’re using CMake, navigate to the client directory and run:
mkdir build cd build cmake .. make -
Build Feature Plugins:
- The feature plugins need to be compiled as shared libraries (DLL/SO/DYLIB) based on your operating system.
- Make sure OpenCV is linked correctly during the build process.
-
Start the Server:
- Run the Node.js server to start serving the feature configuration:
cd server node server.js -
Run the Client:
- After building the client application, run it to start processing the webcam feed:
./client_application
-
Toggle Features:
- Use the server's
/api/get_subscriptionendpoint to update the feature configuration. - The client will periodically fetch this configuration and enable/disable features accordingly.
- Use the server's
The server's feature configuration is a simple JSON object:
{
"kalman_filter": false,
"optical_flow": true,
"face_detection": true
}To update the configuration, modify the subscriptionData object in the server code and restart the server.
To add new features:
- Create a new plugin following the same structure as the existing features (e.g., Face Detection, Kalman Filter).
- Implement the
processFramefunction in the plugin. - Build the plugin as a shared library.
- Add the feature to the client-side configuration (e.g.,
featuresmap).