Created
April 12, 2013 12:39
-
-
Save Luzifer/5371726 to your computer and use it in GitHub Desktop.
This script is designed to work with an HooToo IPCamera you can for example buy at http://goo.gl/V3H2W - It will take one picture every n seconds and store them named by current time in one folder so you later on can assemble them into a timelapse video.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This script is designed to work with an HooToo IPCamera you can for example | |
# buy at http://goo.gl/V3H2W - It will take one picture every n seconds and | |
# store them named by current time in one folder so you later on can assemble | |
# them into a timelapse video. | |
# | |
# Copyright (C) 2013 Knut Ahlers <[email protected]> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all | |
# copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
# SOFTWARE. | |
import urllib, sys, os, time | |
from datetime import datetime | |
if len(sys.argv) != 6: | |
print 'Usage: %s <ip / hostname of the camera> <username> <password> <seconds between shots> <output directory>' % sys.argv[0] | |
sys.exit(1) | |
if not os.path.exists(sys.argv[5]): | |
print 'Please create target directory' | |
sys.exit(2) | |
imageurl = 'http://%s/snapshot.cgi?resolution=64&user=%s&pwd=%s' % (sys.argv[1], sys.argv[2], sys.argv[3]) | |
print 'Starting to fetch from "%s"' % imageurl | |
try: | |
while True: | |
imagedata = urllib.urlopen(imageurl).read() | |
imagename = '%s.jpg' % datetime.now().strftime('%Y-%m-%d_%H-%M-%S') | |
filename = os.path.join(sys.argv[5], imagename) | |
open(filename, 'w').write(imagedata) | |
print 'Saved "%s"...' % filename | |
time.sleep(int(sys.argv[4])) | |
except KeyboardInterrupt: | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment