Commit dd5b951a by “liusq”

取消等待线程池执行完

parent 9a1411ee
......@@ -12,6 +12,7 @@
#include <vector>
#include <opencv2/opencv.hpp>
#include <mutex>
#include <condition_variable>
class AlgorithmTaskManage{
public:
AlgorithmTaskManage();
......@@ -90,6 +91,7 @@ private:
selected->setIsRunning(true); // 立刻标记为正在运行
return selected;
}
template<typename T>
void resetSemaphoreAndClearObjects(Common& instance, QSemaphore*& semaphore, std::vector<T*>& containers, int len) {
if (semaphore != nullptr) {
......@@ -107,6 +109,7 @@ private:
instance.deleteObj(semaphore);
}
}
static AlgorithmTaskManage* instance;
std::vector<HumanDetection*>humanDetections;
......
......@@ -23,18 +23,23 @@ CameraHandle::CameraHandle(QString &url, QString &httpUrl, QString &sSn, int &ch
devConfig(devConfig)
{
connect(this, SIGNAL(afterDownloadFile(int,int,QString)), this, SLOT(pushRecordToCloud(int,int,QString)),Qt::QueuedConnection);
faceMapWorker.setX(0);
faceMapWorker.setY(0);
}
CameraHandle::~CameraHandle() {
stopRequested_=true;
semaphore.acquire();
Common & instace= Common::getInstance();
dev_snap_syn_timer->stop();
QThreadPool::globalInstance()->waitForDone();
ScopeSemaphoreExit guard([this]() {
semaphore.release(); // 释放信号量
});
instace.deleteObj(dev_snap_syn_timer);
instace.deleteObj(loginParam);
instace.deleteObj(sxMediaFaceImageReq);
......@@ -362,7 +367,6 @@ void CameraHandle::sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id,
}
int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
if (stopRequested_) return -1;
if (!semaphore.tryAcquire()) {
qInfo() <<sSn<<"sdkDevSnapSyn:正在执行线程";
......@@ -408,7 +412,7 @@ int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
}
void CameraHandle::sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel){
if (stopRequested_) return;
if(hDevice<=0){
qInfo() << "相机断线";
return;
......
......@@ -25,20 +25,22 @@
#include <memory>
#include <functional>
#include <QString>
#include <QObject>
#include <QTimer>
#include <QThreadPool>
#include <QQueue>
#include <opencv2/opencv.hpp>
#include <QSemaphore>
#include <atomic>
enum CAR_INFORMATION {
Exit, //出场
Mobilization, //进场
ExitAndMobilization //
};
class CameraHandle: public QObject {
class CameraHandle: public QObject
{
Q_OBJECT
public:
CameraHandle(QString &url,QString &httpUrl,QString &sSn, int &channel, int imageSave,
float &heightReference,vides_data::responseConfig &devConfig);
......@@ -145,6 +147,7 @@ public:
int findPointRegion(ParkingSpaceInfo &prakArea);
int determineArea(ParkingSpaceInfo &prakArea);
signals:
void callbackFrameReady(const cv::Mat &frame, const QString &url);
......@@ -159,8 +162,7 @@ private :
int hDevice;
int channel;
QString httpUrl;
bool stopRequested_ = false;
SXSDKLoginParam *loginParam;
SXMediaFaceImageReq *sxMediaFaceImageReq;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment