raise ValueError else: lockFile.lock() try: FPSCounter = FPS() FPSCounter.start() cam = cv2.VideoCapture(0) cam.set(3,640) cam.set(4,480) #cam.set(cv2.cv.CV_CAP_PROP_BRIGHTNESS, brightness) #cam.set(cv2.cv.CV_CAP_PROP_SATURATION, saturation) #cam.set(cv2.cv.CV_CAP_PROP_EXPOSURE, exposure) # not working on the old camera visionManager = VisionManager(LB, UB, MBR, cam, KH, KW, FL, [RH,RW,RL], TH, CUW, CUWD, HAX, HAY) networkManager = NetworkManager(JAVA_IP,8080) ################### # The code itself # ################### while True: visionManager.updateImage() visionManager.updateTowerScales() visionManager.updateRobotScales() FPSCounter.update() if visionManager.isObjectDetected: # if an object was detected
action="store_true", default=False, help="Enable network communications") return parser.parse_args() if __name__ == "__main__": if lockFile.is_locked(): raise ValueError("Lock File Locked!") else: lockFile.lock() args = parse_arguments() try: vision_manager = VisionManager() except ValueError, ex: logger.error("Failed initializing VisionManager: %s", ex.message) raise if args.enable_network: try: network_manager = NetworkManager(args.host, args.port) except Exception, ex: logger.error("Unhandled Exception:\n" + traceback.format_exc()) raise else: network_manager = None FPSCounter = FPS() FPSCounter.start()
raise ValueError else: lockFile.lock() try: FPSCounter = FPS() FPSCounter.start() cam = cv2.VideoCapture(0) cam.set(3, 640) cam.set(4, 480) # cam.set(cv2.cv.CV_CAP_PROP_BRIGHTNESS, brightness) # cam.set(cv2.cv.CV_CAP_PROP_SATURATION, saturation) # cam.set(cv2.cv.CV_CAP_PROP_EXPOSURE, exposure) # not working on the old camera visionManager = VisionManager(LB, UB, MBR, cam, KH, KW, FL, [RH, RW, RL], TH, CUW, CUWD, HAX, HAY) networkManager = NetworkManager(JAVA_IP, 8080) ################### # The code itself # ################### while True: visionManager.updateImage() visionManager.updateTowerScales() visionManager.updateRobotScales() FPSCounter.update() if visionManager.isObjectDetected: # if an object was detected
parser.add_argument("--dump_image", action="store_true", default=False, help="Dump images to current working directory") parser.add_argument("--enable_network", action="store_true", default=False, help="Enable network communications") return parser.parse_args() if __name__ == "__main__": if lockFile.is_locked(): raise ValueError("Lock File Locked!") else: lockFile.lock() args = parse_arguments() try: vision_manager = VisionManager() except ValueError, ex: logger.error("Failed initializing VisionManager: %s", ex.message) raise if args.enable_network: try: network_manager = NetworkManager(args.host, args.port) except Exception, ex: logger.error("Unhandled Exception:\n" + traceback.format_exc()) raise else: network_manager = None FPSCounter = FPS() FPSCounter.start()