コード例 #1
0
    def convert_image_data(self):
        rect_aoi = ueye.IS_RECT()
        bits_per_pixel = 24
        converted_image_data = ImageData()
        conversion_params = ueye.BUFFER_CONVERSION_PARAMS()
        ueye.is_AOI(self.hCam, ueye.IS_AOI_IMAGE_GET_AOI, rect_aoi,
                    ueye.sizeof(rect_aoi))
        converted_image_data.memory_pointer = self.converted_memory_pointer
        converted_image_data.memory_id = self.converted_memory_id
        converted_image_data.width = rect_aoi.s32Width
        converted_image_data.height = rect_aoi.s32Height
        converted_image_data.bits_per_pixel = bits_per_pixel
        conversion_params.nDestPixelFormat = ueye.IS_CM_RGB8_PACKED
        conversion_params.pSourceBuffer = self.img_data.memory_pointer
        conversion_params.pDestBuffer = converted_image_data.memory_pointer
        conversion_params.nDestPixelConverter = ueye.IS_CONV_MODE_SOFTWARE_3X3
        conversion_params.nDestColorCorrectionMode = ueye.IS_CCOR_DISABLE
        conversion_params.nDestGamma = ueye.INT(100)
        conversion_params.nDestSaturationU = ueye.INT(100)
        conversion_params.nDestSaturationV = ueye.INT(100)
        conversion_params.nDestEdgeEnhancement = ueye.INT(0)
        ueye.is_Convert(self.hCam,
                        ueye.IS_CONVERT_CMD_APPLY_PARAMS_AND_CONVERT_BUFFER,
                        conversion_params, ueye.sizeof(conversion_params))

        return converted_image_data
コード例 #2
0
ファイル: IDSCamera.py プロジェクト: mhejda/PyIDSCam
    def info(self):
        print('======================= Camera info ==========================')
        if self.sensorInfo.strSensorName.decode('utf8')[-1] == 'C':
            print('COLOR sensor detected.')
        elif self.sensorInfo.strSensorName.decode('utf8')[-1] == 'M':
            print('MONOCHROMATIC sensor detected.')
        elif self.sensorInfo.strSensorName.decode(
                'utf8')[-1] != 'C' and self.sensorInfo.strSensorName.decode(
                    'utf8')[-1] != 'M':
            print(
                'WARNING: Unknown sensor type (mono/RGB). Image capturing will not work correctly.'
            )
        print('--------------------------------------------------------------')

        #print('Current maximal acquisition speed: ' + str(self.currentFPS) + ' fps')

        expTimeMin = ueye.c_double(0)
        expTimeMax = ueye.c_double(1000)
        ueye.is_Exposure(self.CamID,
                         ueye.IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MIN,
                         expTimeMin, ueye.sizeof(expTimeMin))
        ueye.is_Exposure(self.CamID,
                         ueye.IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MAX,
                         expTimeMax, ueye.sizeof(expTimeMax))

        print('Exposure time range: ' +
              str(round(expTimeMin.value * 1000, 3)) + ' to ' +
              str(round(expTimeMax.value * 1000, 3)) + ' us')
        print('--------------------------------------------------------------')
        for i in self.sensorInfo._fields_:
            print(str(i[0]) + ": " + str(eval('self.sensorInfo.%s' % i[0])))
