demonmaestro
Posts: 21
Joined: Fri Jun 07, 2013 10:07 am

Take Timed Pictures and Upload

Sat Jun 14, 2014 2:01 am

Okay is there any software or something that i can use that will take a picture from a webcam at say ever 60 minutes and upload them via ftp to a server?

Thank you for all the help in advanced.! :D

danjperron
Posts: 2854
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Take Timed Pictures and Upload

Sat Jun 14, 2014 2:47 am

Check post for time lapse.

A lot of them use motion or mjpg-streamer.

I prefer mjpg-streamer but your webcam need to be mjpeg compatible.


http://www.raspberrypi.org/forums/viewt ... 19#p471519


1- I use crontab to capture one image every minute to create time lapse. Every hour will be the same thing.
2- I also add a water mark with the current time and temperature.
3- Then I transfer the image into my NAS server , a Mybook live from WD.
4- At midnight every day , a cron tab script take each snapshot and record a small video of the day.


This is an example of timelapse. One picture every minute.

https://dl.dropboxusercontent.com/u/488 ... _12_15.mp4

I do have a D.I.Y but it is in french and it's more than timelapse. The state is still preliminary.

https://docs.google.com/document/d/1512 ... sp=sharing


If you decide to try mjpg-streamer , these scripts will help you to start

First, a script to start mjpg-streamer with a 720P webcam (compatible mjpeg)

streamer720p.sh

Code: Select all

killall mjpg_streamer
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -n -f 10 -r 1280x720" -o "/usr/local/lib/output_http.so -p 
10088 -w /usr/local/www" &

A script to capture and transfer image into a ftp site

SnapShot.py

Code: Select all

#!/usr/bin/python
import time
import os
import sys
import re
import subprocess
import datetime

now = datetime.datetime.now()

# capture image

SnapImage = "/var/www/chart/data/image.jpg"

subprocess.call(["/usr/bin/wget","-O",SnapImage,"http://127.0.0.1:10088/?action=snapshot"])

# create a stamp image file
StampImage = "PondImg_" + now.strftime("%Y_%m_%d_%H_%M_%S") + (".jpg")


# transfer image to mycloud WD disk

subprocess.call(["/usr/local/bin/FtpImage.sh",SnapImage,StampImage,"userName","userPassword"])
And the script to ftp

ftpImage.sh

Code: Select all

#!/bin/bash

IN_LOCAL=$1
OUT_REMOTE=$2

USER=$3
PASSWD=$4
sleep 5
ftp -v -n 10.11.12.4 <<END_OF_SESSION
user $USER $PASSWD
cd /Daniel/PiData/Images
prompt off
binary
put $IN_LOCAL $OUT_REMOTE
bye
END_OF_SESSION
Daniel
Last edited by danjperron on Sat Jun 14, 2014 3:00 am, edited 1 time in total.

demonmaestro
Posts: 21
Joined: Fri Jun 07, 2013 10:07 am

Re: Take Timed Pictures and Upload

Sat Jun 14, 2014 2:55 am

Thank you for responding. But I am just wanting to take a picture ever hour and upload it to my web server that is all.

The link you sent me to for mjpg-streamer is the one i had wrote.

danjperron
Posts: 2854
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Take Timed Pictures and Upload

Sat Jun 14, 2014 3:06 am

Create a script with fswebcam to capture image and use the script from my post to transfer in ftp

Run the script by crontab every hour

Daniel

demonmaestro
Posts: 21
Joined: Fri Jun 07, 2013 10:07 am

Re: Take Timed Pictures and Upload

Sat Jun 14, 2014 3:47 am

I was to be honest looking for step by step instructions ;)

User avatar
DougieLawson
Posts: 32352
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Take Timed Pictures and Upload

Sat Jun 14, 2014 9:09 am

demonmaestro wrote:I was to be honest looking for step by step instructions ;)
http://www.instructables.com/id/Simple- ... i-and-a-c/

You'll want to update the code
time.sleep(60)
to
time.sleep(3600)
so that it only gets a photo every hour (rather than every minute)
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

danjperron
Posts: 2854
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Take Timed Pictures and Upload

Sat Jun 14, 2014 1:26 pm

In the learning place,

the timelapse method is already there in step by step mode.

http://www.raspberrypi.org/learning/web ... pse-setup/

The only thing to change is the script you put into the crontab.

1 - install fswebcam
sudo apt-get install fswebcam

2- install ftp
sudo apt-get install ftp

3- create a script to capture and transfer via ftp

Code: Select all

#!/bin/bash

#change these parameters to fit your need

IN_LOCAL=snapImg.jpg
OUT_REMOTE=snapImg.jpg

USER=Daniel
PASSWD=12345
SERVERIP=10.11.12.4


#do fswebcam twice , the first is to get webcam in stable condition
fswebcam -r 1280x720 --no-banner /dev/null -F 3
sleep 2
fswebcam -r 1280x720 --no-banner   $IN_LOCAL

#ok now we will transfer via ftp


/usr/bin/ftp -v -n $SERVERIP <<END_OF_SESSION
user $USER $PASSWD
cd /Daniel/SnapFolder
prompt off
binary
put $IN_LOCAL $OUT_REMOTE
bye
END_OF_SESSION
4 - make it runnable

sudo chmod +x SnapShot.sh

5 - finally add the script into the crontab.
sudo crontab -e

0 * * * * /home/pi/SnapShot.sh


I prefer crontab for two reasons. you are not using resource in between snapshot and in case of software crash/kill it will restart itself every hour.

I hope this is good enough for you.

B.T.W. if you are using sftp instead , it will be better since you could use scp command. But this is a different story.

N.B. I use a static file name. If you want to keep the image you will need to add the date stamp into the file.

Daniel

Return to “Graphics, sound and multimedia”

Who is online

Users browsing this forum: No registered users and 5 guests