# Vida - a simple p5js library for motion detection

**URL:** https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560
**Category:** Gallery
**Created:** [January 16, 2019, 2:13pm UTC](https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560 "2019-01-16T14:13:40Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![yaniki](https://avatars.discourse-cdn.com/v4/letter/y/c77e96/32.png) [@yaniki](https://discourse.processing.org/u/yaniki)
#### Post date: [January 16, 2019, 2:13pm UTC](https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560/1 "2019-01-16T14:13:40Z")

</div>

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](https://tetoki.eu/vida)

kind regards

Yaniki  
[https://paweljanicki.jp](https://paweljanicki.jp)

---

<div class="post-metadata">

### Author: ![yaniki](https://avatars.discourse-cdn.com/v4/letter/y/c77e96/32.png) [@yaniki](https://discourse.processing.org/u/yaniki)
#### Post date: [January 17, 2019, 1:17pm UTC](https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560/2 "2019-01-17T13:17:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![yaniki](https://avatars.discourse-cdn.com/v4/letter/y/c77e96/32.png) [@yaniki](https://discourse.processing.org/u/yaniki)
#### Post date: [January 19, 2019, 5:53pm UTC](https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560/3 "2019-01-19T17:53:25Z")

</div>

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

---

<div class="post-metadata">

### Author: ![yaniki](https://avatars.discourse-cdn.com/v4/letter/y/c77e96/32.png) [@yaniki](https://discourse.processing.org/u/yaniki)
#### Post date: [January 25, 2019, 11:51pm UTC](https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560/4 "2019-01-25T23:51:32Z")

</div>

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](https://tetoki.eu/vida)

---

<div class="post-metadata">

### Author: ![AndreasRef](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andreasref/32/133_2.png) [@AndreasRef](https://discourse.processing.org/u/AndreasRef)
#### Post date: [February 26, 2019, 9:28am UTC](https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560/5 "2019-02-26T09:28:20Z")

</div>

Very cool library!  
Thanks for putting it online 😃

---

<div class="post-metadata">

### Author: ![yaniki](https://avatars.discourse-cdn.com/v4/letter/y/c77e96/32.png) [@yaniki](https://discourse.processing.org/u/yaniki)
#### Post date: [April 9, 2019, 2:24pm UTC](https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560/6 "2019-04-09T14:24:42Z")

</div>

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) 😉

---

<div class="post-metadata">

### Author: ![yaniki](https://avatars.discourse-cdn.com/v4/letter/y/c77e96/32.png) [@yaniki](https://discourse.processing.org/u/yaniki)
#### Post date: [September 20, 2019, 11:12am UTC](https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560/7 "2019-09-20T11:12:29Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [September 20, 2019, 4:13pm UTC](https://discourse.processing.org/t/vida-a-simple-p5js-library-for-motion-detection/7560/8 "2019-09-20T16:13:39Z")

</div>

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