Created
March 3, 2015 18:41
-
-
Save aviraldg/00a0312f4723a942d66b to your computer and use it in GitHub Desktop.
This file contains hidden or 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/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