95 lines
3.2 KiB
Python
95 lines
3.2 KiB
Python
import ctypes
|
|
import os
|
|
import time
|
|
from ctypes import *
|
|
|
|
from src.components.hikrobot_dll import *
|
|
# Define the necessary structures and constants from MvVisionSensorDefine.h
|
|
|
|
|
|
def print_device_info(device_info_list):
|
|
num_devices=device_info_list.nDeviceNum
|
|
for i in range(num_devices):
|
|
device_info = device_info_list.pDeviceInfo[i].contents
|
|
nIp1 = ((device_info.nCurrentIp & 0xff000000) >> 24)
|
|
nIp2 = ((device_info.nCurrentIp & 0x00ff0000) >> 16)
|
|
nIp3 = ((device_info.nCurrentIp & 0x0000ff00) >> 8)
|
|
nIp4 = (device_info.nCurrentIp & 0x000000ff)
|
|
print(f"[{i}]Gige: {device_info.chUserDefinedName.decode()}"
|
|
f"({nIp1}.{nIp2}.{nIp3}.{nIp4})")
|
|
|
|
|
|
def main():
|
|
global MV_VS_OK
|
|
print("SC2016 TEST")
|
|
|
|
device_info_list = MV_VS_DEVICE_INFO_LIST()
|
|
|
|
nRet = mv_lib.MV_VS_EnumDevices(ctypes.byref(device_info_list))
|
|
|
|
if nRet != MV_VS_OK:
|
|
print(f"Enum devices failed! nRet [{nRet:#x}]")
|
|
return -2
|
|
else:
|
|
print("Enum devices OK")
|
|
|
|
if device_info_list.nDeviceNum > 0:
|
|
print_device_info(device_info_list)
|
|
else:
|
|
print("Find No Devices!")
|
|
return -2
|
|
|
|
if device_info_list.nDeviceNum == 2:
|
|
print("Starting dual camera test!")
|
|
# Define MV_VS_OK (replace with the actual value)
|
|
MV_VS_OK = 0
|
|
MV_VS_DEVICE_INFO_1 = device_info_list.pDeviceInfo[0];
|
|
MV_VS_DEVICE_INFO_2 = device_info_list.pDeviceInfo[1];
|
|
pHandle1 = c_void_p()
|
|
pHandle2 = c_void_p()
|
|
nRet1 = mv_lib.MV_VS_CreateHandle(byref(pHandle1), MV_VS_DEVICE_INFO_1)
|
|
nRet2 = mv_lib.MV_VS_CreateHandle(byref(pHandle2), MV_VS_DEVICE_INFO_2)
|
|
if nRet1 != MV_VS_OK or nRet2 != MV_VS_OK:
|
|
print(f"Create Handle failed! [{nRet1:#x} {nRet2:#x}]")
|
|
return
|
|
nRet1 = mv_lib.MV_VS_Login(pHandle1, b"Admin", b"Abc1234")
|
|
nRet2 = mv_lib.MV_VS_Login(pHandle2, b"Admin", b"Abc1234")
|
|
if nRet1 != MV_VS_OK or nRet2 != MV_VS_OK:
|
|
print(f"Login failed! [{nRet1:#x} {nRet2:#x}]")
|
|
return
|
|
else:
|
|
print("Login OK")
|
|
|
|
nRet1 = mv_lib.MV_VS_SetBoolValue(pHandle1, b"CommandImageMode", 0)
|
|
nRet2 = mv_lib.MV_VS_SetBoolValue(pHandle2, b"CommandImageMode", 0)
|
|
if nRet1 != MV_VS_OK or nRet2 != MV_VS_OK:
|
|
print(f"CommandImageMode failed! [{nRet1 & 0xFFFFFFFF:#x} {nRet2 & 0xFFFFFFFF:#x}]")
|
|
return
|
|
else:
|
|
print("CommandImageMode OK")
|
|
|
|
nRet1 = mv_lib.MV_VS_SetEnumValue(pHandle1, b"AcquisitionMode", 2)
|
|
nRet2 = mv_lib.MV_VS_SetEnumValue(pHandle2, b"AcquisitionMode", 2)
|
|
if nRet1 != MV_VS_OK or nRet2 != MV_VS_OK:
|
|
print(f"AcquisitionMode failed! [{nRet1 & 0xFFFFFFFF:#x} {nRet2 & 0xFFFFFFFF:#x}]")
|
|
return
|
|
else:
|
|
print("AcquisitionMode OK")
|
|
|
|
nRet1 = mv_lib.MV_VS_StartRun(pHandle1)
|
|
nRet2 = mv_lib.MV_VS_StartRun(pHandle2)
|
|
time.sleep(1)
|
|
|
|
if nRet1 != MV_VS_OK or nRet2 != MV_VS_OK:
|
|
print(f"Start run failed! [{nRet1&0xFFFFFFFF:#x} {nRet2&0xFFFFFFFF:#x}]")
|
|
return
|
|
else:
|
|
print("Start run OK")
|
|
|
|
MV_VS_GetFrame(pHandle1)
|
|
MV_VS_GetFrame(pHandle2)
|
|
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
main() |