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
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)
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
def ueye_set_image_format(hcam, formatid) -> None: fid = ueye.int(formatid) cmd = ueye.IMGFRMT_CMD_SET_FORMAT err = ueye.is_ImageFormat(hcam, cmd, fid, ueye.sizeof(fid)) _throw_if_err(hcam, err)
import cv2 from pyueye import ueye from pyueye_example_camera import Camera from pyueye_example_utils import ImageData, ImageBuffer import time import numpy as np # Initialize camera cam = Camera() cam.init() nRet = ueye.is_ResetToDefault(cam.handle()) # Change the format to 1280x960 formatID = ueye.UINT(8) nRet = ueye.is_ImageFormat(cam.handle(), ueye.IMGFRMT_CMD_SET_FORMAT, formatID, ueye.sizeof(formatID)) cam.alloc() # Allocate image memory # Disable auto exposure dblEnable = ueye.DOUBLE(0) dblDummy = ueye.DOUBLE(0) ueye.is_SetAutoParameter(cam.handle(), ueye.IS_SET_ENABLE_AUTO_SENSOR_GAIN_SHUTTER, dblEnable, dblDummy) newExposure = ueye.DOUBLE(30) ret = ueye.is_Exposure(cam.handle(), ueye.IS_EXPOSURE_CMD_SET_EXPOSURE, newExposure, ueye.sizeof(newExposure)) ueye.is_Focus(cam.handle(), ueye.FOC_CMD_SET_DISABLE_AUTOFOCUS, None, 0) # Disable autofocus focus_overview = ueye.INT(205) # Focus value for overview image (taken from 570mm above table) focus_closeup = ueye.INT(144) # Focus value for closeup image (taken from 190mm above table)