Created
June 29, 2015 19:46
-
-
Save aviraldg/72ea988781c6295c822a to your computer and use it in GitHub Desktop.
post-commit
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/python | |
import subprocess, cv2, os | |
PATH = os.environ.get('GITPIC_PATH') | |
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