A Node.js application that processes IP camera feeds using TensorFlow.js object detection.
- Connects to multiple IP cameras (up to 4)
- Uses TensorFlow.js with COCO-SSD model to detect objects in camera feeds
- Processes camera feeds in separate worker threads for better performance
- Provides a REST API endpoint to access detection results
- Node.js v22 or higher
- NPM or Yarn
# Clone the repository
git clone https://github.com/yourusername/ip-camera-data.git
cd ip-camera-data
# Install dependencies
npm install
Edit the config.js
file to set your IP camera URLs and server port:
const config = {
port: 8080, // HTTP server port
CAM1: process.env.CAM1 || 'https://your-camera-url-1',
CAM2: process.env.CAM2 || 'https://your-camera-url-2',
CAM3: process.env.CAM3 || 'https://your-camera-url-3',
CAM4: process.env.CAM4 || 'https://your-camera-url-4',
};
You can also set the camera URLs via environment variables.
Start the application:
node index.js
Access the camera data via the REST API:
GET http://localhost:8080/camdata
This will return a JSON object with detection results from all cameras:
{
"CAM1": {
"image": { "height": 480, "width": 640, "channels": 3 },
"predictions": [
{ "bbox": [x, y, width, height], "class": "person", "score": 0.8912 },
...
],
"timestamp": 1678912345678
},
"CAM2": { ... },
"CAM3": { ... },
"CAM4": { ... }
}
- The application starts an Express server and creates worker threads for each camera
- Each worker loads the TensorFlow.js COCO-SSD model for object detection
- Workers continuously fetch images from the configured camera URLs
- Object detection is performed on each image
- Results are sent back to the main thread and stored
- The REST API endpoint
/camdata
provides access to the latest detection results
ISC