Commit 4b67a9ac by liusq

新增绿牌,蓝牌长度限制和信号自动析构

parent f5c6f1e3
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <QDateTime> #include <QDateTime>
#include <QJsonDocument> #include <QJsonDocument>
#include <memory> #include <memory>
#include <functional>
#include <QString> #include <QString>
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
...@@ -28,9 +29,7 @@ ...@@ -28,9 +29,7 @@
#include <QQueue> #include <QQueue>
#include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
#include <QSemaphore> #include <QSemaphore>
#include <atomic>
enum CAR_INFORMATION { enum CAR_INFORMATION {
Exit, //出场 Exit, //出场
Mobilization, //进场 Mobilization, //进场
...@@ -46,25 +45,25 @@ public: ...@@ -46,25 +45,25 @@ public:
int sdkDevLoginSyn(QString sDevId, int nDevPort, QString sUserName, QString sPassword, int nTimeout); int sdkDevLoginSyn(QString sDevId, int nDevPort, QString sUserName, QString sPassword, int nTimeout);
//int SdkMediaGetFaceImage(int hDevice, int nSeq, int nTimeout); //int SdkMediaGetFaceImage(int hDevice, int nSeq, int nTimeout);
int sdkDevSetAlarmListener(XSDK_HANDLE hDevice, int bListener); int sdkDevSetAlarmListener(XSDK_HANDLE hDevice, int bListener);
int getHdevice(); int getHdevice();
int getChannel(); int getChannel();
void clearCameraHandle(); void clearCameraHandle();
// void rebindTimer(int hDevice); // void rebindTimer(int hDevice);
void initSdkRealTimeDevSnapSyn(int hDevice,int syn_timer); void initSdkRealTimeDevSnapSyn(int hDevice,int syn_timer,uint64 face_frequency);
void updateImage(const cv::Mat & frame,qint64 currentTime); void updateImage(const cv::Mat & frame,qint64 currentTime);
void matToBase64(const cv::Mat &image, QByteArray &base64Data); void matToBase64(const cv::Mat &image, QByteArray &base64Data);
int callbackFunction(XSDK_HANDLE hObject,QString &szString); int callbackFunction(XSDK_HANDLE hObject,QString &szString);
void checkAndUpdateCurrentPlate(ParkingSpaceInfo*park,const cv::Mat & frame,RecognizedInfo& newInfo,int &result,std::map<int,RecognizedInfo>&exitAndMoMap); void checkAndUpdateCurrentPlate(ParkingSpaceInfo*park,const cv::Mat & frame,RecognizedInfo& newInfo,int &result,std::map<int,RecognizedInfo>&exitAndMoMap);
void licensePlateRecognitionResults(vides_data::requestLicensePlate &location); void licensePlateRecognitionResults(vides_data::requestLicensePlate &location);
void sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel); void sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel);
//时间设置 //时间设置
void sdkDevSystemTimeZoneSyn(QString &time); void sdkDevSystemTimeZoneSyn(QString &time);
...@@ -74,12 +73,11 @@ public: ...@@ -74,12 +73,11 @@ public:
void sdkEncodeCfg(const char *enCode); void sdkEncodeCfg(const char *enCode);
//28181更新 //28181更新
void sdkDevSpvMn(const char* spvMn); void sdkDevSpvMn(const char* spvMn);
void sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id, void sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id,
QString startTimer,QString endTime); QString startTimer,QString endTime);
void setTimeoutMs(int timeoutMs); void setTimeoutMs(int timeoutMs);
bool acquireAndReleaseWithTimeout(bool flag);
QString getSSn(); QString getSSn();
...@@ -87,7 +85,7 @@ public: ...@@ -87,7 +85,7 @@ public:
void setMediaHandle(int mediaHandle); void setMediaHandle(int mediaHandle);
void setCurrentFace(int currentFace); void setCurrentFace(int currentFace);
void initParkingSpaceInfo(const std::list<vides_data::responseArea>&areas); void initParkingSpaceInfo(const std::list<vides_data::responseArea>&areas);
bool compareLists(const std::list<vides_data::responseArea>& newAreas); bool compareLists(const std::list<vides_data::responseArea>& newAreas);
...@@ -108,23 +106,24 @@ public: ...@@ -108,23 +106,24 @@ public:
int determineArea(ParkingSpaceInfo &prakArea); int determineArea(ParkingSpaceInfo &prakArea);
signals: signals:
void callbackFrameReady(const cv::Mat &frame, const QString &url); void callbackFrameReady(const cv::Mat &frame, const QString &url);
void afterDownloadFile( int id,int recognitionType,QString ossUrl); void afterDownloadFile( int id,int recognitionType,QString ossUrl);
private slots: private slots:
void sdkRealTimeDevSnapSyn(int hDevice); void sdkRealTimeDevSnapSyn(int hDevice);
void pushRecordToCloud(int id,int recognitionType,QString ossUrl); void pushRecordToCloud(int id,int recognitionType,QString ossUrl);
void releaseSemaphore(); //void releaseSemaphore();
private : private :
int hDevice; int hDevice;
int channel; int channel;
QString httpUrl; QString httpUrl;
SXSDKLoginParam *loginParam; SXSDKLoginParam *loginParam;
SXMediaFaceImageReq *sxMediaFaceImageReq; SXMediaFaceImageReq *sxMediaFaceImageReq;
std::mutex plateMutex; std::mutex plateMutex;
std::mutex faceMutex; std::mutex faceMutex;
QString sSn; QString sSn;
QString url; QString url;
...@@ -143,8 +142,6 @@ private : ...@@ -143,8 +142,6 @@ private :
//2秒钟抓一次图 //2秒钟抓一次图
QTimer *dev_snap_syn_timer; QTimer *dev_snap_syn_timer;
QTimer *release_timer;
int offlineCount=0; int offlineCount=0;
TCV_HumanDetector *detector; TCV_HumanDetector *detector;
...@@ -154,10 +151,12 @@ private : ...@@ -154,10 +151,12 @@ private :
QSemaphore semaphore; QSemaphore semaphore;
int timeoutMs; int timeoutMs;
int image_save; int image_save;
std::atomic<uint64> faceCount;
uint64 face_frequency;
}; };
#endif // CAMERAHANDLE_H #endif // CAMERAHANDLE_H
...@@ -63,6 +63,19 @@ void Common::setImages(QString images){ ...@@ -63,6 +63,19 @@ void Common::setImages(QString images){
this->images=images; this->images=images;
} }
float Common::getCarConfidenceMax() const{
return carConfidenceMax;
}
void Common::setCarConfidenceMax(float carConfidenceMax){
this->carConfidenceMax=carConfidenceMax;
}
float Common::getCarConfidenceMin() const{
return carConfidenceMin;
}
void Common::setCarConfidenceMin(float carConfidenceMin){
this->carConfidenceMin=carConfidenceMin;
}
QString Common::GetLocalIp() { QString Common::GetLocalIp() {
QString ipAddress; QString ipAddress;
QList<QHostAddress> list = QNetworkInterface::allAddresses(); QList<QHostAddress> list = QNetworkInterface::allAddresses();
......
...@@ -44,6 +44,11 @@ public: ...@@ -44,6 +44,11 @@ public:
QString GetLocalIp(); QString GetLocalIp();
float getCarConfidenceMax() const;
void setCarConfidenceMax(float carConfidenceMax);
float getCarConfidenceMin() const;
void setCarConfidenceMin(float carConfidenceMin);
template<typename T> template<typename T>
void deleteObj(T*& obj) { void deleteObj(T*& obj) {
...@@ -57,6 +62,8 @@ private: ...@@ -57,6 +62,8 @@ private:
QString videoOut; QString videoOut;
QString videoDownload; QString videoDownload;
QString images; QString images;
float carConfidenceMax;
float carConfidenceMin;
Common(); Common();
~Common(); ~Common();
......
...@@ -6,19 +6,18 @@ ...@@ -6,19 +6,18 @@
#include "herror.h" #include "herror.h"
#include "LogHandle.h" #include "LogHandle.h"
#include "VidesData.h" #include "VidesData.h"
#include <mutex>
class FaceReconition class FaceReconition
{ {
private: private:
static FaceReconition* instance; static FaceReconition* instance;
HContextHandle ctxHandle; HContextHandle ctxHandle=nullptr;
float configConfidence; float configConfidence;
std::vector<int32_t>customIds; std::vector<int32_t>customIds;
FaceReconition(); FaceReconition();
~FaceReconition(); ~FaceReconition();
......
#include "FaceRecognition.h" #include "FaceRecognition.h"
#include <QThread>
FaceReconition::FaceReconition() {} FaceReconition::FaceReconition() {}
...@@ -23,23 +25,21 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con ...@@ -23,23 +25,21 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con
QString bPath = QCoreApplication::applicationDirPath() + "/model_zip/T1_5"; QString bPath = QCoreApplication::applicationDirPath() + "/model_zip/T1_5";
#else #else
#error "不支持的架构" #error "不支持的架构"
#endif #endif
QByteArray && bypath = bPath.toUtf8(); QByteArray && bypath = bPath.toUtf8();
char* spath = bypath.data(); char* spath = bypath.data();
HString path = spath; HString path = spath;
HInt32 option = HF_ENABLE_QUALITY | HF_ENABLE_FACE_RECOGNITION | HF_ENABLE_MASK_DETECT; HInt32 option = HF_ENABLE_QUALITY | HF_ENABLE_FACE_RECOGNITION | HF_ENABLE_MASK_DETECT;
HF_DetectMode detMode = HF_DETECT_MODE_IMAGE; // 选择图像模式 即总是检测 HF_DetectMode detMode = HF_DETECT_MODE_IMAGE; // 选择图像模式 即总是检测
// 创建ctx if(ctxHandle==nullptr){
ret = HF_CreateFaceContextFromResourceFileOptional(path, option, detMode, 5, &ctxHandle); // 创建ctx
if (ret != HSUCCEED) { ret = HF_CreateFaceContextFromResourceFileOptional(path, option, detMode, 5, &ctxHandle);
qInfo() << QString("Create ctx error: %1").arg(ret); if (ret != HSUCCEED) {
return; qInfo() << QString("Create ctx error: %1").arg(ret);
return;
}
} }
// ret = HF_FaceRecognitionThresholdSetting(ctxHandle, 0.36);
// if (ret != HSUCCEED) {
// qInfo() << QString("HF_FaceRecognitionThresholdSetting error: %1").arg(ret);
// return;
// }
customIds.clear(); customIds.clear();
int i = 0; int i = 0;
for (auto it = maps.begin(); it != maps.end(); ++it,++i) { for (auto it = maps.begin(); it != maps.end(); ++it,++i) {
...@@ -57,7 +57,7 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con ...@@ -57,7 +57,7 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con
imageData.width = image.cols; imageData.width = image.cols;
imageData.rotation = VIEW_ROTATION_0; imageData.rotation = VIEW_ROTATION_0;
imageData.format = FORMAT_BGR; imageData.format = FORMAT_BGR;
HImageHandle imageSteamHandle; HImageHandle imageSteamHandle;
ret = HF_CreateImageStream(&imageData, &imageSteamHandle); ret = HF_CreateImageStream(&imageData, &imageSteamHandle);
this->configConfidence=confidence; this->configConfidence=confidence;
...@@ -66,25 +66,25 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con ...@@ -66,25 +66,25 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con
HF_ReleaseImageStream(imageSteamHandle); // 释放资源 HF_ReleaseImageStream(imageSteamHandle); // 释放资源
return; return;
} }
HF_MultipleFaceData multipleFaceData = {0}; HF_MultipleFaceData multipleFaceData = {0};
HF_FaceContextRunFaceTrack(ctxHandle, imageSteamHandle, &multipleFaceData); HF_FaceContextRunFaceTrack(ctxHandle, imageSteamHandle, &multipleFaceData);
if (multipleFaceData.detectedNum <= 0) { if (multipleFaceData.detectedNum <= 0) {
qInfo() << QString("initSourceImageMap:未检测到人脸: %1").arg(key); qInfo() << QString("initSourceImageMap:未检测到人脸: %1").arg(key);
HF_ReleaseImageStream(imageSteamHandle); // 释放资源 HF_ReleaseImageStream(imageSteamHandle); // 释放资源
return; return;
} }
HF_FaceFeature feature = {0}; HF_FaceFeature feature = {0};
ret = HF_FaceFeatureExtract(ctxHandle, imageSteamHandle, multipleFaceData.tokens[0], &feature); ret = HF_FaceFeatureExtract(ctxHandle, imageSteamHandle, multipleFaceData.tokens[0], &feature);
if (ret != HSUCCEED) { if (ret != HSUCCEED) {
qInfo() << QString("特征提取出错: %1").arg(ret); qInfo() << QString("特征提取出错: %1").arg(ret);
HF_ReleaseImageStream(imageSteamHandle); // 释放资源 HF_ReleaseImageStream(imageSteamHandle); // 释放资源
return; return;
} }
char* tagName = new char[key.size() + 1]; char* tagName = new char[key.size() + 1];
std::strcpy(tagName, key.toStdString().c_str()); std::strcpy(tagName, key.toStdString().c_str());
HF_FaceFeatureIdentity identity = {0}; HF_FaceFeatureIdentity identity = {0};
...@@ -92,16 +92,16 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con ...@@ -92,16 +92,16 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con
identity.customId = i; identity.customId = i;
customIds.push_back( identity.customId); customIds.push_back( identity.customId);
identity.tag = tagName; identity.tag = tagName;
ret = HF_FeaturesGroupInsertFeature(ctxHandle, identity); ret = HF_FeaturesGroupInsertFeature(ctxHandle, identity);
if (ret != HSUCCEED) { if (ret != HSUCCEED) {
qInfo() << QString("插入失败: %1").arg(ret); qInfo() << QString("插入失败: %1").arg(ret);
HF_ReleaseImageStream(imageSteamHandle); // 释放资源 HF_ReleaseImageStream(imageSteamHandle); // 释放资源
return; return;
} }
delete[] tagName; delete[] tagName;
ret = HF_ReleaseImageStream(imageSteamHandle); ret = HF_ReleaseImageStream(imageSteamHandle);
if (ret == HSUCCEED) { if (ret == HSUCCEED) {
imageSteamHandle = nullptr; imageSteamHandle = nullptr;
...@@ -118,8 +118,6 @@ int FaceReconition::featureRemove(){ ...@@ -118,8 +118,6 @@ int FaceReconition::featureRemove(){
HResult ret= HF_FeaturesGroupFeatureRemove(ctxHandle,customId); HResult ret= HF_FeaturesGroupFeatureRemove(ctxHandle,customId);
qDebug()<<"ret:featureRemove "<<ret; qDebug()<<"ret:featureRemove "<<ret;
} }
HF_ReleaseFaceContext(ctxHandle);
} }
} }
void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_data::faceRecognitionResult>&faces){ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_data::faceRecognitionResult>&faces){
...@@ -131,7 +129,7 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d ...@@ -131,7 +129,7 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d
imageData.width = source.cols; imageData.width = source.cols;
imageData.rotation = VIEW_ROTATION_0; imageData.rotation = VIEW_ROTATION_0;
imageData.format = FORMAT_BGR; imageData.format = FORMAT_BGR;
HImageHandle imageSteamHandle; HImageHandle imageSteamHandle;
ret = HF_CreateImageStream(&imageData, &imageSteamHandle); ret = HF_CreateImageStream(&imageData, &imageSteamHandle);
if (ret != HSUCCEED) { if (ret != HSUCCEED) {
...@@ -140,12 +138,12 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d ...@@ -140,12 +138,12 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d
} }
HF_MultipleFaceData multipleFaceData = {0}; HF_MultipleFaceData multipleFaceData = {0};
HF_FaceContextRunFaceTrack(ctxHandle, imageSteamHandle, &multipleFaceData); HF_FaceContextRunFaceTrack(ctxHandle, imageSteamHandle, &multipleFaceData);
if (multipleFaceData.detectedNum <= 0) { if (multipleFaceData.detectedNum <= 0) {
qDebug()<<QString("search 未检测到人脸"); qDebug()<<QString("search 未检测到人脸");
return ; return ;
} }
std::vector<std::vector<float>> features; std::vector<std::vector<float>> features;
// 被搜索的目标这边推荐使用拷贝式的接口来获取特征向量 // 被搜索的目标这边推荐使用拷贝式的接口来获取特征向量
HInt32 featureNum; HInt32 featureNum;
...@@ -174,7 +172,7 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d ...@@ -174,7 +172,7 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d
qInfo()<<QString("搜索失败: %1").arg(ret); qInfo()<<QString("搜索失败: %1").arg(ret);
return ; return ;
} }
qDebug()<<QString("搜索置信度: %1").arg(confidence); qDebug()<<QString("搜索置信度: %1").arg(confidence);
qDebug()<<QString("匹配到的tag: %1").arg(searchIdentity.tag); qDebug()<<QString("匹配到的tag: %1").arg(searchIdentity.tag);
qDebug()<<QString("匹配到的customId: %1").arg(searchIdentity.customId); qDebug()<<QString("匹配到的customId: %1").arg(searchIdentity.customId);
...@@ -193,7 +191,7 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d ...@@ -193,7 +191,7 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d
} }
//printf("活体置信度: %f", livenessConfidence.confidence[0]); //printf("活体置信度: %f", livenessConfidence.confidence[0]);
qDebug()<<QString("活体置信度====>:%1").arg(livenessConfidence.confidence[0],0,'Q',4); qDebug()<<QString("活体置信度====>:%1").arg(livenessConfidence.confidence[0],0,'Q',4);
HF_FaceMaskConfidence maskConfidence = {0}; HF_FaceMaskConfidence maskConfidence = {0};
ret = HF_GetFaceMaskConfidence(ctxHandle, &maskConfidence); ret = HF_GetFaceMaskConfidence(ctxHandle, &maskConfidence);
if (ret != HSUCCEED) { if (ret != HSUCCEED) {
...@@ -217,7 +215,7 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d ...@@ -217,7 +215,7 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d
newface.height=multipleFaceData.rects[rect].height; newface.height=multipleFaceData.rects[rect].height;
faces.push_back(newface); faces.push_back(newface);
} }
rect++; rect++;
} }
ret = HF_ReleaseImageStream(imageSteamHandle); ret = HF_ReleaseImageStream(imageSteamHandle);
......
...@@ -18,6 +18,7 @@ int HumanDetection::findHuManCar(const cv::Mat &source,int res,TCV_HumanDetector ...@@ -18,6 +18,7 @@ int HumanDetection::findHuManCar(const cv::Mat &source,int res,TCV_HumanDetector
int num = (res == 0) ? TCV_HumanDetectorGetNumOfHuman(detector) :TCV_HumanDetectorGetNumOfCar(detector); int num = (res == 0) ? TCV_HumanDetectorGetNumOfHuman(detector) :TCV_HumanDetectorGetNumOfCar(detector);
qDebug() << (res == 0 ? "Number of people detected:" : "Number of cars detected:") << num; qDebug() << (res == 0 ? "Number of people detected:" : "Number of cars detected:") << num;
TCV_ReleaseCameraStream(stream); TCV_ReleaseCameraStream(stream);
return num; return num;
} }
...@@ -131,6 +131,7 @@ void LicensePlateRecognition::licensePlateNumber(const cv::Mat &source, QString ...@@ -131,6 +131,7 @@ void LicensePlateRecognition::licensePlateNumber(const cv::Mat &source, QString
newPlate.time=currentTime; newPlate.time=currentTime;
newPlate.new_color=QString::fromStdString(type); newPlate.new_color=QString::fromStdString(type);
newPlate.new_plate=QString::fromUtf8(results.plates[i].code); newPlate.new_plate=QString::fromUtf8(results.plates[i].code);
newPlate.text_confidence=results.plates[i].text_confidence;
vides_data::ParkingArea area; vides_data::ParkingArea area;
area.topLeftCornerX=results.plates[i].x1; area.topLeftCornerX=results.plates[i].x1;
area.topLeftCornerY=results.plates[i].y1; area.topLeftCornerY=results.plates[i].y1;
......
#include "ScopeSemaphoreExit.h"
ScopeSemaphoreExit::ScopeSemaphoreExit(std::function<void()> onExit)
: onExit_(onExit) {}
ScopeSemaphoreExit::~ScopeSemaphoreExit() {
if (onExit_) onExit_();
}
#ifndef SCOPESEMAPHOREEXIT_H
#define SCOPESEMAPHOREEXIT_H
#include <functional>
class ScopeSemaphoreExit {
public:
explicit ScopeSemaphoreExit(std::function<void()> onExit);
~ScopeSemaphoreExit();
private:
std::function<void()> onExit_;
};
#endif // SCOPESEMAPHOREEXIT_H
...@@ -133,6 +133,7 @@ struct LicensePlate ...@@ -133,6 +133,7 @@ struct LicensePlate
QByteArray img; QByteArray img;
qint64 time; qint64 time;
ParkingArea recognition; ParkingArea recognition;
float text_confidence;
LicensePlate() {} LicensePlate() {}
}; };
......
...@@ -93,7 +93,8 @@ SOURCES += \ ...@@ -93,7 +93,8 @@ SOURCES += \
TaskRunnable.cpp \ TaskRunnable.cpp \
CameraHandle.cpp \ CameraHandle.cpp \
ParkingSpaceInfo.cpp \ ParkingSpaceInfo.cpp \
HumanDetection.cpp HumanDetection.cpp \
ScopeSemaphoreExit.cpp
HEADERS += \ HEADERS += \
Common.h \ Common.h \
...@@ -109,7 +110,8 @@ HEADERS += \ ...@@ -109,7 +110,8 @@ HEADERS += \
TaskRunnable.h \ TaskRunnable.h \
CameraHandle.h \ CameraHandle.h \
ParkingSpaceInfo.h \ ParkingSpaceInfo.h \
HumanDetection.h HumanDetection.h \
ScopeSemaphoreExit.h
#FORMS += \ #FORMS += \
# mainwindow.ui # mainwindow.ui
......
...@@ -15,7 +15,7 @@ MainWindow::MainWindow() ...@@ -15,7 +15,7 @@ MainWindow::MainWindow()
modelPaths=qSetting->value("licensePlateRecognition/model_paths").toString(); modelPaths=qSetting->value("licensePlateRecognition/model_paths").toString();
initVideoOutPath(); initCommon();
deleteLogFileTimer =new QTimer(this); deleteLogFileTimer =new QTimer(this);
connect(deleteLogFileTimer, &QTimer::timeout, this, &MainWindow::deleteLogFile); connect(deleteLogFileTimer, &QTimer::timeout, this, &MainWindow::deleteLogFile);
...@@ -301,18 +301,28 @@ void MainWindow::startCamera(const QString &httpurl){ ...@@ -301,18 +301,28 @@ void MainWindow::startCamera(const QString &httpurl){
Common & instace= Common::getInstance(); Common & instace= Common::getInstance();
MediaFaceImage* mediaFaceImage= MediaFaceImage::getInstance(); MediaFaceImage* mediaFaceImage= MediaFaceImage::getInstance();
QString nonConstHttpUrl = std::remove_const<QString>::type(httpurl); QString nonConstHttpUrl = std::remove_const<QString>::type(httpurl);
vides_data::responseDeviceData devices; vides_data::responseDeviceData devices;
// QString serialNumber = QSysInfo::machineUniqueId(); // QString serialNumber = QSysInfo::machineUniqueId();
QString serialNumber; QString serialNumber;
findLocalSerialNumber(serialNumber); findLocalSerialNumber(serialNumber);
vides_data::requestDeviceStatus reStatus;
reStatus.sSn=serialNumber;
reStatus.status=1;
reStatus.type=1;
reStatus.ip_addr=instace.GetLocalIp();
HttpService httpService(httpurl); HttpService httpService(httpurl);
vides_data::response *res=httpService.httpPostDeviceStatus(reStatus);
if(res->code!=0){
qInfo()<<"盒子状态上报失败 code:"<<res->code<<"msg:"<<res->data;
}
instace.deleteObj(res);
httpService.setHttpUrl(httpurl);
vides_data::response *re= httpService.httpFindCameras(serialNumber,devices); vides_data::response *re= httpService.httpFindCameras(serialNumber,devices);
if(re->code==0){ if(re->code==0 || re->code==20004){
if(devices.list.size()<=0){
instace.deleteObj(re);
return;
}
QString username = qSetting->value("devices/username").toString(); QString username = qSetting->value("devices/username").toString();
QString password = qSetting->value("devices/password").toString(); QString password = qSetting->value("devices/password").toString();
std::map<QString,vides_data::localDeviceStatus*> localDevices; std::map<QString,vides_data::localDeviceStatus*> localDevices;
...@@ -329,7 +339,7 @@ void MainWindow::startCamera(const QString &httpurl){ ...@@ -329,7 +339,7 @@ void MainWindow::startCamera(const QString &httpurl){
QString key = ipAddress + ":" + QString::number(localDevice->TCPPort); QString key = ipAddress + ":" + QString::number(localDevice->TCPPort);
if(faceDetectionParkingPushs.count(key)<=0){ if(faceDetectionParkingPushs.count(key)<=0){
httpService.setHttpUrl(httpurl); httpService.setHttpUrl(httpurl);
vides_data::cameraParameters parameter; vides_data::cameraParameters parameter;
parameter.sDevId=ipAddress; parameter.sDevId=ipAddress;
parameter.nDevPort=localDevice->TCPPort; parameter.nDevPort=localDevice->TCPPort;
...@@ -354,7 +364,7 @@ void MainWindow::startCamera(const QString &httpurl){ ...@@ -354,7 +364,7 @@ void MainWindow::startCamera(const QString &httpurl){
} }
} }
this->deleteCloudNotCamer(localDevices, devices.list); this->deleteCloudNotCamer(localDevices, devices.list);
for (auto& pair : localDevices) { for (auto& pair : localDevices) {
if (pair.second != nullptr) { // 如果对象未被删除(即不为nullptr) if (pair.second != nullptr) { // 如果对象未被删除(即不为nullptr)
instace.deleteObj(pair.second); instace.deleteObj(pair.second);
...@@ -363,24 +373,10 @@ void MainWindow::startCamera(const QString &httpurl){ ...@@ -363,24 +373,10 @@ void MainWindow::startCamera(const QString &httpurl){
// 清空 localDevices 容器 // 清空 localDevices 容器
localDevices.clear(); localDevices.clear();
} }
vides_data::requestDeviceStatus reStatus;
reStatus.sSn=serialNumber;
reStatus.status=1;
reStatus.type=1;
reStatus.ip_addr=instace.GetLocalIp();
qDebug()<<"local.ip_addr===>"<<reStatus.ip_addr;
httpService.setHttpUrl(httpurl);
qDebug()<<"httpurl===>"<<httpurl;
qDebug()<<"serialNumber===>"<<serialNumber;
vides_data::response *res=httpService.httpPostDeviceStatus(reStatus);
if(res->code!=0){
qInfo()<<"盒子状态上报失败 code:"<<res->code<<"msg:"<<res->data;
}
updateLocalFace(httpurl); updateLocalFace(httpurl);
instace.deleteObj(re); instace.deleteObj(re);
instace.deleteObj(res);
} }
bool MainWindow::isDeviceInList(const QString& deviceId, const std::list<vides_data::responseDeviceStatus>& devices) { bool MainWindow::isDeviceInList(const QString& deviceId, const std::list<vides_data::responseDeviceStatus>& devices) {
...@@ -718,7 +714,9 @@ void MainWindow::initCameras(vides_data::cameraParameters &parameter,const std:: ...@@ -718,7 +714,9 @@ void MainWindow::initCameras(vides_data::cameraParameters &parameter,const std::
cameraHandle->sdkDevSetAlarmListener(sdk_handle,1); cameraHandle->sdkDevSetAlarmListener(sdk_handle,1);
int synTime=qSetting->value("timer/dev_snap_syn_timer").toInt(); int synTime=qSetting->value("timer/dev_snap_syn_timer").toInt();
cameraHandle->initSdkRealTimeDevSnapSyn(sdk_handle,synTime); uint64 face_frequency=qSetting->value("devices/face_frequency").toULongLong();
cameraHandle->initSdkRealTimeDevSnapSyn(sdk_handle,synTime,face_frequency);
int seTime=qSetting->value("timer/semaphore_time").toInt(); int seTime=qSetting->value("timer/semaphore_time").toInt();
cameraHandle->setTimeoutMs(seTime); cameraHandle->setTimeoutMs(seTime);
cameraHandle->initParkingSpaceInfo(areas); cameraHandle->initParkingSpaceInfo(areas);
...@@ -777,11 +775,15 @@ void MainWindow::createDirectory(int flag,const QString& dirName, const QString& ...@@ -777,11 +775,15 @@ void MainWindow::createDirectory(int flag,const QString& dirName, const QString&
} }
} }
void MainWindow::initVideoOutPath(){ void MainWindow::initCommon(){
createDirectory(0x01,"frame_images", "目录创建成功", "目录创建失败"); createDirectory(0x01,"frame_images", "目录创建成功", "目录创建失败");
createDirectory(0x00,"frame_video", "创建视频目录成功", "视频目录创建失败"); createDirectory(0x00,"frame_video", "创建视频目录成功", "视频目录创建失败");
createDirectory(0x02,"images", "图片目录创建成功", "图片目录创建失败"); createDirectory(0x02,"images", "图片目录创建成功", "图片目录创建失败");
float carConfidenceMax=qSetting->value("devices/carConfidenceMax").toFloat();
float carConfidenceMin=qSetting->value("devices/carConfidenceMin").toFloat();
Common& instance = Common::getInstance();
instance.setCarConfidenceMax(carConfidenceMax);
instance.setCarConfidenceMin(carConfidenceMin);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
......
...@@ -34,12 +34,13 @@ class MainWindow : public QObject ...@@ -34,12 +34,13 @@ class MainWindow : public QObject
public: public:
explicit MainWindow(); explicit MainWindow();
void initVideoOutPath(); void initCommon();
void setVideoPath(int flag, const QString& path); void setVideoPath(int flag, const QString& path);
void createDirectory(int flag,const QString& dirName, const QString& successMsg, const QString& failureMsg); void createDirectory(int flag,const QString& dirName, const QString& successMsg, const QString& failureMsg);
void initFaceFaceRecognition(); void initFaceFaceRecognition();
void initCameras(vides_data::cameraParameters &parameter,const std::list<vides_data::responseArea>&areas); void initCameras(vides_data::cameraParameters &parameter,const std::list<vides_data::responseArea>&areas);
......
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