0

我尝试使用相机 IDS UI-5240-CP-C-HQ 的 GPIO,但没有找到PYTHON的 API 或库ueye的文档。我不能使用函数 is_IO() 因为我不知道如何使用参数pParam

from pyueye import ueye
import numpy as np
import cv2
import sys
hCam = ueye.HIDS(0)
gpioConfiguration = ueye.IO_GPIO_CONFIGURATION
gpioConfiguration.u32Gpio = ueye.IO_GPIO_1;
gpioConfiguration.u32Configuration = ueye.IS_GPIO_OUTPUT;
gpioConfiguration.u32State = ueye.int(0);

nRet = ueye.is_IO(hCam, ueye.IS_IO_CMD_GPIOS_SET_CONFIGURATION, gpioConfiguration, 8)

ueye.is_IO(HIDS hCam, UINT nCommand, void* pParam, UINT cbSizeOfParam) 与手册中的 C++ 中的功能相同:https ://en.ids-imaging.com/manuals/ids-software-suite/ueye-manual /4.94.2/en/is_iogpio.html

谢谢。[JQ]

4

2 回答 2

0

我认为问题在于您实际上并没有构建 gpio 配置对象。

试试这个(最后有括号):

gpioConfiguration = ueye.IO_GPIO_CONFIGURATION()

另外,如果你还没有这样做。在这种情况下使用 hCam 之前,您必须使用 ueye.is_InitCamera 打开设备。

使用 ueye.sizeof(gpioConfiguraiton) 而不是指定参数的大小。

于 2021-10-15T07:01:17.747 回答
0

谢谢,这是我使用的相机的配置代码

def init_camera():
time_exposure_ = 3 #
fps_ = 7 #
pixel_clock_ = 50 #
time_trigger_delay = 990 # ms
gamma_ = 1.6
black_lvl_ = 116
hCam = ueye.HIDS(0)  #ID: 1001  #0: first available camera;  1-254: The camera with the specified camera ID
sInfo = ueye.SENSORINFO()
cInfo = ueye.CAMINFO()
pcImageMemory = ueye.c_mem_p()
MemID = ueye.int()
rectAOI = ueye.IS_RECT()
rectAOI.s32Width = ueye.INT(1280)
rectAOI.s32Weight = ueye.INT(1024)
pitch = ueye.INT()
channels = 3                    #3: channels for color mode(RGB); take 1 channel for monochrome
print("START IDS cam")
nRet = ueye.is_InitCamera(hCam, None)
if nRet != ueye.IS_SUCCESS:
    print("is_InitCamera -> ERROR")
nRet = ueye.is_ResetToDefault( hCam)
if nRet != ueye.IS_SUCCESS:
    print("is_ResetToDefault ERROR")
nRet = ueye.is_SetDisplayMode(hCam, ueye.IS_SET_DM_DIB)
m_nColorMode = ueye.IS_CM_BGRA8_PACKED
nBitsPerPixel = ueye.INT(32)
bytes_per_pixel = int(nBitsPerPixel / 8)
nRet = ueye.is_AOI(hCam, ueye.IS_AOI_IMAGE_GET_AOI, rectAOI, ueye.sizeof(rectAOI))
width = rectAOI.s32Width
height = rectAOI.s32Height
nRet = ueye.is_AllocImageMem(hCam, width, height, nBitsPerPixel, pcImageMemory, MemID)
pnCol = ueye.int()
pnColMode = ueye.int()
if nRet != ueye.IS_SUCCESS:
    print("is_AllocImageMem ERROR")
else:
    nRet = ueye.is_SetImageMem(hCam, pcImageMemory, MemID)
    if nRet != ueye.IS_SUCCESS:
        print("is_SetImageMem ERROR")
    else:
        nRet = ueye.is_SetColorMode(hCam, m_nColorMode)
        nRet = ueye.is_GetColorDepth(hCam, pnCol, pnColMode)
nRet = ueye.is_SetGainBoost(hCam, ueye.IS_SET_GAINBOOST_OFF)
gamma_value = ueye.uint(int(gamma_*100)) # 1.0*100
nRet = ueye.is_Gamma(hCam, ueye.IS_GAMMA_CMD_SET, gamma_value, ueye.sizeof(gamma_value))
blacklevel_offset = ueye.uint(black_lvl_)
ueye.is_Blacklevel(hCam, ueye.IS_BLACKLEVEL_CMD_SET_OFFSET, blacklevel_offset, ueye.sizeof(blacklevel_offset))
blacklevel_auto = ueye.uint(1)
ueye.is_Blacklevel(hCam, ueye.IS_BLACKLEVEL_CMD_SET_MODE, blacklevel_auto, ueye.sizeof(blacklevel_auto))
pixel_clock = ueye.uint(pixel_clock_)
nRet = ueye.is_PixelClock(hCam, ueye.IS_PIXELCLOCK_CMD_SET, pixel_clock, ueye.sizeof(pixel_clock))
fps = ueye.double(fps_)
nRet = ueye.is_SetFrameRate(hCam, ueye.IS_GET_DEFAULT_FRAMERATE, fps)
time_exposure = ueye.double(time_exposure_)
nRet = ueye.is_Exposure(hCam, ueye.IS_EXPOSURE_CMD_SET_EXPOSURE, time_exposure, ueye.sizeof(time_exposure))
nRet = ueye.is_SetHWGainFactor(hCam, ueye.IS_SET_RED_GAIN_FACTOR, ueye.INT(132))
nRet = ueye.is_SetHWGainFactor(hCam, ueye.IS_SET_GREEN_GAIN_FACTOR, ueye.INT(100))
nRet = ueye.is_SetHWGainFactor(hCam, ueye.IS_SET_BLUE_GAIN_FACTOR, ueye.INT(120))

nRet = ueye.is_CaptureVideo(hCam, ueye.IS_DONT_WAIT)
nRet = ueye.is_SetTriggerDelay(hCam, ueye.int(time_trigger_delay*1000))

return hCam, pcImageMemory, MemID, width, height, nBitsPerPixel, pitch, bytes_per_pixel
于 2022-02-01T17:52:33.387 回答