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
Exemplo n.º 2
0
    def init(self):
        ret = ueye.is_InitCamera(self.h_cam, None)
        if ret != ueye.IS_SUCCESS:
            self.h_cam = None
            raise uEyeException(ret)
        else:
            print('Initialising cam ', self.h_cam)
            ret = ueye.is_SetGainBoost(self.h_cam, ueye.IS_SET_GAINBOOST_ON)
            print('GAINBOOST:', ret)
#             ms = ueye.DOUBLE(20)
#             rate = ueye.DOUBLE(10)
#             newrate = ueye.DOUBLE()
#             number = ueye.UINT()
#
#             ret = ueye.is_SetFrameRate(self.h_cam, rate, newrate);
#             print('FR:',ret,newrate)
#             ret = ueye.is_Exposure(self.h_cam, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE, ms, ueye.sizeof(ms));
#             print('EXP:',ret,ms)
#             ret = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET_NUMBER, number, ueye.sizeof(number))
#             print('PxCLK #:',ret, number)
#             PCrange = (ctypes.c_uint * 3)()
#             ret = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET_RANGE, PCrange, 3*ueye.sizeof(number))
#             print('PxCLK range:', ret, PCrange[0], PCrange[1], PCrange[2])
#             list_pixel_clocks = (ctypes.c_uint * 150)()
#             ret = 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:', ret, list_np[0:number.value])
#             ret = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET, number, ueye.sizeof(number))
#             print('PxCLK current:',ret, number)
#             ret = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET_DEFAULT, number, ueye.sizeof(number))
#             print('PxCLK default:',ret, number)
#             ret = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_SET, ueye.UINT(20), ueye.sizeof(number))
#             print('PxCLK set:',ret, number)
#             ret = ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET, number, ueye.sizeof(number))
#             print('PxCLK current:',ret, number)
#
#             self.set_colormode(ueye.IS_CM_BGR8_PACKED)
#             self.set_displaymode(ueye.IS_SET_DM_DIB)
#             self.set_aoi(0,0, 1936, 1216)

        return ret
def BOOOOOOOOOOST(cam, mode):
    """set the gain boost mode of the camera"""
    if mode == 1:
        ueye.is_SetGainBoost(cam, ueye.IS_SET_GAINBOOST_ON)
    else:
        ueye.is_SetGainBoost(cam, ueye.IS_SET_GAINBOOST_OFF)
 def __disable_gain_boost(self):
     if not ueye.is_SetGainBoost(self.cam, ueye.IS_SET_GAINBOOST_OFF) == ueye.IS_SUCCESS:
         raise RuntimeError("IS_SET_GAINBOOST_OFF failed")