Vida - a simple p5js library for motion detection

Dear Friends

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:

  1. 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.

  2. 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.

  3. 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

kind regards

Yaniki
https://paweljanicki.jp

4 Likes

Update: I figured out, that there was some issues with Vida webpage and online examples when browsed under mobile Safari. I fixed this, so now the site should work better under iOS/Safari (of course mobile Safari will not allow you to use the video camera, so I recommend using examples based on the video file).

And another one small fix: online examples based on video file should be compatible with more browsers now.

Updated and improved examples now shows how to use Vida also with iOS.

Moreover there are a few details corrected in the reference and comments in the source code (in the library code itself and in the examples). The address has not changed and the library with documentation, on- and offline examples is still here: https://tetoki.eu/vida

1 Like

Very cool library!
Thanks for putting it online :smiley:

1 Like

I made some very, very, very boring fixes, so therefore, from now, Vida should be compatible with the p5js v. 0.8.0 (and online examples should be compatible with new, infamous, autoplay restrictions) :wink:

1 Like

Dear Friends

Vida has been updated to version 0.3: the library can now be used in the instance mode, it also works with P5js v. 0.9.0.

3 Likes

Thank you so much for your work on this, and sharing it with the community!