def Set_Values(cam, exposure, gain, blacklevel, automode):
    """sets the exposure time and gain of the camera"""
    exposure = ueye.double(exposure)
    expo = ueye.double()
    gain = ueye.int(gain)
    # sets the exposure time and gain with the values
    # or sets them automatically
    if automode is False:
        ueye.is_SetHardwareGain(cam, gain, ueye.IS_IGNORE_PARAMETER,
                                ueye.IS_IGNORE_PARAMETER,
                                ueye.IS_IGNORE_PARAMETER)
        ueye.is_Exposure(cam, ueye.IS_EXPOSURE_CMD_SET_EXPOSURE, exposure,
                         ueye.ueye.sizeof(exposure))
        expo = exposure
        ueye.is_Blacklevel(cam, ueye.IS_BLACKLEVEL_CMD_SET_OFFSET, blacklevel)
    elif automode is True:
        pval1 = ueye.double(1)
        pval2 = ueye.double(0)
        ueye.is_SetAutoParameter(cam, ueye.IS_SET_ENABLE_AUTO_GAIN, pval1,
                                 pval2)
        pval1 = ueye.double(1)
        pval2 = ueye.double(0)
        ueye.is_SetAutoParameter(cam, ueye.IS_SET_ENABLE_AUTO_SHUTTER, pval1,
                                 pval2)
    return Get_Values(cam.value, expo.value)
예제 #2
0
 def setHarwareGain(self, gain_val):
     current_gain = ueye.is_SetHardwareGain(self.cam,
                                            ueye.IS_GET_MASTER_GAIN,
                                            ueye.IS_IGNORE_PARAMETER,
                                            ueye.IS_IGNORE_PARAMETER,
                                            ueye.IS_IGNORE_PARAMETER)
     hasWorked = ueye.is_SetHardwareGain(self.cam, int(gain_val),
                                         ueye.IS_IGNORE_PARAMETER,
                                         ueye.IS_IGNORE_PARAMETER,
                                         ueye.IS_IGNORE_PARAMETER)
     self.check(hasWorked, 'is_SetHardwareGain')