コード例 #3
0
ファイル: pyueye_camera.py プロジェクト: rip3045/VisionSystem
    def set_full_auto(self):
        print("full auto")
        disable = ueye.DOUBLE(0)
        enable = ueye.DOUBLE(1)
        zero = ueye.DOUBLE(0)
        ms = ueye.DOUBLE(20)
        rate = ueye.DOUBLE(50)
        newrate = ueye.DOUBLE()
        number = ueye.UINT()

        nRet = ueye.is_SetAutoParameter(self.h_cam, ueye.IS_SET_ENABLE_AUTO_GAIN, enable, zero);
        print('AG:',nRet)
        nRet = ueye.is_SetAutoParameter(self.h_cam, ueye.IS_SET_ENABLE_AUTO_SHUTTER, enable, zero);
        print('A_SHUTTER:',nRet)
        nRet = ueye.is_SetFrameRate(self.h_cam, rate, newrate);
        print('FR:',nRet,newrate)
        nRet = ueye.is_Exposure(self.h_cam, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE, ms, ueye.sizeof(ms));
        print('EXP:',nRet,ms)
        nRet = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET_NUMBER, number, ueye.sizeof(number))
        print('PxCLK #:',nRet, number)
        PCrange = (ctypes.c_uint * 3)()
        nRet = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET_RANGE, PCrange, 3*ueye.sizeof(number))
        print('PxCLK range:', nRet, PCrange[0], PCrange[1], PCrange[2])
        list_pixel_clocks = (ctypes.c_uint * 150)()
        nRet = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET_LIST,  list_pixel_clocks, number*ueye.sizeof(number))
        list_np = np.frombuffer(list_pixel_clocks, int)
        print('PxCLK list:', nRet, list_np[0:number.value])
        nRet = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET, number, ueye.sizeof(number))
        print('PxCLK current:',nRet, number)
        nRet = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET_DEFAULT, number, ueye.sizeof(number))
        print('PxCLK default:',nRet, number)
        nRet = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_SET, ueye.UINT(20), ueye.sizeof(number))
        print('PxCLK set:',nRet, number)
        nRet = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET, number, ueye.sizeof(number))
        print('PxCLK current:',nRet, number)
コード例 #4
0
def capture_image(cam, gripper_height):
    camera_height = gripper_height + 70  # Camera is placed 70mm above gripper
    # TODO: Find a curve that correlates distance from subject and focus value
    if camera_height > 300:
        nRet = ueye.is_Focus(cam.handle(), ueye.FOC_CMD_SET_MANUAL_FOCUS,
                             config.focus_overview,
                             ueye.sizeof(config.focus_overview))
    else:
        nRet = ueye.is_Focus(cam.handle(), ueye.FOC_CMD_SET_MANUAL_FOCUS,
                             config.focus_closeup,
                             ueye.sizeof(config.focus_closeup))

    #nRet = ueye.is_Focus(cam.handle(), ueye.FOC_CMD_SET_ENABLE_AUTOFOCUS_ONCE, None, 0)

    # autofocus_status = ueye.INT(0)
    # ueye.is_Focus(cam.handle(), ueye.FOC_CMD_GET_AUTOFOCUS_STATUS, autofocus_status, ueye.sizeof(autofocus_status))
    img_buffer = ImageBuffer()  # Create image_tools buffer
    #ueye.is_Focus(cam.handle(), ueye.FOC_CMD_SET_ENABLE_AUTOFOCUS_ONCE, None, 0)
    time.sleep(0.5)
    # cam.freeze_video(True)  # Freeze video captures a single image_tools

    nRet = ueye.is_WaitForNextImage(cam.handle(), 1000, img_buffer.mem_ptr,
                                    img_buffer.mem_id)
    img_data = ImageData(cam.handle(), img_buffer)
    array = img_data.as_1d_image()
    img_data.unlock()

    return array
コード例 #5
0
    def set_parameters(self, disable_exposure=True):
        # Change image format
        # formatID = ueye.UINT(5)  # Change image format to 2048x1536
        formatID = ueye.UINT(8)  # Change image format to 1280x960
        nRet = ueye.is_ImageFormat(self.hCam, ueye.IMGFRMT_CMD_SET_FORMAT,
                                   formatID, ueye.sizeof(formatID))

        if disable_exposure:
            # Disable auto exposure
            dblEnable = ueye.DOUBLE(0)
            dblDummy = ueye.DOUBLE(0)
            ueye.is_SetAutoParameter(
                self.hCam, ueye.IS_SET_ENABLE_AUTO_SENSOR_GAIN_SHUTTER,
                dblEnable, dblDummy)

            # Set new exposure value from .ini-file
            config = configparser.ConfigParser()
            config.read('image_tools/cam_adjustments.ini')
            exposure = float(config['EXPOSURE']['exposure'])
            newExposure = ueye.DOUBLE(exposure)
            ret = ueye.is_Exposure(self.hCam,
                                   ueye.IS_EXPOSURE_CMD_SET_EXPOSURE,
                                   newExposure, ueye.sizeof(newExposure))

        # Disable autofocus
        ueye.is_Focus(self.hCam, ueye.FOC_CMD_SET_DISABLE_AUTOFOCUS, None, 0)
