Esempio n. 1
0
 def capture_image(self):
     self.running = True
     rtn_val = ArducamSDK.Py_ArduCam_beginCaptureImage(self.cam.handle)
     if rtn_val != 0:
         raise ImageCaptureException(
             "Error beginning capture, rtn_val: {}".format(rtn_val))
     self.logger.info("Starting image capture for dev: {}".format(
         self.cam.dev_id))
     while self.running:
         try:
             rtn_val = ArducamSDK.Py_ArduCam_captureImage(self.cam.handle)
             if rtn_val > 255:
                 if rtn_val == ArducamSDK.USB_CAMERA_USB_TASK_ERROR:
                     raise USBCameraTaskError(
                         "USB task error: {}".format(rtn_val))
                 raise ImageCaptureException(
                     "Error capture image, rtn_val: ".format(rtn_val))
             time.sleep(0.005)
         except ImageCaptureException as e:
             self.logger.warning(
                 "Non critical error capturing image: {}".format(str(e)))
Esempio n. 2
0
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)