#szdiyCam
szdiyCam project runs on top of a Raspberry Pi with its camera board. It takes a picture every 20sec and uploads it to a custom image API server and QiNiu. The pictures taken are stored away in a local folder for later retrieval. The project is a community project by SZDIY Hackers' Community.
##Default Directory
The default directory can be changed in config.py
/tmp
for temporary picture storage before moving to a archive location/home/pi/szdiy_img
stores every pictures taken. They are sorted by date into different folders.
##Setup
-
Clone the project
cd szdiyCam
-
Setup virtual environment to ensure anything you did inside the directory does not pollute OS
virtualenv venv
-
Activate virtualenv
source venv/bin/activate
-
Install dependencies using pip
pip install -r requirements.txt
-
(optional) EXIF support
-
Install
pyexiv2
which is used to make sureexif
data is copied over correctlysudo apt-get install python-pyexiv2
-
Link the
pyexiv2
library to virtual environmentln -s /usr/lib/python2.7/dist-packages/libexiv2python.so venv/lib/python2.7/site-packages/ ln -s /usr/lib/python2.7/dist-packages/pyexiv2 venv/lib/python2.7/site-packages/
-
-
copy
credentials.py.sample
tocredentials.py
. You will need to arrange your own picture API server there. The sample used QiNiu and a custom written API image server backend which is not part of this project. But it can be easily extended for other image uploading service such as Imagur API by creating your own uploading functions. -
If you get a QiNiu API key successfully setup in step 6, you can now run without any issues
python main.py
-
(Optional) A clear archive script is added for maintenance. You can add it to crontab so it can run once everyday. $ crontab -e 0 0 * * * python /home/pi/szdiyCam/clearArchive.py 1>>/home/pi/szdiycam_cleararchive.log 2>> /home/pi/szdiycam_cleararchive.log &
###Wechat 微信 Wechat is integrated in the uploading process. Our backend server handles normal picture upload and Wechat API at a single URL endpoint (not included in this project).
uploadAFileToLinodeWithWXMediaID
handles uploading image to the Wechat server as well as our backend server. It reports the Wechat server response to our backend. Our backend will use this info to redeliver captured images stored on Wechat server to a Wechat App. To use without Wechat, use uploadAFileToLinode
instead.
###Setup as System Service
-
put
uploadingimage
under/etc/init.d/uploadingimage
-
Make it executable
sudo chmod +x uploadingimage
-
Make it run at startup
update-rc.d uploadingimage defaults
-
For debugging purpose, you can reconnect this session by running
sudo screen -r 'uploading image'
#License GPL V3
Copyright (C) 2014 SZDIY Hackers' Community
szdiyCam is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
szdiyCam is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with szdiyCam. If not, see <http://www.gnu.org/licenses/>.