コード例 #6
0
 def __disable_hot_pixel_correction(self, value=0):
     hot_pixel = ueye.c_void_p(int(value))
     if not ueye.is_HotPixel(self.cam, ueye.IS_HOTPIXEL_DISABLE_CORRECTION, hot_pixel,
                             ueye.sizeof(hot_pixel)) == ueye.IS_SUCCESS:
         raise RuntimeError("IS_HOTPIXEL_DISABLE_CORRECTION failed")
     if not ueye.is_HotPixel(self.cam, ueye.IS_HOTPIXEL_DISABLE_SENSOR_CORRECTION, hot_pixel,
                             ueye.sizeof(hot_pixel)) == ueye.IS_SUCCESS:
         raise RuntimeError("IS_HOTPIXEL_DISABLE_SENSOR_CORRECTION failed")
コード例 #7
0
ファイル: qt_classes.py プロジェクト: barrygwn/planebots
 def setExposure(self, ms):
     ms_old = ueye.c_double(0)
     rv = ueye.is_Exposure(self.hCam, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE, ms_old, ueye.sizeof(ms_old))
     ems = ueye.c_double(ms)
     rv = ueye.is_Exposure(self.hCam, ueye.IS_EXPOSURE_CMD_SET_EXPOSURE, ems, ueye.sizeof(ems))
     ms_old = ueye.c_double(0)
     rv = ueye.is_Exposure(self.hCam, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE, ms_old, ueye.sizeof(ms_old))
     return rv
コード例 #8
0
 def get_format_list(self):
     count = ueye.UINT()
     check(ueye.is_ImageFormat(self.h_cam, ueye.IMGFRMT_CMD_GET_NUM_ENTRIES, count, ueye.sizeof(count)))
     format_list = ueye.IMAGE_FORMAT_LIST(ueye.IMAGE_FORMAT_INFO * count.value)
     format_list.nSizeOfListEntry = ueye.sizeof(ueye.IMAGE_FORMAT_INFO)
     format_list.nNumListElements = count.value
     check(ueye.is_ImageFormat(self.h_cam, ueye.IMGFRMT_CMD_GET_LIST,
                               format_list, ueye.sizeof(format_list)))
     return format_list
コード例 #9
0
ファイル: IDSCamera.py プロジェクト: mhejda/PyIDSCam
    def set_intTime(self, intTime):
        intTime = intTime / 1000
        """ Set the exposure time in microseconds. """

        expTime = ueye.c_double(intTime)
        ueye.is_Exposure(self.CamID, ueye.IS_EXPOSURE_CMD_SET_EXPOSURE,
                         expTime, ueye.sizeof(expTime))
        wert = ueye.c_double()
        sizeo = ueye.sizeof(wert)
        ueye.is_Exposure(self.CamID, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE, wert,
                         sizeo)
コード例 #10
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)
コード例 #11
0
 def __device_feature(self, value=1):
     param = ueye.INT(int(value))
     nRet = ueye.is_DeviceFeature(self.cam,
                                  ueye.IS_DEVICE_FEATURE_CMD_SET_LOG_MODE,
                                  param, ueye.sizeof(param))
     if nRet != ueye.IS_SUCCESS:
         raise RuntimeError("IS_DEVICE_FEATURE_CMD_SET_LOG_MODE failed")
コード例 #12
0
 def setAOI(self):
     self.ret = ueye.is_AOI(self.hcam, ueye.IS_AOI_IMAGE_GET_AOI,
                            self.rectAOI, ueye.sizeof(self.rectAOI))
     if self.ret != ueye.IS_SUCCESS:
         print("is_AOI ERROR")
     self.width = self.rectAOI.s32Width
     self.height = self.rectAOI.s32Height