예제 #3
0
    def connect(self):
        """ Connects to the USB camera, creates main controlling object + prints out confirmation """
        connectRet = ueye.is_InitCamera(self.CamID, None)

        if connectRet == 0:  # on succesful connection
            self.connected = True
            self.sensorInfo = ueye.SENSORINFO()
            print('IDS camera connected.')
            ueye.is_GetSensorInfo(self.CamID, self.sensorInfo)

            self.sensorHeight_ctype, self.sensorWidth_ctype = self.sensorInfo.nMaxHeight, self.sensorInfo.nMaxWidth
            self.currentHeight, self.currentWidth = self.sensorHeight_ctype.value, self.sensorWidth_ctype.value

            # Settings block
            ueye.is_PixelClock(self.CamID, ueye.IS_PIXELCLOCK_CMD_SET,
                               ueye.c_int(self.pixelClock),
                               ueye.sizeof(ueye.c_int(self.pixelClock)))
            self.currentFPS = ueye.c_double(0)

            #ueye.is_SetFrameRate(self.CamID, ueye.c_int(self.FPS),self.currentFPS)

            ueye.is_SetDisplayMode(self.CamID, ueye.IS_SET_DM_DIB)
            ueye.is_SetColorMode(self.CamID, ueye.IS_CM_SENSOR_RAW12)

            ueye.is_SetAutoParameter(self.CamID, ueye.IS_SET_ENABLE_AUTO_GAIN,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(self.CamID,
                                     ueye.IS_SET_ENABLE_AUTO_SENSOR_GAIN,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(self.CamID,
                                     ueye.IS_SET_ENABLE_AUTO_SHUTTER,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(self.CamID,
                                     ueye.IS_SET_ENABLE_AUTO_SENSOR_SHUTTER,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(self.CamID,
                                     ueye.IS_SET_ENABLE_AUTO_WHITEBALANCE,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(
                self.CamID, ueye.IS_SET_ENABLE_AUTO_SENSOR_WHITEBALANCE,
                ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetHardwareGain(self.CamID, ueye.c_int(0), ueye.c_int(0),
                                    ueye.c_int(0), ueye.c_int(0))

            # Show a pattern (for testing)
            #ueye.is_SetSensorTestImage(self.CamID,ueye.IS_TEST_IMAGE_HORIZONTAL_GREYSCALE, ueye.c_int(0))

        else:
            print('Camera connecting failure...')
def Get_Values(cam, exposure):
    """gets the current exposure time and gain of the camera"""
    exposure = ueye.double(exposure)
    gain = ueye.int()
    ueye.is_Exposure(cam, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE, exposure,
                     ueye.sizeof(exposure))
    gain = ueye.is_SetHardwareGain(cam, ueye.IS_GET_MASTER_GAIN,
                                   ueye.IS_IGNORE_PARAMETER,
                                   ueye.IS_IGNORE_PARAMETER,
                                   ueye.IS_IGNORE_PARAMETER)
    return exposure.value, gain
예제 #5
0
    def Camera_Initialization(self):
        self.hcam = ueye.HIDS(0)
        self.ret = ueye.is_InitCamera(self.hcam, None)
        self.ret = ueye.is_SetColorMode(self.hcam, ueye.IS_CM_MONO12)
        self.IDS_FPS = float(50)
        self.newrate = ueye.DOUBLE(self.IDS_FPS)
        self.rate = ueye.DOUBLE(self.IDS_FPS)
        self.IDS_exposure = float(20)

        self.width = 2056
        self.height = 1542
        self.rect_aoi = ueye.IS_RECT()
        self.rect_aoi.s32X = ueye.int(0)
        self.rect_aoi.s32Y = ueye.int(0)
        self.rect_aoi.s32Width = ueye.int(self.width)
        self.rect_aoi.s32Height = ueye.int(self.height)
        ueye.is_AOI(self.hcam, ueye.IS_AOI_IMAGE_SET_AOI, self.rect_aoi,
                    ueye.sizeof(self.rect_aoi))

        self.mem_ptr = ueye.c_mem_p()
        self.mem_id = ueye.int()
        self.bitspixel = 16
        self.ret = ueye.is_AllocImageMem(self.hcam, self.width, self.height,
                                         self.bitspixel, self.mem_ptr,
                                         self.mem_id)

        self.ret = ueye.is_SetImageMem(self.hcam, self.mem_ptr, self.mem_id)
        self.ret = ueye.is_CaptureVideo(self.hcam, ueye.IS_DONT_WAIT)
        #self.lineinc = self.width * int((self.bitspixel + 7) / 8)
        self.lineinc = self.width * int(self.bitspixel / 8)

        self.nRet = ueye.is_SetFrameRate(self.hcam, self.rate, self.newrate)
        self.expms = ueye.DOUBLE(self.IDS_exposure)
        self.nRet = ueye.is_Exposure(self.hcam,
                                     ueye.IS_EXPOSURE_CMD_SET_EXPOSURE,
                                     self.expms, ueye.sizeof(self.expms))

        self.pixelclock = ueye.c_uint(197)
        self.nRet = ueye.is_PixelClock(self.hcam, ueye.IS_PIXELCLOCK_CMD_SET,
                                       self.pixelclock, 4)
        #pixelclock = ueye.c_uint()
        #ueye.is_PixelClock(hcam, ueye.IS_PIXELCLOCK_CMD_GET, pixelclock, 4)

        self.nRet = ueye.is_SetHardwareGain(self.hcam, 100,
                                            ueye.IS_IGNORE_PARAMETER,
                                            ueye.IS_IGNORE_PARAMETER,
                                            ueye.IS_IGNORE_PARAMETER)
        #gg = ueye.c_uint()
        #ueye.is_SetHWGainFactor(hcam, ueye.IS_GET_MASTER_GAIN_FACTOR, gg)
        self.nRet = ueye.is_SetHardwareGamma(self.hcam,
                                             ueye.IS_SET_HW_GAMMA_ON)
예제 #6
0
 def get_gain(self):
     """
     Get the current gain.
     Returns
     =======
     gain: number
         Current gain
     """
     self.gain = ueye.is_SetHardwareGain(self.cam, 
                                         ueye.IS_GET_MASTER_GAIN, 
                                         ueye.IS_IGNORE_PARAMETER, 
                                         ueye.IS_IGNORE_PARAMETER,
                                         ueye.IS_IGNORE_PARAMETER)
     return self.gain 
 def set_hw_gain(self, gain):
     """
     Set the master amplification. It can be tuned between 0% and 100%.
     :param gain: amplification to be set
     :return: None
     """
     gn = ueye.UINT(int(gain))
     # nRet = ueye.is_SetHWGainFactor(self.cam, ueye.IS_SET_MASTER_GAIN_FACTOR, gn)
     # if not ueye.is_SetHardwareGain(self.cam, gn, ueye.IS_IGNORE_PARAMETER, ueye.IS_IGNORE_PARAMETER,
     #                                ueye.IS_IGNORE_PARAMETER) == ueye.IS_SUCCESS:
     if not ueye.is_SetHardwareGain(self.cam, gn, ueye.UINT(int(0)), ueye.INT(int(0)),
                                    ueye.INT(int(0))) == ueye.IS_SUCCESS:
         raise RuntimeError("Gain not set")
     print("Master gain set to", gn.value)
예제 #8
0
    def configure(self, parameters):
        # Exposure varies by camera: 0.020ms to 69.847 for UI-3250 model (check uEye cockpit for specifics)
        # Gain (master) can be set between 0-100
        # Black level can be set between 0-255
        # Gamma can be set between 0.01 and 10

        #Set dict keys to all lower case
        parameters = dict((k.lower(), v) for k, v in parameters.items())

        if 'exposure' in parameters:
            #Doesn't do anything
            err = ueye.is_Exposure(
                self._cam, ueye.IS_EXPOSURE_CMD_SET_EXPOSURE,
                ueye.DOUBLE(parameters['exposure']),
                ueye.sizeof(ueye.DOUBLE(parameters['exposure'])))
            if err != ueye.IS_SUCCESS:
                raise CameraException(self._cam, 'ueye>configure>exposure>',
                                      err)

        if 'gain' in parameters:
            err = ueye.is_SetHardwareGain(self._cam,
                                          ueye.INT(parameters['gain']),
                                          ueye.IS_IGNORE_PARAMETER,
                                          ueye.IS_IGNORE_PARAMETER,
                                          ueye.IS_IGNORE_PARAMETER)
            if err != ueye.IS_SUCCESS:
                raise CameraException(self._cam, 'ueye>configure>gain>', err)

        if 'black_level' in parameters:
            err = ueye.is_Blacklevel(
                self._cam, ueye.IS_BLACKLEVEL_CMD_SET_OFFSET,
                ueye.INT(parameters['black_level']),
                ueye.sizeof(ueye.INT(parameters['black_level'])))
            if err != ueye.IS_SUCCESS:
                raise CameraException(self._cam, 'ueye>configure>black_level>',
                                      err)

        if 'gamma' in parameters:
            # Digital gamma correction
            err = ueye.is_Gamma(
                self._cam, ueye.IS_GAMMA_CMD_SET,
                ueye.INT(int(parameters['gamma'] * 100)),
                ueye.sizeof(ueye.INT(int(parameters['gamma'] * 100))))
            if err != ueye.IS_SUCCESS:
                raise CameraException(self._cam, 'ueye>configure>gamma>', err)
예제 #9
0
 def configure_camera(self, mode='RGB8', **kwargs):
     err = pue.is_SetDisplayMode(self.cam, pue.IS_SET_DM_DIB)
     if err != pue.IS_SUCCESS:
         raise CameraException(self.cam,
                               'ueye>configure_image>set_display_mode>',
                               err)
     err = pue.is_SetExternalTrigger(self.cam, pue.IS_SET_TRIGGER_SOFTWARE)
     if err != pue.IS_SUCCESS:
         raise CameraException(self.cam,
                               'ueye>configure_image>set_trigger>', err)
     err = pue.is_SetHardwareGain(self.cam, 0, 24, 0, 30)
     if err != pue.IS_SUCCESS:
         raise CameraException(self.cam,
                               'ueye>configure_image>set_hardware_gain>',
                               err)
     err = pue.is_SetHardwareGamma(self.cam, pue.IS_SET_HW_GAMMA_OFF)
     if err != pue.IS_SUCCESS:
         raise CameraException(self.cam,
                               'ueye>configure_image>set_hardware_gamma>',
                               err)
     '''
예제 #10
0
    def set_gain(self, mGain, rGain, gGain, bGain):
        """
        Set gain

        Params
        ======
        mGain: integer
            master gain value
        rGain: integer
            red gain value, default value 0
        gGain: integer
            green gain value, default value 0
        bGain: integer
            blue gain value, default value 0
        """
        self.nRet = ueye.is_SetHardwareGain(self.cam, 
                                            mGain, 
                                            rGain, 
                                            gGain,
                                            bGain)
        if self.nRet != ueye.IS_SUCCESS:
            error_log(self.nRet, "is_SetHardwareGain")
예제 #11
0
if nRet != ueye.IS_SUCCESS:
    print("is_InquireImageMem ERROR")
else:
    print("Press q to leave the program")
a=20



a=ueye.DOUBLE(30)
c=ueye.DOUBLE()
b=ueye.UINT(8)
thing=ueye.is_Exposure(hCam,ueye.IS_EXPOSURE_CMD_SET_EXPOSURE, a,b )
thing=ueye.is_Exposure(hCam,ueye.IS_EXPOSURE_CMD_GET_EXPOSURE, c,b )
print(c)
gain=ueye.UINT(80)
thingy=ueye.is_SetHardwareGain(hCam,gain, ueye.IS_IGNORE_PARAMETER, ueye.IS_IGNORE_PARAMETER, ueye.IS_IGNORE_PARAMETER)
#---------------------------------------------------------------------------------------------------------------------------------------
nRet = ueye.is_FreezeVideo(hCam, ueye.IS_WAIT)
Iinfo=ueye.UEYEIMAGEINFO()
n=1

while(nRet == ueye.IS_SUCCESS):

    
    # In order to display the image in an OpenCV window we need to...
    # ...extract the data of our image memory
    array = ueye.get_data(pcImageMemory, width, height, nBitsPerPixel, pitch, copy=False)
    

    # bytes_per_pixel = int(nBitsPerPixel / 8)
예제 #12
0
파일: camera.py 프로젝트: netzo92/pypyueye
 def set_gain(self, master, r, g, b):
     ueye.is_SetHardwareGain(self.h_cam, master, r, g, b)
예제 #13
0
 def set_gain(self, value):
     value = int(value)
     ueye.is_SetHardwareGain(self.hcam, value, 1, 1, 1)
예제 #14
0
if nRet != ueye.IS_SUCCESS:
    print("SetFrame ERROR:\t", nRet)
else:
    print("FramesPerSecond:\t", myFrameRate)

# Set EXPOSURE TIME
# nRet = is_Exposure(m_hCam, IS_EXPOSURE_CMD_SET_EXPOSURE, (void*)&m_ExposureTime, sizeof(m_ExposureTime));
#IS_EXPOSURE_CMD_SET_EXPOSURE = 12
nRet = ueye.is_Exposure(hCam, 12, myExposure, 8)  #sizeof(myExposure) )
if nRet != ueye.IS_SUCCESS:
    print("Exposure ERROR:\t", nRet)
else:
    print("Exposure set to:\t", myExposure)

# Set GAIN
nRet = ueye.is_SetHardwareGain(hCam, myGain, -1, -1, -1)
if nRet != ueye.IS_SUCCESS:
    print("SetGain ERROR:\t", nRet)
else:
    print("Gain set to:\t", myGain)

# Activates the camera's live video mode (free run mode)
nRet = ueye.is_CaptureVideo(hCam, ueye.IS_DONT_WAIT)
if nRet != ueye.IS_SUCCESS:
    print("is_CaptureVideo ERROR")

# Enables the queue mode for existing image memory sequences
nRet = ueye.is_InquireImageMem(hCam, pcImageMemory, MemID, width, height,
                               nBitsPerPixel, pitch)
if nRet != ueye.IS_SUCCESS:
    print("is_InquireImageMem ERROR")
예제 #15
0
 def set_gain(self, master, red, green, blue):
     err = pue.is_SetHardwareGain(self.cam, master, red, green, blue)
     if err != pue.IS_SUCCESS:
         raise CameraException(self.cam, 'ueye>set_gain>', err, False)