Commit e5fe3f20 by “liusq”

修改http超时时间或车牌配置盒子信息

parent cf45df20
......@@ -49,10 +49,11 @@ void AlgorithmTaskManage::initHumanDetectionManage(const QString &modelPaths,
humanDetections.emplace_back(human);
}
}
void AlgorithmTaskManage::initLicensePlateManage(const QString &modelPaths,
float carConfidence,bool is_high){
void AlgorithmTaskManage::initLicensePlateManage(const QString &modelPaths,bool is_high,int maxNum,bool useHalf,
float boxThreshold,float nmsThreshold,float recThreshold){
for (int i = 0; i < licensePlateLen; ++i) {
LicensePlateRecognition* licensePlateRecognition=new LicensePlateRecognition(modelPaths,carConfidence,is_high);
LicensePlateRecognition* licensePlateRecognition=new LicensePlateRecognition(
modelPaths,is_high,maxNum,useHalf,boxThreshold,nmsThreshold,recThreshold);
licensePlateRecognitions.emplace_back(licensePlateRecognition);
}
......@@ -95,28 +96,38 @@ AlgorithmTaskManage::~AlgorithmTaskManage(){
}
}
void AlgorithmTaskManage::releaseResources(
int newHumanDetectionLen, int newLicensePlateLen, int newFaceLen,const QString &odelPaths,
float humanCarShapeConfidence,
int uniformColor,
float licensePlateCarConfidence,
std::map<QString,QString>& faceMaps,
int numberFaces,
float faceConfidence,
__uint8_t algorithmPermissions,
bool is_high) {
void AlgorithmTaskManage::releaseResources(const vides_data::DetectionParams& params) {
Common & instance = Common::getInstance();
isShuttingDown.store(true, std::memory_order_release);
ScopeSemaphoreExit guard([this]() {
isShuttingDown.store(false, std::memory_order_release);
});
__uint8_t algorithmPermissions = params.algorithmPermissions;
qInfo()<<"修改参数:releaseResources "<<algorithmPermissions;
int newHumanDetectionLen = params.newHumanDetectionLen;
int newLicensePlateLen = params.newLicensePlateLen;
int newFaceLen = params.newFaceLen;
QString modelPath = params.modelPaths;
float humanCarShapeConfidence = params.humanCarShapeConfidence;
int uniformColor = params.uniformColor;
std::map<QString, QString> faceMaps = params.faceMaps;
int numberFaces = params.numberFaces;
float faceConfidence = params.faceConfidence;
bool high = params.isHigh;
int maxNum = params.maxNum;
bool useHalf = params.useHalf;
float boxThreshold = params.boxConfThreshold;
float nmsThreshold = params.nmsThreshold;
float recThreshold = params.recConfidenceThreshold;
// 穿工服算法参数更新
if ((algorithmPermissions & 0x01 << 2) != 0) {
resetSemaphoreAndClearObjects(instance,semaphore, humanDetections, humanDetectionLen);
initialize(newHumanDetectionLen, newLicensePlateLen, newFaceLen, false, 0x00);
initHumanDetectionManage(odelPaths, humanCarShapeConfidence, uniformColor);
initHumanDetectionManage(modelPath, humanCarShapeConfidence, uniformColor);
}
// 人脸算法参数更新
......@@ -130,7 +141,7 @@ void AlgorithmTaskManage::releaseResources(
if ((algorithmPermissions & 0x01) != 0) {
resetSemaphoreAndClearObjects(instance,plateSemaphore, licensePlateRecognitions, licensePlateLen);
initialize(newHumanDetectionLen, newLicensePlateLen, newFaceLen, false, 0x01);
initLicensePlateManage(odelPaths, licensePlateCarConfidence,is_high);
initLicensePlateManage(modelPath,high,maxNum,useHalf,boxThreshold,nmsThreshold,recThreshold);
}
}
......
......@@ -28,8 +28,8 @@ public:
void initHumanDetectionManage(const QString &modelPaths,
float carShapeConfidence,int &uniformColor);
void initLicensePlateManage(const QString &modelPaths,
float carConfidence,bool is_high);
void initLicensePlateManage(const QString &modelPaths,bool is_high,int maxNum,bool useHalf,
float boxThreshold,float nmsThreshold,float recThreshold);
void modifyImageFeature(std::map<QString,QString>&maps,int numberFaces,float confidence,bool isNull);
void initFaceReconitionHandle(std::map<QString,QString>&maps,int numberFaces,float confidence);
......@@ -37,14 +37,7 @@ public:
void *schedulingAlgorithm(int scheType);
void releaseResources(int newHumanDetectionLen, int newLicensePlateLen, int newFaceLen, const QString &odelPaths,
float humanCarShapeConfidence,
int uniformColor,
float licensePlateCarConfidence,
std::map<QString,QString>& faceMaps,
int numberFaces,
float faceConfidence,
__uint8_t algorithmPermissions,bool is_high);
void releaseResources(const vides_data::DetectionParams& params);
......
......@@ -252,7 +252,7 @@ void CameraHandle::cameraParameterUpdate(vides_data::responseConfig &cloudConfig
forMat=true;
}
if(forMat){
deviceReboot(true);
deviceReboot();
}
if(devConfig.camera.updateAt!=cloudConfig.camera.updateAt){
if(devConfig.camera.username!=cloudConfig.camera.username ||
......@@ -364,10 +364,9 @@ void CameraHandle::sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id,
return ;
}
}
int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
if (!semaphore.tryAcquire()) {
qInfo() <<sSn<<"sdkDevSnapSyn:正在执行线程";
return -1;
......@@ -438,9 +437,10 @@ void CameraHandle::sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel){
QString ip=QString::fromUtf8(loginParam->sDevId);
bool is_ping=vides_data::pingAddress(ip);
if(!is_ping){
deviceReboot(false);
deviceReboot();
}else {
deviceReboot(true);
QString ip=QString::fromUtf8(loginParam->sDevId);
MainWindow::sp_this->clearOfflineCameraHandle(ip,loginParam->nDevPort);
}
// 执行离线处理逻辑
// TODO: 可以在此处更新设备状态、发送告警通知等
......@@ -853,7 +853,6 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
}
}
void CameraHandle::findIp(QString &ip){
ip=QString::fromStdString(loginParam->sDevId);
......@@ -947,7 +946,7 @@ void CameraHandle::sdkWifi(QString &pwd,QString &ssid){
qInfo() << "修改wifi失败";
}
deviceReboot(false);
deviceReboot();
}
void CameraHandle::sdkDevSystemTimeZoneSyn(QString &time){
......@@ -1073,7 +1072,7 @@ void CameraHandle::sdkDevSpvMn(const char *spvMn){
qInfo() << "sdkDevSpvMn 28181->修改失败"<<res;
}
}
int CameraHandle::deviceReboot(bool isCloseHandle){
int CameraHandle::deviceReboot(){
int nRet=0;
XSDK_CFG::OPMachine cfg;
cfg.Action.SetValue("Reboot");
......@@ -1084,10 +1083,6 @@ int CameraHandle::deviceReboot(bool isCloseHandle){
qInfo() << sSn<<"重启相机失败"<<nRet;
return 0 ;
}
if(isCloseHandle){
return 0;
}
QString ip=QString::fromUtf8(loginParam->sDevId);
MainWindow::sp_this->clearOfflineCameraHandle(ip,loginParam->nDevPort);
return nRet;
......
......@@ -100,7 +100,7 @@ public:
void updateSdkDevSpvMn(vides_data::responseGb28181 *gb28181);
//重启设备
int deviceReboot(bool isCloseHandle );
int deviceReboot();
//设备关机
int deviceShutdown();
//获取固件版本
......
......@@ -518,13 +518,18 @@ vides_data::response *HttpService::httpDeviceConfig(const QString &serialNumber,
// 解析 licensePlateConfig
QJsonObject licensePlateConfigObj = dataObj["licensePlateConfig"].toObject();
config.licensePlateConfig.isOn = licensePlateConfigObj["isOn"].toBool();
config.licensePlateConfig.carConfidence = licensePlateConfigObj["carConfidence"].toVariant().toFloat();
config.licensePlateConfig.recConfidenceThreshold = licensePlateConfigObj["recConfidenceThreshold"].toVariant().toFloat();
config.licensePlateConfig.carConfidenceMax = licensePlateConfigObj["carConfidenceMax"].toVariant().toFloat();
config.licensePlateConfig.carConfidenceMin = licensePlateConfigObj["carConfidenceMin"].toVariant().toFloat();
config.licensePlateConfig.licensePlateLen=licensePlateConfigObj["licensePlateLen"].toInt();
config.licensePlateConfig.updateAt = licensePlateConfigObj["updateAt"].toVariant().toULongLong();
config.licensePlateConfig.maxNum=licensePlateConfigObj["maxNum"].toInt();
config.licensePlateConfig.useHalf=licensePlateConfigObj["useHalf"].toBool();
config.licensePlateConfig.boxConfThreshold = licensePlateConfigObj["boxConfThreshold"].toVariant().toFloat();
config.licensePlateConfig.nmsThreshold = licensePlateConfigObj["nmsThreshold"].toVariant().toFloat();
config.licensePlateConfig.isHigh=licensePlateConfigObj["isHigh"].toBool();
// 解析 uniformConfig
QJsonObject uniformConfigObj = dataObj["uniformConfig"].toObject();
......@@ -547,10 +552,8 @@ vides_data::response *HttpService::httpDeviceConfig(const QString &serialNumber,
//解析mqttConfig
QJsonObject mqttConfigObj = dataObj["mqttConfig"].toObject();
config.mqttConfig.address=mqttConfigObj["address"].toString();
config.mqttConfig.clientId=mqttConfigObj["clientId"].toString();
config.mqttConfig.qos=mqttConfigObj["qos"].toInt();
config.mqttConfig.timeout = mqttConfigObj["timeout"].toVariant().toULongLong();
config.mqttConfig.topic=mqttConfigObj["topic"].toString();
config.mqttConfig.username=mqttConfigObj["username"].toString();
config.mqttConfig.password=mqttConfigObj["password"].toString();
......
......@@ -7,7 +7,7 @@ HttpClient::HttpClient(QObject *parent)
{
m_networkAccessManager = new QNetworkAccessManager(this);
m_timer = new QTimer(this);
m_timer->setInterval(6000);
m_timer->setInterval(10000);
m_timer->setSingleShot(true);
connect(m_timer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
}
......
......@@ -4,22 +4,23 @@
LicensePlateRecognition::LicensePlateRecognition(const QString &modelPaths, float carConfidence,bool is_high) {
LicensePlateRecognition::LicensePlateRecognition(const QString &modelPaths,bool is_high,int maxNum,
bool useHalf,float boxThreshold,float nmsThreshold,float recThreshold) {
HLPR_ContextConfiguration configuration = {0};
QByteArray && by_mpath=modelPaths.toUtf8();
char* m_path=by_mpath.data();
configuration.models_path = m_path;
configuration.max_num = 5;
configuration.max_num = maxNum;
if(is_high){
configuration.det_level = DETECT_LEVEL_HIGH;
}else{
configuration.det_level = DETECT_LEVEL_LOW;
}
configuration.use_half = false;
configuration.nms_threshold = 0.5f;
configuration.rec_confidence_threshold = carConfidence;
configuration.box_conf_threshold = 0.30f;
configuration.use_half = useHalf;
configuration.nms_threshold =nmsThreshold;
configuration.rec_confidence_threshold = recThreshold;
configuration.box_conf_threshold = boxThreshold;
configuration.threads = 1;
ctx = HLPR_CreateContext(&configuration);
}
......
......@@ -29,7 +29,9 @@ public:
void replaceWith1And0( QString &code);
LicensePlateRecognition(const QString &modelPaths,float carConfidence,bool is_high);
LicensePlateRecognition(const QString &modelPaths,bool is_high,int maxNum,
bool useHalf,float boxThreshold,float nmsThreshold,float recThreshold
);
LicensePlateRecognition();
......
......@@ -118,13 +118,14 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
CameraHandle*cameraHandle= MainWindow::sp_this->findHandle(response.sn);
if(cameraHandle==nullptr){
qInfo() << "不存在该相机";
return 1;
}
if(response.msg_type==2){
res=cameraHandle->deviceShutdown();
}
if(response.msg_type==3){
res= cameraHandle->deviceReboot(false);
res=-1;
}else{
if(response.msg_type==2){
res=cameraHandle->deviceShutdown();
}
if(response.msg_type==3){
res= cameraHandle->deviceReboot();
}
}
vides_data::requestMqttData request;
qInfo() << "res"<<res;
......
......@@ -258,15 +258,19 @@ struct FaceConfig {
struct LicensePlateConfig {
bool isOn;
float carConfidence;
float carConfidenceMax;
float carConfidenceMin;
int licensePlateLen;
quint64 updateAt;
bool is_high;
quint64 updateAt;
int maxNum; ///< 识别最大数量
bool useHalf; ///< 是否使用半精度推理模式
float boxConfThreshold; ///< 检测框阈值
float nmsThreshold; ///< 非极大值抑制阈值
float recConfidenceThreshold; ///< 识别置信度阈值
bool isHigh;
};
struct UniformConfig {
bool isOn;
int uniformColor;
......@@ -307,6 +311,24 @@ struct requestMqttData{
int code;
QString uniq;
};
struct DetectionParams {
int newHumanDetectionLen;
int newLicensePlateLen;
int newFaceLen;
QString modelPaths;
float humanCarShapeConfidence;
int uniformColor;
std::map<QString, QString> faceMaps;
int numberFaces;
float faceConfidence;
__uint8_t algorithmPermissions;
bool isHigh;
int maxNum; ///< 识别最大数量
bool useHalf; ///< 是否使用半精度推理模式
float boxConfThreshold; ///< 检测框阈值
float nmsThreshold; ///< 非极大值抑制阈值
float recConfidenceThreshold; ///< 识别置信度阈值
};
inline bool isVirtualMachine()
{
......
File added
......@@ -25,6 +25,9 @@ INCLUDEPATH+=/usr/local/include/human
INCLUDEPATH+=/usr/local/include/CImg
INCLUDEPATH+=/usr/local/include/mqtt
# 禁用所有警告
QMAKE_CXXFLAGS += -w
#unix:contains(QMAKE_HOST.arch, x86_64) {
# QMAKE_LIBDIR += /home/mark/Public/x86_opencv/lib
#}
......
......@@ -70,13 +70,20 @@ MainWindow::MainWindow()
float carShapeConfidence=config.uniformConfig.carShapeConfidence;
float carConfidence=config.licensePlateConfig.carConfidence;
bool is_high=config.licensePlateConfig.is_high;
bool is_high=config.licensePlateConfig.isHigh;
int maxNum = config.licensePlateConfig.maxNum;
bool useHalf = config.licensePlateConfig.useHalf;
float boxThreshold = config.licensePlateConfig.boxConfThreshold;
float nmsThreshold = config.licensePlateConfig.nmsThreshold;
float recThreshold = config.licensePlateConfig.recConfidenceThreshold;
AlgorithmTaskManage &algorithmTaskManage= AlgorithmTaskManage::getInstance();
algorithmTaskManage.initialize(humanDetectionLen,licensePlateLen,faceLen,true,0x00);
algorithmTaskManage.initHumanDetectionManage(modelPaths,carShapeConfidence,uniformColor);
algorithmTaskManage.initLicensePlateManage(modelPaths,carConfidence,is_high);
algorithmTaskManage.initLicensePlateManage(modelPaths,is_high,maxNum,
useHalf,boxThreshold,nmsThreshold,recThreshold
);
MediaFaceImage* mediaFaceImage= MediaFaceImage::getInstance();
QString configPath = qSetting->value("devices/sz_config_path").toString();
......@@ -122,7 +129,9 @@ MainWindow::MainWindow()
qDebug() << "Server started, listening on port 12345";
}
config.mqttConfig.clientId=serialNumber;
QString topic = QStringLiteral("/thingshub/%1/device/reply").arg(serialNumber);
config.mqttConfig.topic=topic;
this->mqttConfig= config.mqttConfig;
MqttSubscriber* subscriber = MqttSubscriber::getInstance(mqttConfig);
subscriber->start();
......@@ -155,14 +164,29 @@ void MainWindow::divParameterUpdate(vides_data::responseConfig &cloudConfig ){
if(!faceAlgorithm && !licensePlateAlgorithm && !uniformAlgorithm && !timeChange){
return;
}
bool is_high=cloudConfig.licensePlateConfig.is_high;
__uint8_t alg= this->intToUint8t(faceAlgorithm,licensePlateAlgorithm,uniformAlgorithm) ;
algorithmTaskManage.releaseResources(cloudConfig.uniformConfig.humanDetectionLen
,cloudConfig.licensePlateConfig.licensePlateLen,
cloudConfig.faceConfig.faceLen,modelPaths,
cloudConfig.uniformConfig.carShapeConfidence
,cloudConfig.uniformConfig.uniformColor,cloudConfig.licensePlateConfig.carConfidence,localImageMap,
cloudConfig.faceConfig.faceNumbers,cloudConfig.faceConfig.confidence,alg,is_high);
vides_data::DetectionParams params;
params.newHumanDetectionLen =cloudConfig.uniformConfig.humanDetectionLen;
params.newLicensePlateLen =cloudConfig.licensePlateConfig.licensePlateLen;
params.newFaceLen =cloudConfig.faceConfig.faceLen;
params.modelPaths = modelPaths;
params.humanCarShapeConfidence =cloudConfig.uniformConfig.carShapeConfidence;
params.uniformColor =cloudConfig.uniformConfig.uniformColor;
params.faceMaps = localImageMap;
params.numberFaces =cloudConfig.faceConfig.faceNumbers;
params.faceConfidence =cloudConfig.faceConfig.confidence;
params.algorithmPermissions =alg;
params.isHigh =cloudConfig.licensePlateConfig.isHigh;
params.maxNum = cloudConfig.licensePlateConfig.maxNum;
params.useHalf = cloudConfig.licensePlateConfig.useHalf;
params.boxConfThreshold = cloudConfig.licensePlateConfig.boxConfThreshold;
params.nmsThreshold =cloudConfig.licensePlateConfig.nmsThreshold;
params.recConfidenceThreshold = cloudConfig.licensePlateConfig.recConfidenceThreshold;
algorithmTaskManage.releaseResources(params);
if(config.timerSettings.updateAt!=cloudConfig.timerSettings.updateAt){
if(config.timerSettings.deleteLogFileTimer!=cloudConfig.timerSettings.deleteLogFileTimer){
deleteLogFileTimer->stop();
......@@ -514,7 +538,7 @@ void MainWindow::startCamera(const QString &httpurl){
else {
CameraHandle *indexHandle=findHandle(device.sSn);
if(indexHandle!=nullptr &&device.is_reboot){
indexHandle->deviceReboot(false);
indexHandle->deviceReboot();
}else {
auto it = this->faceDetectionParkingPushs.find(key);
if (it != this->faceDetectionParkingPushs.end()) {
......@@ -963,6 +987,8 @@ void MainWindow::initCameras(vides_data::cameraParameters &parameter,vides_data:
initDevConfigSyn(cameraHandle,devConfig);
cameraHandle->sdkDevSetAlarmListener(sdk_handle,0);
int synTime=devConfig.camera.devSnapSynTimer;
uint64 face_frequency=devConfig.faceConfig.faceFrequency;
......
This diff is collapsed. Click to expand it.
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