コード例 #13
0
ファイル: live_track.py プロジェクト: gigatronics/live_focus
def init_cam(hcam):

    # get fps
    #  hcam_fps = is_GetFramesPerSecond(hcam, None)

    # set color mode
    ueye.is_SetColorMode(hcam, ueye.IS_CM_BGR8_PACKED)

    # set region of interest
    rect_aoi = ueye.IS_RECT()
    rect_aoi.s32X = ueye.int(0)
    rect_aoi.s32Y = ueye.int(0)
    rect_aoi.s32Width = ueye.int(width)
    rect_aoi.s32Height = ueye.int(height)
    ueye.is_AOI(hcam, ueye.IS_AOI_IMAGE_SET_AOI, rect_aoi,
                ueye.sizeof(rect_aoi))

    # allocate memory
    mem_ptr = ueye.c_mem_p()
    mem_id = ueye.int()

    ueye.is_AllocImageMem(hcam, width, height, bitspixel, mem_ptr, mem_id)
    ueye.is_SetImageMem(hcam, mem_ptr, mem_id)

    # continuous capture to memory
    ueye.is_CaptureVideo(hcam, ueye.IS_DONT_WAIT)

    return mem_ptr
コード例 #14
0
def calculate_focus(cam, working_distance):
    """This characteristic belongs to the IDS XS camera with serial code 4102885308.
    As stated by IDS themselves the characteristic is not robust and could vary between
    different cameras.
    The characteristic was made based on images up to a working distance of 620mm.
    """
    # TODO: Make characteristics for all IDS XS cameras at UiS.
    #  By checking the serial code through ueye.SENSORINFO, one would know which specific camera is in use

    if working_distance >= 357.5:
        focus_value = 204
    elif 237 <= working_distance < 357.5:
        focus_value = 192
    elif 169 <= working_distance < 237:
        focus_value = 180
    elif 131.5 <= working_distance < 169:
        focus_value = 168
    elif 101.5 <= working_distance < 131.5:
        focus_value = 156
    elif 86.5 <= working_distance < 101.5:
        focus_value = 144
    elif 72 <= working_distance < 86.5:
        focus_value = 128
    elif 42.5 <= working_distance < 72:
        focus_value = 112
    else:
        print("Too close to subject. Focus value not found. Default value: 204")
        focus_value = 204

    # Set the correct focus value
    focus_UINT = ueye.UINT(focus_value)
    ueye.is_Focus(cam.hCam, ueye.FOC_CMD_SET_MANUAL_FOCUS, focus_UINT, ueye.sizeof(focus_UINT))
    time.sleep(0.3)
コード例 #15
0
ファイル: cueye.py プロジェクト: attokdz/ueye_ioc
	def getPixelClock(self):
		self.pixelClock=ueye.c_uint()
		if ueye.is_PixelClock(self.hcam, ueye.IS_PIXELCLOCK_CMD_GET, self.pixelClock, ueye.sizeof(ueye.c_uint)):
			self.status=True
			_logger.error("Error retrinving PixelClock")
			return True
		return False
コード例 #16
0
ファイル: ueye.py プロジェクト: zacsimile/python-microscopy
    def SetIntegTime(self, integ_time):
        """
        Sets the exposure time in s. Currently assumes that we will want to go as fast as possible at this exposure time
        and also sets the frame rate to match.

        Parameters
        ----------
        iTime : float
            Exposure time in s

        Returns
        -------
        None

        See Also
        --------
        GetIntegTime
        """
        new_fps = ueye.double()
        self.check_success(
            ueye.is_SetFrameRate(self.h, 1 / integ_time, new_fps))
        # by default, set exposure time to max for this frame rate
        # "If 0 is passed, the exposure time is set to the maximum value of 1/frame rate."
        exposure = ueye.double(0)
        self.check_success(
            ueye.is_Exposure(self.h, ueye.IS_EXPOSURE_CMD_SET_EXPOSURE,
                             exposure, ueye.sizeof(exposure)))
コード例 #17
0
 def Set_Exp(self):
     if self.Movie_Switch == 1:
         self.exposure = ueye.DOUBLE(float(self.SetExp_lineEdit.text()))
         self.expms = ueye.DOUBLE(self.exposure)
         self.nRet = ueye.is_Exposure(self.hcam,
                                      ueye.IS_EXPOSURE_CMD_SET_EXPOSURE,
                                      self.expms, ueye.sizeof(self.expms))
