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, //进场
...@@ -54,7 +53,7 @@ public: ...@@ -54,7 +53,7 @@ public:
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);
...@@ -79,7 +78,6 @@ public: ...@@ -79,7 +78,6 @@ public:
QString startTimer,QString endTime); QString startTimer,QString endTime);
void setTimeoutMs(int timeoutMs); void setTimeoutMs(int timeoutMs);
bool acquireAndReleaseWithTimeout(bool flag);
QString getSSn(); QString getSSn();
...@@ -110,10 +108,11 @@ signals: ...@@ -110,10 +108,11 @@ 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;
...@@ -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;
...@@ -156,7 +153,9 @@ private : ...@@ -156,7 +153,9 @@ private :
int timeoutMs; int timeoutMs;
int image_save; int image_save;
std::atomic<uint64> faceCount;
uint64 face_frequency;
}; };
......
...@@ -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,14 +6,13 @@ ...@@ -6,14 +6,13 @@
#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;
......
#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; // 选择图像模式 即总是检测
if(ctxHandle==nullptr){
// 创建ctx // 创建ctx
ret = HF_CreateFaceContextFromResourceFileOptional(path, option, detMode, 5, &ctxHandle); ret = HF_CreateFaceContextFromResourceFileOptional(path, option, detMode, 5, &ctxHandle);
if (ret != HSUCCEED) { if (ret != HSUCCEED) {
qInfo() << QString("Create ctx error: %1").arg(ret); qInfo() << QString("Create ctx error: %1").arg(ret);
return; 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) {
...@@ -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){
......
...@@ -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);
...@@ -306,13 +306,23 @@ void MainWindow::startCamera(const QString &httpurl){ ...@@ -306,13 +306,23 @@ void MainWindow::startCamera(const QString &httpurl){
// 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 *re= httpService.httpFindCameras(serialNumber,devices); vides_data::response *res=httpService.httpPostDeviceStatus(reStatus);
if(re->code==0){ if(res->code!=0){
if(devices.list.size()<=0){ qInfo()<<"盒子状态上报失败 code:"<<res->code<<"msg:"<<res->data;
instace.deleteObj(re);
return;
} }
instace.deleteObj(res);
httpService.setHttpUrl(httpurl);
vides_data::response *re= httpService.httpFindCameras(serialNumber,devices);
if(re->code==0 || re->code==20004){
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;
...@@ -363,23 +373,9 @@ void MainWindow::startCamera(const QString &httpurl){ ...@@ -363,23 +373,9 @@ 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);
} }
...@@ -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