I would like to introduce a new library for p5js:
Vida is a simple library that adds camera (or video) based motion detection and blob tracking functionality to p5js. The library allows motion detection based on a static or progressive background; defining rectangular zones in the monitored image, inside which the occurrence of motion triggers the reaction of the program; detection of moving objects (“blobs”) with unique index, position, mass, rectangle, approximated polygon. The main guidelines of the library are to maintain the code in a compact form, easy to modify, hack and rework.
I think that the library will be useful both for the creation of “reallife projects” as well as for people who teach (themselves or others) basics of coding and need a simple mechanism for working with a camera.
The development of the library is at an early level (let’s say “alpha”, although all documented functions should work properly), so any comments will be very helpful. It is also worth mentioning a few issues:
Vida works well, but it can be faster, some calculations can be chewed on the GPU, and the code optimized… so I assume that performance can be improved.
Access to the camera from the web browser often causes problems, it is not directly related to the Vida library, or even p5js - it’s rather a question of how browser vendors solve security issues. I mention this in the documentation, it is also easy to find information on the browsers-cameras-OSes issues. On macOS and Windows it’s best to use Mozilla Firefox - it has the least problems both for local and network file hosting.
Vida is not OpenCV. It is not something that should replace OpenCV. Vida is a library that is supposed to provide the simplest mechanisms of motion detection and at the same time enable easy “hacking” of the source code (so Vida does not use emscripten to speed up the code - at least for now).
The library with examples and docs is available here: https://tetoki.eu/vida