Created
June 25, 2016 05:01
-
-
Save chrisvoncsefalvay/b73f5ec2cbb88beb30ca8297aea279cf to your computer and use it in GitHub Desktop.
Processing injector for live image analysis
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
| import numpy as np | |
| import imutils | |
| import argparse | |
| import cv2 | |
| def analyse_image(frame): | |
| # Put your image processing code here... | |
| return frame | |
| # Construct argument parser & parse arguments | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("-i", "--image", help="Path to the image") | |
| args = vars(ap.parse_args()) | |
| if args["image"]: | |
| imgbuff = cv2.imread(args["image"]) | |
| else: | |
| vc = cv2.VideoCapture(0) | |
| while True: | |
| if args["image"]: | |
| cv2.imshow("Original image", imgbuff) | |
| else: | |
| _, imgbuff = vc.read() | |
| primage = analyse_image(imgbuff) | |
| cv2.imshow("image_analysis", primage) | |
| k = cv2.waitKey(30) & 0xFF | |
| if k == 27: | |
| if vc: | |
| vc.release() | |
| cv2.destroyAllWindows() | |
| break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment