示例#1
0
    def CaptureFrame(self, skip_pin_trig=False, skip_manual_trig=False):
        '''
		 @brief Capture image
		 	Pin triggering is handled if it is set.

		 @param skip_pin_trig (True/False for skipping trigging a new frame on the Ptgrey)
		 @param skip_manual_trig (True/False for skipping manual trig.)

		 @return frame
		'''
        self.AssertCameraCapturing()
        if not (skip_manual_trig):
            self.ManualTriggering()
        if self.__mc_trigger_pin.GetPin() >= 0 and not (skip_pin_trig):
            self.__mc_trigger_pin.TogglePin()
        t = RunThread(self.RetrieveBufferThread)
        if self.__capture_timeout >= 0:
            t.join(self.__capture_timeout)
        else:
            t.join()
        if t.isAlive():
            raise PtGreyError('timeout_capturing_frame_error_msg')
        elif self.__error_flag:
            self.__error_flag = False
            raise PtGreyError('failed_capturing_frame_error_msg')
        if self.CheckManualTriggering():
            time.sleep(
                1.0
            )  # Sleep camera if manual trig to make it dump the image buffer.
        return np.array(self.__frame_object)
示例#2
0
    def ImportFlyCapture2(self):
        '''
		 @brief import pyflycapture2
		 	raies import_flycapture2_error_msg error if flycapture2 library is not available.
		'''
        try:
            import flycapture2 as fc2
            self.__fc2 = fc2
        except ImportError:
            raise PtGreyError('import_fc2_error_msg')
示例#3
0
    def ConnectCamera(self):
        '''
		 @brief connect to camera

		 @return camera_info
		'''
        # Ensure sufficient cameras are found
        bus = self.__fc2.BusManager()
        numCams = bus.getNumOfCameras()
        self.__fc2_camera = self.__fc2.Context()
        if bus.getNumOfCameras() == 0:
            raise PtGreyError('camera_not_connected_error_msg')
        self.__fc2_camera = self.__fc2.Camera()
        self.__fc2_camera.connect(bus.getCameraFromIndex(0))
        self.__frame_object = self.__fc2.Image()

        # Power on the Camera
        cameraPower = 0x610
        powerVal = 0x80000000

        self.__fc2_camera.writeRegister(cameraPower, powerVal)

        # Waiting for camera to power up
        retries = 10
        timeToSleep = 0.1  #seconds
        for i in range(retries):
            sleep(timeToSleep)
            try:
                regVal = self.__fc2_camera.readRegister(cameraPower)
            except self.__fc2.Fc2error:  # Camera might not respond to register reads during powerup.
                pass
            awake = True
            if regVal == powerVal:
                break
            awake = False
        if not awake:
            print "Could not wake Camera. Exiting..."
            raise PtGreyError('camera_not_connected_error_msg')

        self.__camera_connected = True
        return self.GetCameraInfo()
示例#4
0
    def ConnectCamera(self):
        '''
		 @brief connect to camera

		 @return camera_info
		'''
        self.__fc2_camera = self.__fc2.Context()
        if self.__fc2_camera.get_num_of_cameras() == 0:
            raise PtGreyError('camera_not_connected_error_msg')
        self.__fc2_camera.connect(*self.__fc2_camera.get_camera_from_index(0))
        self.__frame_object = self.__fc2.Image()
        self.__camera_connected = True
        return self.GetCameraInfo()
    def __init__(self, pin, out_pin=True):
        '''CONSTRUCTOR'''
        try:
            import wiringpi2 as wpi
            self.__wpi = wpi
        except ImportError:
            raise PtGreyError('wiringpi_not_available_error_msg')

        self.__wpi.wiringPiSetup()
        self.SetPin(pin)
        if out_pin:
            self.SetPinOut()
        else:
            self.SetPinIn()
示例#6
0
    def AssertCameraCapturing(self):
        '''
		 @brief Assert camera capturing
		'''
        if not (self.CheckCapturing()):
            raise PtGreyError('camera_not_capturing_error_msg')
示例#7
0
    def AssertCameraConnected(self):
        '''
		 @brief Assert camera connected
		'''
        if self.__fc2_camera == None or not (self.__camera_connected):
            raise PtGreyError('camera_not_connected_error_msg')
示例#8
0
    def AssertFlyCapture2(self):
        '''
		 @brief Assert that the flycapture2 library is available
		'''
        if self.__fc2 == None:
            raise PtGreyError('import_flycapture2_error_msg')