以下是他们提供的手册。
_uint32_t nCameras = ntcGetCameraCount();
if ( nCameras > 0 )
{
 pCamInfo = new NEPTUNE_CAM_INFO[nCameras];
 ntcGetCameraInfo(pCamInfo, nCameras);
}
NeptuneCamHandle hCamHandle;
// if unicast
ntcOpen(pCamInfo[0].strCamID, &hCamHandle);
// if multicast
ntcOpen(pCamInfo[0].strCamID, &hCamHandle, NEPTUNE_DEV_ACCESS_CONTROL);
 
这是我如何使用它在我的代码:
class _NEPTUNE_CAM_INFO_(Structure):
    pass
_NEPTUNE_CAM_INFO_._fields_ = [
    ('strVendor', c_char * 512),
    ('strModel', c_char * 512),
    ('strSerial', c_char * 512),
    ('strUserID', c_char * 512),
    ('strIP', c_char * 512),
    ('strMAC', c_char * 32),
    ('strSubnet', c_char * 512),
    ('strGateway', c_char * 512),
    ('strCamID', c_char * 512),
]
NEPTUNE_CAM_INFO = _NEPTUNE_CAM_INFO_
class IMICamera:
    def __init__(self):
        self._handle = c_void_p()  # 记录当前连接设备的句柄
        self.handle = pointer(self._handle)  # 创建句柄指针
        self.IMI_ntcInit()
    def IMI_ntcInit(self):
        IMICamCtrldll.ntcGetCameraCount.restype = c_int
        return IMICamCtrldll.ntcInit()
        # return MvCamCtrldll.ntcInit()
    def IMI_ntcGetCameraCount(self, count):
        IMICamCtrldll.ntcGetCameraCount.argtype = (c_void_p,)
        IMICamCtrldll.ntcGetCameraCount.restype = c_int
        return IMICamCtrldll.ntcGetCameraCount(byref(count))
    def IMI_ntcGetCameraInfo(self, pInfo, count):
        IMICamCtrldll.ntcGetCameraInfo.argtype = (c_void_p, c_void_p)
        IMICamCtrldll.ntcGetCameraInfo.restype = c_int
        return IMICamCtrldll.ntcGetCameraInfo(byref(pInfo), count)
    def IMI_ntcOpen(self, pstrDevID):
        IMICamCtrldll.ntcOpen.argtype = (c_char, c_void_p)
        IMICamCtrldll.ntcOpen.restype = c_int
        return IMICamCtrldll.ntcOpen(pstrDevID, byref(self.handle))
if __name__ == '__main__':
    mv = IMICamera()
    count = c_uint()
    res = mv.IMI_ntcGetCameraCount(count)
    if res != 0:
        print('IMI_ntcGetCameraCount', res)
    pInfo = (NEPTUNE_CAM_INFO * count.value)()
    res = mv.IMI_ntcGetCameraInfo(pInfo, count)
    if res != 0:
        print('IMI_ntcGetCameraInfo', res)
    strCamID = pInfo[1].strCamID
    pid = (c_char * 512)()
    for i in range(len(strCamID)):
        pid[i] = strCamID[i]
    pid2 = ctypes.create_string_buffer(512)
    pid2.value = strCamID
    pid3 = c_char_p(b'00:09:7e:02:80:88')
    res = mv.IMI_ntcOpen(pid3)
 
我尝试了许多类型参数,您可以在我的代码中看到。 在我运行我的代码后,结果总是得到error_code -203,这意味着NEPTUNE_ERR_InvalidParameter。 我该怎么解决这个问题?我做错了什么?谢谢! 问题来源StackOverflow 地址:/questions/59385744/invalid-parameter-when-using-python-ctypes-to-call-dll-function
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
import ctypes ll=ctypes.CDLL("pythontest3.dll") path= ctypes.c_char_p("C:\Users\Public\Pictures\Sample Pictures\a.jpg") path2= ctypes.c_char_p("C:\Users\Public\Pictures\Sample Pictures\b.jpg") ll.MSE.restype = ctypes.c_double#指定MSE的返回类型为double ll.PSNR.restype=ctypes.c_double#指定PSNR的返回值为double
指定返回值类型很重要,否则得到的结果会有错误
ll.abc.argtypes =[ctypes.c_char_p,ctypes.c_char_p]#指定参数类型 print ll.MSE(path.value,path.value)