#include "Hd_VirualCamera.h" #include QQueue> queuePic; QMutex* n_mutex = new QMutex(); Hd_VirualCamera::Hd_VirualCamera() { //m_thread = new MyThread; //m_mutex = new QMutex(); } Hd_VirualCamera::~Hd_VirualCamera() { if (n_mutex) { delete n_mutex; n_mutex = nullptr; } qDebug() << "[info]" << __FUNCTION__ << "line:" << __LINE__ << " delete success!"; } bool Hd_VirualCamera::readData(std::vector& mat, QByteArray& data, nlohmann::json& json) { Q_UNUSED(data) int cnt = 0; while (queuePic.empty()) { cnt++; QThread::msleep(10); if (cnt > 3000) { qCritical() << " [ error] " << __FUNCTION__ << " line:" << __LINE__ << " srcImage is null"; return false; } } n_mutex->lock(); vector dstMat = queuePic.dequeue(); n_mutex->unlock(); //for (int i=0;i& mat, QByteArray& data, nlohmann::json& json) { Q_UNUSED(mat) cameraName = data.toStdString(); return true; } bool Hd_VirualCamera::initParas(QByteArray&, nlohmann::json& json) { return true; } bool Hd_VirualCamera::run()//Θν΄₯·’ { n_mutex->lock(); if (cameraName == "156112" || cameraName == "162762") { vector mats; mats.push_back(cv::imread("H:\\testImg\\2.5D-H-1_16-00-14-38_Count0.bmp", -1)); mats.push_back(cv::imread("H:\\testImg\\2.5D-H-1_16-00-14-38_Count1.tiff", -1)); queuePic.enqueue(mats); } n_mutex->unlock(); return true; } Hd_VirualCamera* create(){ qDebug() << "[info]" << __FUNCTION__ << "line:" << __LINE__ << "Hd_VirualCamera create success!"; return new Hd_VirualCamera; } void destory(Hd_VirualCamera* ptr){ if (ptr) { delete ptr; ptr = nullptr; } qDebug() << "[info] " << __FUNCTION__ << " line:" << __LINE__ << "Hd_MvCamera_module destory success!"; }