Ejemplo n.º 1
0
 def save_parameters(self, path):
     # Save parameters to file
     pParam = ueye.wchar_p()
     pParam.value = path
     err = ueye.is_ParameterSet(self._cam,
                                ueye.IS_PARAMETERSET_CMD_SAVE_FILE, pParam,
                                0)
     if err != ueye.IS_SUCCESS:
         raise CameraException(self._cam, 'ueye>save_parameters>', err)
Ejemplo n.º 2
0
def main(config_path="/home/oran/Pictures/Settings/default-camera-settings.ini"
         ):
    print(config_path)
    # we need a QApplication, that runs our QT Gui Framework
    app = PyuEyeQtApp()

    # a basic qt window
    view = PyuEyeQtView()
    view.resize(1920 / 1.5, 1080 / 1.5)
    view.show()
    #update_config_gain(update={'red': '0','green' : '0','blue':'0'},set=True)
    #update_config_exposure(update=70,set=True)
    # view.user_callback = adjust_manually
    view.user_callback = print_means
    # view.user_callback = adjust_manually
    # camera class to simplify uEye API access
    cam = Camera()
    cam.init()
    # cam.set
    cam.set_colormode(ueye.IS_CM_BGR8_PACKED)
    pParam = ueye.wchar_p()
    pParam.value = config_path
    ueye.is_ParameterSet(1, ueye.IS_PARAMETERSET_CMD_LOAD_FILE, pParam, 0)

    # cam.set(cv2.cv.CV_CAP_PROP_EXPOSURE, 10)

    # cam.__getattribute__('is_CameraStatus')
    # cam.__setattr__('GetCameraInfo',0)
    #cam.set_aoi(0,0, 1280, 1024)
    cam.set_aoi(0, 0, 4912, 3684)
    cam.alloc()
    cam.capture_video()
    ueye._is_GetError
    ueye.is_Exposure(1,
                     ueye.c_uint(1),
                     ueye.c_void_p(),
                     cbSizeOfParam=ueye.c_int(0))
    # ueye.IS_EXPOSURE_CMD_GET_FINE_INCREMENT_RANGE_MIN = 20
    # ueye.IS_EXPOSURE_CMD_GET_FINE_INCREMENT_RANGE_MAX = 21

    # a thread that waits for new images and processes all connected views
    thread = FrameThread(cam, view)
    thread.start()

    # update_config_gain()

    # cleanup
    app.exit_connect(thread.stop)
    app.exec_()

    thread.stop()
    thread.join()

    cam.stop_video()
    cam.exit()
Ejemplo n.º 3
0
 def load_parameters(self, path):
     # Load parameters from file
     # Taken from: https://stackoverflow.com/questions/56461431/error-loading-ueye-camera-configuration-file-with-pyueye
     pParam = ueye.wchar_p()
     pParam.value = path
     err = ueye.is_ParameterSet(self._cam,
                                ueye.IS_PARAMETERSET_CMD_LOAD_FILE, pParam,
                                0)
     if err != ueye.IS_SUCCESS:
         raise CameraException(self._cam, 'ueye>load_parameters>', err)
     # Wait for parameters to take effect
     time.sleep(5)
def update_config(ini_file="raw_camera_params.ini",key = 'green',set=True):
	config = configparser.ConfigParser()
	config.sections()
	config.read(ini_file, encoding='utf-8-sig')

	if set:
			val = input('update ' + key + ' to:')
			config['Gain'][key] = val

	with open(ini_file, 'w') as configfile:
		config.write(configfile)

	pParam = ueye.wchar_p()
	pParam.value = ini_file
	ueye.is_ParameterSet(1, ueye.IS_PARAMETERSET_CMD_LOAD_FILE, pParam, 0)
def update_config_gain(ini_file="/home/oran/Pictures/Settings/default-camera-settings.ini",update = {'green':'10'},set=False):
	print('updating' + ini_file)
	config = configparser.ConfigParser()
	config.sections()
	config.read(ini_file, encoding='utf-8-sig')

	if set:
		for key in update.keys():
			config['Gain'][key] = update[key]
	else:
		for key in update.keys():
			config['Gain'][key] = str(int(config['Gain'][key]) + int(update[key]))
			# print(config['Gain'][key])
	with open(ini_file, 'w') as configfile:
		config.write(configfile)

	pParam = ueye.wchar_p()
	pParam.value = ini_file
	ueye.is_ParameterSet(1, ueye.IS_PARAMETERSET_CMD_LOAD_FILE, pParam, 0)
