Codeproject.AI
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
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
Paste your coordinates here and press Get config
to generate a config example
Troubleshooting
codeprojectai
, add the following to your config.yaml
logger:
logs:
viseron.components.codeprojectai: debug