コード例 #18
0
    def saveImage(self):
        ueye.is_AllocImageMem(self.hcam, self.sensorinfo.nMaxWidth, self.sensorinfo.nMaxHeight, 24, self.pccmem,
                              self.memID)
        ueye.is_SetImageMem(self.hcam, self.pccmem, self.memID)
        ueye.is_SetDisplayPos(self.hcam, 100, 100)

        self.nret = ueye.is_FreezeVideo(self.hcam, ueye.IS_WAIT)
        self.rawImageTimeStamp = datetime.datetime.now()
        self.imageTimeStamp = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S')
        self.imageName = 'imagem_%s.jpg' % self.imageTimeStamp
        self.imagePath = self.operationConfigs['savingDirectory'] + self.imageName
        # self.imagePath = self.operationConfigs['savingDirectory'] + "tmp.jpg"
        self.FileParams = ueye.IMAGE_FILE_PARAMS()
        self.FileParams.pwchFileName = self.imagePath
        self.FileParams.nFileType = ueye.IS_IMG_BMP
        self.FileParams.ppcImageMem = None
        self.FileParams.pnImageID = None

        self.nret = ueye.is_ImageFile(self.hcam, ueye.IS_IMAGE_FILE_CMD_SAVE, self.FileParams,
                                      ueye.sizeof(self.FileParams))

        ueye.is_FreeImageMem(self.hcam, self.pccmem, self.memID)
        #sleep(.01)
        #ueye.is_ExitCamera(self.hcam)
        self.image = np.uint8(ndimage.imread(self.imagePath, flatten=True))
        self.image = self.crop_end(self.image, 0, 100)
コード例 #19
0
    def get_aoi(self):
        rect_aoi = ueye.IS_RECT()
        ueye.is_AOI(self.h_cam, ueye.IS_AOI_IMAGE_GET_AOI, rect_aoi,
                    ueye.sizeof(rect_aoi))

        return Rect(rect_aoi.s32X.value, rect_aoi.s32Y.value,
                    rect_aoi.s32Width.value, rect_aoi.s32Height.value)
コード例 #20
0
def Init_Cam(width=640, heigth=480, gain_boost=1):
    """inits the uEye camera"""
    # inits next available cam
    cam = ueye.HIDS(0)
    ueye.is_InitCamera(cam, None)

    ueye.is_EnableAutoExit(cam, ueye.IS_ENABLE_AUTO_EXIT)

    # sets the Colourmode of the camera
    ueye.is_SetColorMode(cam, ueye.IS_CM_SENSOR_RAW8)

    # sets the trigger
    ret = ueye.is_SetExternalTrigger(cam, ueye.IS_SET_TRIGGER_SOFTWARE)
    mode = ueye.int(0)

    # sets the blacklevel
    ueye.is_Blacklevel(cam, ueye.IS_BLACKLEVEL_CMD_SET_MODE, mode,
                       ueye.sizeof(mode))

    # sets the size of the image
    rectAOI = ueye.IS_RECT()
    rectAOI.s32X = 44
    rectAOI.s32Y = 0
    rectAOI.s32Width = 480
    rectAOI.s32Height = 480
    ueye.is_AOI(cam, ueye.IS_AOI_IMAGE_SET_AOI, rectAOI, ueye.sizeof(rectAOI))

    # allocates memory with given size
    width = ueye.int(width)
    heigth = ueye.int(heigth)
    bitspixel = ueye.int(8)
    pcImgMem = ueye.c_mem_p()
    pid = ueye.int()
    ueye.is_AllocImageMem(cam, 480, heigth, bitspixel, pcImgMem, pid)

    # sets the image memory as active
    ueye.is_SetImageMem(cam, pcImgMem, pid)

    # activates video mode
    ueye.is_CaptureVideo(cam, ueye.IS_DONT_WAIT)

    # sets gain boost mode
    if gain_boost == 1:
        ueye.is_SetGainBoost(cam, ueye.IS_SET_GAINBOOST_ON)
    else:
        ueye.is_SetGainBoost(cam, ueye.IS_SET_GAINBOOST_OFF)
    return cam, ret, pcImgMem, pid