def update_config_exposure(ini_file="/home/oran/Desktop/camera_params.ini",update = 0,set=False):
	config = configparser.ConfigParser()
	config.sections()
	config.read(ini_file, encoding='utf-8-sig')
	if set:
		config['Timing']['exposure'] = str(update)

	else:
		print('exposure set to ' +  str(int(config['Timing']['exposure']) + update))
		config['Timing']['exposure'] = str(int(config['Timing']['exposure']) + update)

	with open(ini_file, 'w') as configfile:
		config.write(configfile)

	pParam = ueye.wchar_p()
	pParam.value = ini_file
	ueye.is_ParameterSet(1, ueye.IS_PARAMETERSET_CMD_LOAD_FILE, pParam, 0)

	return config['Timing']['exposure']
Ejemplo n.º 7
0
def update_config_gain(
        ini_file="C:\sandbox\camera_calibration\raw_camera_params.ini",
        update={'green': '10'},
        set=False):
    config = configparser.ConfigParser()
    config.sections()
    config.read(ini_file, encoding='utf-8-sig')

    if set:
        for key in update.keys():
            config['Gain'][key] = update[key]
    else:
        for key in update.keys():
            config['Gain'][key] = str(
                int(config['Gain'][key]) + int(update[key]))
            # print(config['Gain'][key])
    with open(ini_file, 'w') as configfile:
        config.write(configfile)

    pParam = ueye.wchar_p()
    pParam.value = ini_file
    ueye.is_ParameterSet(1, ueye.IS_PARAMETERSET_CMD_LOAD_FILE, pParam, 0)
Ejemplo n.º 8
0
    def __init__(self, pathToParameterSets, fps):

        self.hCam = ueye.HIDS(0)
        self.sInfo = ueye.SENSORINFO()
        self.cInfo = ueye.CAMINFO()
        self.pcImageMemory = ueye.c_mem_p()
        self.MemID = ueye.int()
        self.rectAOI = ueye.IS_RECT()
        self.pitch = ueye.INT()
        self.nBitsPerPixel = ueye.INT(24)
        self.channels = 3
        self.m_nColorMode = ueye.INT()
        self.bytes_per_pixel = int(self.nBitsPerPixel / 8)
        self.timeStampsFilePath = "times.txt"
        self.timeStampsFile = open(self.timeStampsFilePath, 'w')
        self.FPS = ctypes.c_double(int(fps))
        self.pathToParameterSets = pathToParameterSets

        nRet = ueye.is_InitCamera(self.hCam, None)
        if nRet != ueye.IS_SUCCESS:
            print("is_InitCamera ERROR")

        # Reads out the data hard-coded in the non-volatile camera memory and writes it to the data structure that cInfo points to
        nRet = ueye.is_GetCameraInfo(self.hCam, self.cInfo)
        if nRet != ueye.IS_SUCCESS:
            print("is_GetCameraInfo ERROR")

        # You can query additional information about the sensor type used in the camera
        nRet = ueye.is_GetSensorInfo(self.hCam, self.sInfo)
        if nRet != ueye.IS_SUCCESS:
            print("is_GetSensorInfo ERROR")

        if int.from_bytes(self.sInfo.nColorMode.value,
                          byteorder='big') == ueye.IS_COLORMODE_MONOCHROME:
            # for color camera models use RGB32 mode
            self.m_nColorMode = ueye.IS_CM_MONO8
            self.nBitsPerPixel = ueye.INT(8)
            self.bytes_per_pixel = int(self.nBitsPerPixel / 8)
            print("IS_COLORMODE_MONOCHROME: ", self.m_nColorMode)
            print("\tm_nColorMode: \t\t", self.m_nColorMode)
            print("\tnBitsPerPixel: \t\t", self.nBitsPerPixel)
            print("\tbytes_per_pixel: \t\t", self.bytes_per_pixel)
            print()

        #loading parameter set file

        pParam = ueye.wchar_p()
        pParam.value = self.pathToParameterSets

        nRet = ueye.is_ParameterSet(self.hCam,
                                    ueye.IS_PARAMETERSET_CMD_LOAD_FILE, pParam,
                                    0)
        if nRet != ueye.IS_SUCCESS:
            print("Setting parameter set error")

        #setting fps
        newFPS = ctypes.c_double(0)
        ueye.is_SetFrameRate(self.hCam, self.FPS, newFPS)
        if nRet != ueye.IS_SUCCESS:
            print("Setting fps ERROR")
        else:
            print("FPS is: ", newFPS)

        # Can be used to set the size and position of an "area of interest"(AOI) within an image
        nRet = ueye.is_AOI(self.hCam, ueye.IS_AOI_IMAGE_GET_AOI, self.rectAOI,
                           ueye.sizeof(self.rectAOI))
        if nRet != ueye.IS_SUCCESS:
            print("is_AOI ERROR")

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

        # Prints out some information about the camera and the sensor
        print("Camera model:\t\t", self.sInfo.strSensorName.decode('utf-8'))
        print("Camera serial no.:\t", self.cInfo.SerNo.decode('utf-8'))
        print("Maximum image width:\t", self.width)
        print("Maximum image height:\t", self.height)
        print()