Asennetaan motion Raspberry Pi tietokoneelle.

Comments Off on Asennetaan motion Raspberry Pi tietokoneelle.

Motion on avoin ja ilmainen ohjelma Linux tietokoneille. Sen avulla voi laittaa kameran streamaamaan verkkoon kuvaa ja myöskin samalla tallentaa liikkestä videoita talteen haluttuun paikkaan.

Tässä esimerkiksi Tikka, ja Orava lintulaudalla.

Raspberry Pi tietokoneeseen täytyy tietenkin olla asennettu kamera ja otettu se käyttöön raspberry config asetuksissa. Tämä tehtiin jo aikaisemmassa blog postissa:

Motion kannattaa asentaa hakemalla lähdekoodi projekti github:sta ja kääntämällä se itse. Tämä onnistuu seuraavanlaisilla komennoilla; (Lähde; https://raspberrypi.stackexchange.com/questions/76193/installing-mmal-motion-on-rpi)

sudo mkdir motion 
sudo cd motion
sudo apt-get install autoconf automake autopoint build-essential pkgconf libtool libzip-dev libjpeg-dev git libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavdevice-dev libwebp-dev gettext libmicrohttpd-dev

git clone https://github.com/Motion-Project/motion.git 
sudo cd motion 
sudo autoreconf -fiv 
sudo ./configure 
sudo make 
sudo make install

Sitten voi kopioida nano /usr/local/etc/motion/ kansiossa olevan motion-dist-conf, template asetus tiedoston uudelle nimelle, motion.conf.

cp /usr/local/etc/motion/motion-dist-conf  /usr/local/etc/motion/motion.conf

Motion ohjelman perusasetukset voidaan nyt säätää motion.conf tiedostoa editoimalla.

nano /usr/local/etc/motion/motion.conf
############################################################
# System control configuration parameters
############################################################
# Start in daemon (background) mode and release terminal.
daemon on

# Start in Setup-Mode, daemon disabled.
setup_mode off


############################################################
# Image Processing configuration parameters
############################################################
# Image width in pixels.
width 1280

# Image height in pixels.
height 720

# Maximum number of frames to be captured per second.
framerate 10

# Text to be overlayed in the lower left corner of images
text_left CAMERA1

# Text to be overlayed in the lower right corner of images.
text_right %Y-%m-%d\n%T-%q


############################################################
# Motion detection configuration parameters
############################################################
# Always save pictures and movies even if there was no motion.
emulate_motion off

# Threshold for number of changed pixels that triggers motion.
threshold 1500

# Noise threshold for the motion detection.
; noise_level 32

# Despeckle the image using (E/e)rode or (D/d)ilate or (l)abel.
despeckle_filter EedDl

# Number of images that must contain motion to trigger an event.
minimum_motion_frames 1

# Gap in seconds of no motion detected that triggers the end of an event.
event_gap 60

# The number of pre-captured (buffered) pictures from before motion.
pre_capture 3

# Number of frames to capture after motion is no longer detected.
post_capture 0


############################################################
# Movie output configuration parameters
############################################################
# Create movies of motion events.
movie_output on

# Maximum length of movie in seconds.
movie_max_time 60

# The encoding quality of the movie. (0=use bitrate. 1=worst quality, 100=best)
movie_quality 45

# Container/Codec to used for the movie. See motion_guide.html
movie_codec mkv

# File name(without extension) for movies relative to target directory
movie_filename %t-%v-%Y%m%d%H%M%S


############################################################
# Webcontrol configuration parameters
############################################################
# Port number used for the webcontrol.
webcontrol_port 8080

# Restrict webcontrol connections to the localhost.
webcontrol_localhost off

# Type of configuration options to allow via the webcontrol.
webcontrol_parms 0


############################################################
# Live stream configuration parameters
############################################################

# The port number for the live stream.
stream_port 8081

# Restrict stream connections to the localhost.
stream_localhost off

Motion ohjelma voidaan laittaa käynnistymään automaattisesti, kun Raspberry Pi tietokone käynnistyy.

Esimerkiksi käynnistyksen rc.local tiedostoa voi editoida komennolla:

sudo nano /etc/rc.local 

Nyt voidaan lisätä muutama rivi, ennen exit 0 komentoa:


#KAYNNISTETAAN STARTISSA MOTION.  Tausta ajoon, & merkilla.
cd /usr/local/bin/
./motion &

Tämän jälkeen voidaan käynnistää Raspberry Pi tietokone uudelleen, ja testata saadaanko livestream kuvaa web selaimella.

Livestreami, on mahdollista jakaa ulos, reitittimen asetuksia muokkaamalla.