V20251030-2.1.1

修复相机取流崩溃的bug。
加快海康相机初始化的速度。
This commit is contained in:
2025-10-30 15:21:58 +08:00
parent 6ab9c1b597
commit d76078959f
10 changed files with 129 additions and 684 deletions
@@ -26,6 +26,16 @@ bool ifRunning = false;
MV_CC_DEVICE_INFO_LIST m_stDevList; // ch:设备信息列表结构体变量,用来存储设备列表
//MV_GENTL_IF_INFO_LIST m_stIFList;
void CloseDevice();
static MV_CC_DEVICE_INFO_LIST QByteArrayToMV_CC_DeviceInfoList(const QByteArray& byteArray) {
MV_CC_DEVICE_INFO_LIST deviceInfoList;
if (byteArray.size() == sizeof(MV_CC_DEVICE_INFO_LIST)) {
memcpy(&deviceInfoList, byteArray.constData(), sizeof(MV_CC_DEVICE_INFO_LIST));
}
else {
qDebug() << "Invalid size of QByteArray for MV_CC_DEVICE_INFO_LIST!";
}
return deviceInfoList;
}
QString byteArrayToUnicode(const QByteArray array) {
// state用于保存转换状态,它的成员invalidChars,可用来判断是否转换成功
@@ -94,9 +104,15 @@ void __stdcall ImageCallBackEx(unsigned char* pData0, MV_FRAME_OUT_INFO_EX* pFra
//搜索所有设备
int SearchDevice()
{
memset(&m_stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));
// ch:枚举子网内所有设备 | en:Enumerate all devices within subnet
int nRet = MV_CC_EnumDevices(MV_GIGE_DEVICE | MV_USB_DEVICE, &m_stDevList);
if (m_stDevList.nDeviceNum == 0) {
memset(&m_stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));
// ch:枚举子网内所有设备 | en:Enumerate all devices within subnet
int nRet = MV_CC_EnumDevices(MV_GIGE_DEVICE | MV_USB_DEVICE, &m_stDevList);
if (MV_OK != nRet)
{
return 0;
}
}
for (int i = 0; i < m_stDevList.nDeviceNum; i++)
{
//SN
@@ -110,10 +126,6 @@ int SearchDevice()
break;
}
}
if (MV_OK != nRet)
{
return 0;
}
return -1;
}
@@ -387,6 +399,13 @@ bool Hd_CameraModule_HIK_hard_PCIE::readData(std::vector<cv::Mat>& mat, QByteArr
bool Hd_CameraModule_HIK_hard_PCIE::writeData(std::vector<cv::Mat>& mat, QByteArray& data)
{
Q_UNUSED(mat);
if (data.contains("deviceList")) {
auto result = QByteArrayToMV_CC_DeviceInfoList(data.mid(10));
if (result.nDeviceNum != 0) {
m_stDevList = result;
return true;
}
}
QStringList dataList = QString::fromUtf8(data).split("_");
//2024.02.18更新,相机对应的读SN信号时,表示新产品进入,设置初始值
if (data == "rest_newProductIn")