コード例 #21
0
    def show_image(self):
        nRet = ueye.is_InitCamera(self.h_cam, None)
        nRet = ueye.is_SetDisplayMode(self.h_cam, ueye.IS_SET_DM_DIB)
        nRet = ueye.is_AOI(self.h_cam, ueye.IS_AOI_IMAGE_GET_AOI, self.rectAOI,
                           ueye.sizeof(self.rectAOI))

        self.width = self.rectAOI.s32Width
        self.height = self.rectAOI.s32Height

        nRet = ueye.is_AllocImageMem(self.h_cam, self.width, self.height,
                                     self.nBitsPerPixel, self.pcImageMemory,
                                     self.MemID)
        nRet = ueye.is_SetImageMem(self.h_cam, self.pcImageMemory, self.MemID)
        nRet = ueye.is_SetColorMode(self.h_cam, self.ColorMode)
        nRet = ueye.is_CaptureVideo(self.h_cam, ueye.IS_DONT_WAIT)
        nRet = ueye.is_InquireImageMem(self.h_cam, self.pcImageMemory,
                                       self.MemID, self.width, self.height,
                                       self.nBitsPerPixel, self.pitch)

        while nRet == ueye.IS_SUCCESS:
            array = ueye.get_data(self.pcImageMemory,
                                  self.width,
                                  self.height,
                                  self.nBitsPerPixel,
                                  self.pitch,
                                  copy=False)
            frame = np.reshape(
                array,
                (self.height.value, self.width.value, self.bytes_per_pixel))
            frame = cv2.resize(frame, (0, 0), fx=0.5, fy=0.5)
            size = (self.height, self.width)
            new_camera_matrix, roi = cv2.getOptimalNewCameraMatrix(
                self.camera_matrix, self.dist_coeff, size, 1, size)
            dst = cv2.undistort(frame, self.camera_matrix, self.dist_coeff,
                                None, new_camera_matrix)
            x, y, w, h = roi
            self.dst = dst[y:y + h, x:x + w]

            self.detect_colors()

            self.extrinsic_calibration()

            cv2.imshow("camera", self.dst)

            if cv2.waitKey(1) & 0xFF == ord('q'):
                break

            elif cv2.waitKey(1) & 0xFF == ord('t'):
                cv2.imwrite("/home/lennart/dorna/camera/images/gps.bmp",
                            self.dst)

            elif cv2.waitKey(100) & 0xFF == ord('l'):
                self.found_container = False
                self.container_world_position.clear()
                print("Behälterposition zurückgesetzt")

        ueye.is_FreeImageMem(self.h_cam, self.pcImageMemory, self.MemID)
        ueye.is_ExitCamera(self.h_cam)
        cv2.destroyAllWindows()
コード例 #22
0
 def get_exposure(self, verbose=False):
     ret = ueye.DOUBLE()
     check(
         ueye.is_Exposure(self.h_cam, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE,
                          ret, ueye.sizeof(ret)))
     if verbose:
         print('Exposure: {}'.format(str(ret)))
     return ret
コード例 #23
0
    def set_aoi(self, x, y, width, height):
        rect_aoi = ueye.IS_RECT()
        rect_aoi.s32X = ueye.int(x)
        rect_aoi.s32Y = ueye.int(y)
        rect_aoi.s32Width = ueye.int(width)
        rect_aoi.s32Height = ueye.int(height)

        return ueye.is_AOI(self.h_cam, ueye.IS_AOI_IMAGE_SET_AOI, rect_aoi, ueye.sizeof(rect_aoi))
コード例 #24
0
ファイル: idscam.py プロジェクト: featureNull/pscout_desktop
def ueye_get_image_formats(hcam):
    fcnt = ueye.UINT()
    cmd = ueye.IMGFRMT_CMD_GET_NUM_ENTRIES
    err = ueye.is_ImageFormat(hcam, cmd, fcnt, ueye.sizeof(fcnt))
    _throw_if_err(hcam, err)

    fl = ueye.IMAGE_FORMAT_LIST((ueye.IMAGE_FORMAT_INFO * fcnt))
    fl.nSizeOfListEntry = ueye.sizeof(ueye.IMAGE_FORMAT_INFO)
    fl.nNumListElements = fcnt
    cmd = ueye.IMGFRMT_CMD_GET_LIST
    err = ueye.is_ImageFormat(hcam, cmd, fl, ueye.sizeof(fl))
    # aufschluesseln auf human readable
    fl2 = {fi.nFormatID.value: fi for fi in fl.FormatInfo}
    ret = {}
    for k, v in sorted(fl2.items()):
        ret[k] = v.strFormatName.decode("utf-8")
    return ret
