CodeProject.AI Server is a self-hosted, free and Open Source Artificial Intelligence Server for any platform, any language. Just like you would install a database server to provide data storage, you install CodeProject.AI Server to provide AI services.
It can be installed locally, requires no off-device or out of network data transfer, and is easy to use.
Head over to the CodeProject.AI Documentation for installation instructions.
Configuration
Configuration example
codeprojectai:
host: codeprojectai
port: 32168
object_detector:
cameras:
viseron_CHANGEME_camera:
fps: 1
log_all_objects: true
labels:
- label: person
confidence: 0.8
trigger_recorder: true
- label: cat
confidence: 0.8
zones:
- name: zone1
coordinates:
- x: 0
y: 500
- x: 1920
y: 500
- x: 1920
y: 1080
- x: 0
y: 1080
labels:
- label: person
confidence: 0.8
trigger_recorder: true
mask:
- coordinates:
- x: 400
y: 200
- x: 1000
y: 200
- x: 1000
y: 750
- x: 400
y: 750
camera_two:
fps: 1
labels:
- label: person
confidence: 0.7
trigger_recorder: true
- label: cat
confidence: 0.8
trigger_recorder: false
face_recognition:
save_unknown_faces: true
cameras:
camera_two:
labels:
- person
license_plate_recognition:
cameras:
camera_one:
labels:
- vehicle
- car
- truck
known_plates:
- ABC123
CodeProject.AI configuration.
IP or hostname to your CodeProject.AI server.
Port to your CodeProject.AI server.
Lowest value: 1024
Highest value: 49151
Timeout for requests to your CodeProject.AI server.
Object detector domain config.
Camera-specific configuration. All subordinate keys corresponds to the camera_identifier
of a configured camera.
Camera identifier. Valid characters are lowercase a-z, numbers and underscores.
The FPS at which the object detector runs.
Higher values will result in more scanning, which uses more resources.
When set to true
and a motion_detector
is configured, the object detector will only scan while motion is detected.
A list of labels (objects) to track.
Lowest confidence allowed for detected objects. The lower the value, the more sensitive the detector will be, and the risk of false positives will increase.
Lowest value: 0
Highest value: 1
Minimum height allowed for detected objects, relative to stream height.
Lowest value: 0
Highest value: 1
Maximum height allowed for detected objects, relative to stream height.
Lowest value: 0
Highest value: 1
Minimum width allowed for detected objects, relative to stream width.
Lowest value: 0
Highest value: 1
Maximum width allowed for detected objects, relative to stream width.
Lowest value: 0
Highest value: 1
If set to true
, objects matching this filter will start the recorder.
If set to true
, the recorder will stop as soon as motion is no longer detected, even if the object still is. This is useful to avoid never ending recordings of stationary objects, such as a car on a driveway
Drop frames that are older than the given number. Specified in seconds.
When set to true and loglevel is DEBUG
, all found objects will be logged, including the ones not tracked by labels
.
A mask is used to exclude certain areas in the image from object detection.
List of X and Y coordinates to form a polygon
X-coordinate (horizontal axis).
Y-coordinate (vertical axis).
Zones are used to define areas in the cameras field of view where you want to look for certain objects (labels).
Name of the zone. Has to be unique per camera.
List of X and Y coordinates to form a polygon
X-coordinate (horizontal axis).
Y-coordinate (vertical axis).
A list of labels (objects) to track.
Lowest confidence allowed for detected objects. The lower the value, the more sensitive the detector will be, and the risk of false positives will increase.
Lowest value: 0
Highest value: 1
Minimum height allowed for detected objects, relative to stream height.
Lowest value: 0
Highest value: 1
Maximum height allowed for detected objects, relative to stream height.
Lowest value: 0
Highest value: 1
Minimum width allowed for detected objects, relative to stream width.
Lowest value: 0
Highest value: 1
Maximum width allowed for detected objects, relative to stream width.
Lowest value: 0
Highest value: 1
If set to true
, objects matching this filter will start the recorder.
If set to true
, the recorder will stop as soon as motion is no longer detected, even if the object still is. This is useful to avoid never ending recordings of stationary objects, such as a car on a driveway
Frames will be resized to this width and height before inference to save computing power. Resizing is done by adding black borders to the image to keep the aspect ratio.
Name of a custom CodeProject.AI model.
Face recognition domain config.
Camera-specific configuration. All subordinate keys corresponds to the camera_identifier
of a configured camera.
Camera identifier. Valid characters are lowercase a-z, numbers and underscores.
A list of labels that when detected will be sent to the post processor. Applies only to this specific camera.
A list of labels that when detected will be sent to the post processor. Applies to all cameras defined under cameras
.
Path to folder which contains subdirectories with images for each face to track.
If true, any unrecognized face will be saved to the folder specified in unknown_faces_path
. You can then move this image to the folder of the correct person to improve accuracy.
Path to folder where unknown faces will be stored.
Time in seconds before a detected face is no longer considered detected.
Train CodeProject.AI to recognize faces on Viseron start. Disable this when you have a good model trained.
Minimum confidence for a face to be considered a match.
Lowest value: 0
Highest value: 1
License plate recognition domain config.
Camera-specific configuration. All subordinate keys corresponds to the camera_identifier
of a configured camera.
Camera identifier. Valid characters are lowercase a-z, numbers and underscores.
A list of labels that when detected will be sent to the post processor. Applies only to this specific camera.
A list of labels that when detected will be sent to the post processor. Applies to all cameras defined under cameras
.
List of known license plates. Each plate will have its own sensor.
Minimum confidence for a license plate detection.
Lowest value: 0
Highest value: 1
Time in seconds before a plate recognition expires.
Face recognition
Face recognition runs as a post processor when a specific object is detected.
Labels
Labels are used to tell Viseron when to run a post processor.
Any label configured under the object_detector
for your camera can be added to the post processors labels
section.
Only objects that are tracked by an object_detector
can be sent to a post_processor
.
The object also has to pass all of its filters (confidence, height, width etc).
Train
On startup images are read from face_recognition_path
and a model is trained to recognize these faces.
The folder structure of the faces folder is very strict. Here is an example of the default one:
/config
|── face_recognition
| └── faces
| ├── person1
| | ├── image_of_person1_1.jpg
| | ├── image_of_person1_2.png
| | └── image_of_person1_3.jpg
| └── person2
| | ├── image_of_person2_1.jpeg
| | └── image_of_person2_2.jpg
You need to follow this folder structure, otherwise training will not be possible.
License plate recognition
License plate recognition runs as a post processor when a specific object is detected.
You can track known license plates by adding them to the known_plates
list in the configuration.
Known plates will be reported as binary sensors.
There is also a sensor entity that reports all the plates that have been detected.
This can be used to trigger actions in other platforms, eg Home Assistant, when an unknown plate is detected.
Object detector
An object detector scans an image to identify multiple objects and their position.
Object detectors can be taxing on the system, so it is wise to combine it with a motion detector
Labels
Labels are used to tell Viseron what objects to look for and keep recordings of.
The available labels depends on what detection model you are using.
The max/min width/height is used to filter out any unreasonably large/small objects to reduce false positives.
Objects can also be filtered out with the use of an optional mask.
Zones
Zones are used to define areas in the cameras field of view where you want to
look for certain objects (labels).
Say you have a camera facing the sidewalk and have labels
setup to
record the label person
.
This would cause Viseron to start recording people who are walking past the
camera on the sidewalk. Not ideal.
To remedy this you define a zone which covers only the area that you are
actually interested in, excluding the sidewalk.
codeprojectai:
object_detector:
cameras:
camera_one:
...
zones:
- name: sidewalk
coordinates:
- x: 522
y: 11
- x: 729
y: 275
- x: 333
y: 603
- x: 171
y: 97
labels:
- label: person
confidence: 0.8
trigger_recorder: true
See Mask for how to get the coordinates for a zone.
Mask
Masks are used to exclude certain areas in the image from object detection.
If a detected object has its lower portion inside of the mask it will be discarded.
The coordinates
form a polygon around the masked area.
To easily generate coordinates
you can use a tool like image-map.net.
Just upload an image from your camera, choose the Poly
shape and start drawing your mask.
Then click Show me the code! and adapt it to the config format.
Coordinates coords="522,11,729,275,333,603,171,97"
should be turned into this:
codeprojectai:
object_detector:
cameras:
camera_one:
...
mask:
- coordinates:
- x: 522
y: 11
- x: 729
y: 275
- x: 333
y: 603
- x: 171
y: 97