同步相机模块

This commit is contained in:
2025-10-16 17:04:14 +08:00
parent a69676099b
commit 971eb108a2
2 changed files with 16 additions and 12 deletions
@@ -133,7 +133,7 @@ int SearchDevice()
return -1;
}
bool connctDevice()
bool connectDevice()
{
//MV_CC_Initialize();
index = -1;
@@ -196,6 +196,7 @@ void SetGain(float GainValue)
void __stdcall ReconnectDevice(unsigned int nMsgType, void* pUser)
{
mv_Status = "disconnect";
std::cout << "相机重连中..." << std::endl;
qDebug() << "[Error] " << " MV camera disconnects!";
moduleStatus = false;
if (nMsgType == MV_EXCEPTION_DEV_DISCONNECT)
@@ -207,7 +208,7 @@ void __stdcall ReconnectDevice(unsigned int nMsgType, void* pUser)
while (1)
{
Sleep(100);
if (connctDevice() == true)
if (connectDevice() == true)
{
qWarning() << "[Hd_CameraModule_HIK] " << " Hd_CameraModule_HIK create success again! ";
moduleStatus = true;
@@ -335,10 +336,13 @@ Hd_CameraModule_HIK_hard_PCIE::Hd_CameraModule_HIK_hard_PCIE()
//关闭设备
void CloseDevice()
{
if (handle == nullptr)
return;
unsigned int nRet = MV_CC_StopGrabbing(handle);
if(nRet == 0)
CloseHandle(handle);
if (nRet == 0) {
MV_CC_CloseDevice(handle);
MV_CC_DestroyHandle(handle);
}
//nRet = MV_CC_CloseDevice(handle);
//nRet = MV_CC_DestroyHandle(handle);
}
@@ -490,7 +494,7 @@ bool Hd_CameraModule_HIK_hard_PCIE::initParas(QByteArray& initData)
}
}
bool ifOk = connctDevice();
bool ifOk = connectDevice();
if (ifOk == true)
{
if (expourseTimeList.size() > 0)
@@ -529,15 +533,15 @@ bool Hd_CameraModule_HIK_hard_PCIE::run()
std::cout << "\n gotImg" << std::endl;
break;
}
if (cnt > 2000) {
if (cnt > 150) {
n_mutex->lock();
queuepic.push_back(cv::imread("D://Image_20250809202445856.bmp", -1));
//queuepic.push_back(cv::Mat(200, 200, CV_8UC3, cv::Scalar(0, 255, 0))); //返回空图
//queuepic.push_back(cv::imread("D://Image_20250809202445856.bmp", -1));
queuepic.push_back(cv::Mat(200, 200, CV_8UC3, cv::Scalar(0, 255, 0))); //返回空图
std::cout << "timeout" << std::endl;
n_mutex->unlock();
return true;
}
QThread::msleep(1);
QThread::msleep(10);
}
//考虑到误触发、漏触发的图,在这里进行设置。
//需要设置曝光时