コード例 #25
0
 def get_pixel_clock(self, verbose=False):
     ret = ueye.UINT()
     check(
         ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET, ret,
                            ueye.sizeof(ret)))
     if verbose:
         print('Pixel clock: {}'.format(str(ret)))
     return ret
コード例 #26
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)
コード例 #27
0
 def get_pixel_clock_range(self, verbose=False):
     ret = (ueye.UINT * 3)()
     check(
         ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET_RANGE,
                            ret, ueye.sizeof(ret)))
     if verbose:
         print('Pixel clock range: min={}, max={}, step={}'.format(
             str(ret[0].value), str(ret[1].value), str(ret[2].value)))
     return ret
コード例 #28
0
    def __get_dimensions(self):
        if not ueye.is_AOI(self.cam, ueye.IS_AOI_IMAGE_GET_AOI, self.rect_aoi,
                           ueye.sizeof(self.rect_aoi)) == ueye.IS_SUCCESS:
            raise RuntimeError("Dimensions not fetched")

        self.width = self.rect_aoi.s32Width
        self.height = self.rect_aoi.s32Height

        print("Sensor dimensions acquired")
コード例 #29
0
ファイル: Main_GUI.py プロジェクト: zjlxmyx/ThorlabsKST101
    def run(self):

        a = ueye.is_InitCamera(self.hCam, None)
        b = ueye.is_GetCameraInfo(self.hCam, self.cInfo)
        c = ueye.is_GetSensorInfo(self.hCam, self.sInfo)

        d = ueye.is_ResetToDefault(self.hCam)
        e = ueye.is_SetDisplayMode(self.hCam, ueye.IS_SET_DM_DIB)

        g = ueye.is_AOI(self.hCam, ueye.IS_AOI_IMAGE_GET_AOI, self.rectAOI,
                        ueye.sizeof(self.rectAOI))
        self.width = self.rectAOI.s32Width
        self.height = self.rectAOI.s32Height

        h = ueye.is_AllocImageMem(self.hCam, self.width, self.height,
                                  self.nBitsPerPixel, self.pcImageMemory,
                                  self.MemID)
        i = ueye.is_SetImageMem(self.hCam, self.pcImageMemory, self.MemID)
        f = ueye.is_SetColorMode(self.hCam, ueye.IS_CM_MONO12)

        ueye.is_CaptureVideo(self.hCam, ueye.IS_WAIT)

        j = ueye.is_InquireImageMem(self.hCam, self.pcImageMemory, self.MemID,
                                    self.width, self.height,
                                    self.nBitsPerPixel, self.pitch)
        self.IMAGE_FILE_PARAMS = ueye.IMAGE_FILE_PARAMS(
            self.pcImageMemory, self.MemID)
        self.IMAGE_FILE_PARAMS.nFileType = ueye.IS_IMG_PNG
        self.k = ueye.sizeof(self.IMAGE_FILE_PARAMS)

        # ueye.is_AutoParameter(self.hCam, ueye.IS_AES_CMD_SET_ENABLE, self.autoParameter, ueye.sizeof(self.autoParameter))

        while self.flag:
            self.data = np.ctypeslib.as_array(
                ctypes.cast(self.pcImageMemory,
                            ctypes.POINTER(ctypes.c_ubyte)),
                (self.height * self.pitch, ))
            self.data.dtype = 'uint16'

            self.CameraSignal.emit(self.data)
            time.sleep(0.1)

        ueye.is_FreeImageMem(self.hCam, self.pcImageMemory, self.MemID)
        ueye.is_ExitCamera(self.hCam)
コード例 #30
0
 def set_pixelclock(self, freq=20):
     '''
     set pixelclock in MHz
     param freq: pixelclock in MHz
     '''
     mhz = ueye.UINT(freq)
     ret = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_SET, mhz,
                              ueye.sizeof(mhz))
     if ret:
         raise Exception('Set pixelclock failed')