Giter VIP home page Giter VIP logo

lvdagilis / pir-video Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 38 KB

Processing-based video-playback program to play video when movement is detected, and pause when not, created specifically for galleries in museums, designed to run continuously and without human-intervention after initial setup.

License: GNU General Public License v3.0

Processing 100.00%
pir-video video-playback movement pause processing art gallery interactive

pir-video's Introduction

PIR-Video

Processing-based video-playback program to play video when movement is detected, and pause when not. Originally created for a retrospective installation Timestamps (EN: http://www.ndg.lt/exhibitions/present/timestamps.aspx, LT: http://www.ndg.lt/parodos/parodos/laikmenos.aspx) at the National Art Gallery in Vilnius, Lithuania. The program allows the gallery space to quiet down, fall asleep without any viewers, and each work activates as viewers approach the designated areas. This version specifically is written for a RaspberryPi using Processing and a cheap PIR sensor, but can be easily adapted for other uses. Please get in touch in case your museum/gallery would like this to be customized for your use case!

Setup

##Hardware 0. Connect PIR sensor to Raspberry PI. In case you'd like to use the code provided without needing further modifications, use these pins: Sensor pin to GPIO21 PWR pin to GPIO4 GND pin to GPIO6 Please note that different PIR sensor have different layouts, so check accordingly. On some PIR sensors the pinout is underneath the fresnel lens (which can be very easily removed and replaced)

##Software In practice, this should be possible without needing to use Processing for Pi OS, however, between testing on various RaspberryPis with various states of OS (from fresh installs to old hacked ones), the process of getting the video libraries to run at a high framerate, while keeping an easy install process was just too unreliable. Sometimes it worked, sometimes it didn't, even if following the same steps on a fresh install on the same RPi.

  1. Install the Processing for Pi OS using Raspberry Pi Imager

  2. a. Download Raspberry Pi Imager from https://www.raspberrypi.org/software/

  3. b. Download Processing for Pi Image from Processing.org https://pi.processing.org/download/

  4. c. In Raspberry Pi Imager: "Choose OS" -> "Use custom" -> select the image you downloaded in step 1.b.

  5. d. Select the blank SD card/USB stick you'll be using for the OS install

  6. e. "Write"

  7. Launch the RaspberryPi

  8. Download and copy the PIRVideo files onto the Pi. This tutorial uses /home/pi/GPIOv11 as the location fo the files

  9. Add the desired video to /home/pi/PIRVideo/data. By default, the program is set to use a file called "movie.mp4"

  10. a. In case you have a different filename (recommend to use .mp4 encoding), you can change the filename in the config.txt

##Change timer (optional) 5. If needed, you can change the timer integrated into the program (in testing, the PIR sensor delays were very inaccurate). Enter the desired delay in the first line of config.txt, in milliseconds (ex.: 20s = 20000).

##Hide the RPi taskbar (optional) 6. Right-click on taskbar, select "Panel Preferences" -> Advanced -> Properties -> uncheck "Reserve space, and not covered by maximised windows"

##Set-up an autostart to launch the program every time the RPI receives power. (optional) 7. Open the terminal and enter the following:programa automatiskai pasileistu kai ijungiamas raspberry, paleidus RPi atidaryti terminal ir vesti sias komandas:

mkdir /home/pi/.config/autostart
sudo nano /home/pi/.config/autostart/PIRVideo.desktop

Then, paste the following code:


[Desktop Entry]
Type=Application
Name=GPIO
Exec=processing-java --sketch=/home/pi/PIRVideo --present

After pasting- ctrl+x -> Y -> enter

##8. Restart the Pi

#DEBUG MODE

In case you'd like to test the functionality without having to restart, or manually launch through processing's GUI, you can simply enter the following command into terminal:

processing-java --sketch=/home/pi/PIRVideo --present

Additionally, pressing 'd' in the sketch will launch a debug mode!

Debug mode info: motion Shows whether the PIR is showing as seeing motion (1=motion, 0=no motion) Playing Shows whether the video is playing Delay If there is currently active movement (i.e. the PIR sees movement, or the delay built-into the PIR from the last movement hasn't passed since last movement) - delay will show the full delay time. Once the PIR sends 0 for motion - the software delay will start counting down, and video should stop at 0 Movie available If false - means there's frame skipping, file is in an incorrect format, unreadable, or some other issue with this. Movie time Shows the current frame - good for checking your performance. High-res videos on the Pi will cause significant FPS drops. config time Shows the delay time that's set in the config.txt file "" movie name Shows the movie filename set in config.txt, good to check in case you're having issues with Movie Available

The debug was designed to be easy to understand visually from afar (as the installation was meant for large-scale projections with no more than 1080p resolution), so one could troubleshoot from near the projector/sensor, even if they are far from the screen. Hence:

TOP LEFT White when motion, fades to black (in time with the delay) once motion is no longer detected TOP RIGHT Video preview BOTTOM HALF Debug text, white background when motion = 1, black background when motion = 0.

#Sharing Built with Processing

pir-video's People

Contributors

lvdagilis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.