Skip to content

Instantly share code, notes, and snippets.

@aviraldg
Created March 3, 2015 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aviraldg/00a0312f4723a942d66b to your computer and use it in GitHub Desktop.
Save aviraldg/00a0312f4723a942d66b to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import subprocess, cv2, os
PATH = '/home/aviraldg/Pictures/gitpic/'
def main():
sha = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
repo_name = os.path.basename(subprocess.check_output(["git", "rev-parse", "--show-toplevel"])).strip()
try:
os.makedirs(os.path.join(PATH, repo_name))
except OSError:
pass
outpath = os.path.abspath(os.path.join(PATH, repo_name, '%s.jpg' % sha))
import cv2
camera_port = 0
camera = cv2.VideoCapture(camera_port)
return_value, image = camera.read()
cv2.imwrite(outpath, image)
del(camera) # so that others can use the camera as soon as possible
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment