def captureImage_thread(self): rtn_val = ArducamSDK.Py_ArduCam_beginCaptureImage(self.handle) if rtn_val != 0: print("Error beginning capture, rtn_val = ", rtn_val) self.running = False return else: print("Capture began, rtn_val = ", rtn_val) while self.running: if self.loading: rtn_val = ArducamSDK.Py_ArduCam_captureImage(self.handle) if rtn_val > 255: # print("Error capture image, rtn_val = ",rtn_val) if rtn_val == ArducamSDK.USB_CAMERA_USB_TASK_ERROR: break else: print("restarting camera...") # time.sleep(1) ArducamSDK.Py_ArduCam_endCaptureImage(self.handle) self.camera_initFromFile(self.fileName, self.expconf) ArducamSDK.Py_ArduCam_beginCaptureImage(self.handle) self.loading = True self.running = False ArducamSDK.Py_ArduCam_endCaptureImage(self.handle)
def captureImage_thread(): global handle, running, ct_lock, count1 rtn_val = ArducamSDK.Py_ArduCam_beginCaptureImage(handle) if rtn_val != 0: print "Error beginning capture, rtn_val = ", rtn_val running = False return else: print "Capture began, rtn_val = ", rtn_val while (running and (not rospy.is_shutdown())): #print "capture" if count1 == 0: if ct_lock.acquire(False): print "capture image", count1 rtn_val = ArducamSDK.Py_ArduCam_captureImage(handle) count1 = count1 + 1 if rtn_val != 0: print "Error capture image, rtn_val = ", rtn_val break else: time.sleep(0.005) ct_lock.release() else: time.sleep(0.005) else: time.sleep(0.005) running = False ArducamSDK.Py_ArduCam_endCaptureImage(handle)
def start_capture(self): self.logger.info("Start arducam capture thread") start_code = ArducamSDK.Py_ArduCam_beginCaptureImage(self.handle) if start_code != 0: raise ArducamException("Error starting capture thread", code=start_code) self.logger.debug("Thread started")
def start(self, full=True): self.logger.info("Start arducam capture thread") self.handle = {} if full: self.configure() else: self.connect_cam() self.running = True start_code = ArducamSDK.Py_ArduCam_beginCaptureImage(self.handle) if start_code != 0: raise ArducamException("Error starting capture thread", code=start_code) start_thread(self.read_frames) self.extra_info = self.get_extra_label_info() self.logger.info("Arducam thread started")
def capture_thread(self): global handle, running rtn_val = ArducamSDK.Py_ArduCam_beginCaptureImage(handle) if rtn_val != 0: print("Error beginning capture, rtn_val = ", rtn_val) else: logging.info("Capture began, rtn_val = ", rtn_val) while running: rtn_val = ArducamSDK.Py_ArduCam_captureImage(handle) if rtn_val > 255: #print("Error capture image, rtn_val = ", rtn_val) if rtn_val == ArducamSDK.USB_CAMERA_USB_TASK_ERROR: print("ardu cam USB_CAMERA_USB_TASK_ERROR!!") time.sleep(0.01)
def captureImage_thread(): global handle,running rtn_val = ArducamSDK.Py_ArduCam_beginCaptureImage(handle) if rtn_val != 0: print "Error beginning capture, rtn_val = ",rtn_val running = False return else: print "Capture began, rtn_val = ",rtn_val while running: #print "capture" rtn_val = ArducamSDK.Py_ArduCam_captureImage(handle) if rtn_val != 0: print "Error capture image, rtn_val = ",rtn_val break time.sleep(0.005) running = False ArducamSDK.Py_ArduCam_endCaptureImage(handle)
def captureImage_thread(): global handle, running rtn_val = ArducamSDK.Py_ArduCam_beginCaptureImage(handle) if rtn_val != 0: print("Error beginning capture, rtn_val = ", rtn_val) running = False return else: print("Capture began, rtn_val = ", rtn_val) while running: #print "capture" rtn_val = ArducamSDK.Py_ArduCam_captureImage(handle) if rtn_val > 255: print("Error capture image, rtn_val = ", rtn_val) if rtn_val == ArducamSDK.USB_CAMERA_USB_TASK_ERROR: break time.sleep(0.005) running = False ArducamSDK.Py_ArduCam_endCaptureImage(handle)
def captureImage_thread(): global handle, running rtn_val = ArducamSDK.Py_ArduCam_beginCaptureImage(handle) if rtn_val != 0: print("Failed to begin capture, return value: %s." % (rtn_val)) running = False return else: print("Capture began: %s." % (rtn_val)) while running: # print "capture" rtn_val = ArducamSDK.Py_ArduCam_captureImage(handle) if rtn_val > 255: print("Error while capturing image: %s." % (rtn_val)) if rtn_val == ArducamSDK.USB_CAMERA_USB_TASK_ERROR: break time.sleep(0.005) running = False ArducamSDK.Py_ArduCam_endCaptureImage(handle)
def captureImage_thread(): global handle, running rtn_val = ArducamSDK.Py_ArduCam_beginCaptureImage(handle) if rtn_val != 0: print "Error beginning capture, rtn_val = ", rtn_val running = False return else: print "Capture began, rtn_val = ", rtn_val while (running and (not rospy.is_shutdown())): #print "capture" time0 = time.time() rtn_val = ArducamSDK.Py_ArduCam_captureImage(handle) time1 = time.time() print str(time1 - time0) if rtn_val != 0: print "Error capture image, rtn_val = ", rtn_val break time.sleep(0.005) running = False ArducamSDK.Py_ArduCam_endCaptureImage(handle)
try: h_flip = rospy.get_param("~horizontal_flip") except: h_flip = False try: v_flip = rospy.get_param("~vertical_flip") except: v_flip = False try: id_frame = rospy.get_param("~frame_id") except: print "Please input frame_id." exit() if camera_initFromFile(config_file_name): ArducamSDK.Py_ArduCam_setMode(handle,ArducamSDK.CONTINUOUS_MODE) rtn_val = ArducamSDK.Py_ArduCam_beginCaptureImage(handle) if rtn_val != 0: print "Error beginning capture, rtn_val = ",rtn_val exit() else: print "Capture began, rtn_val = ",rtn_val service_write = rospy.Service('arducam/write_reg', WriteReg, write_register) service_read = rospy.Service('arducam/read_reg', ReadReg, read_register) service_capture = rospy.Service('arducam/capture', Capture, capture) rospy.on_shutdown(rosShutdown) while not rospy.is_shutdown(): captureImage()