Commit ad174f19 by 郭峰

Merge branch 'feature/mqtt-feature' into 'release'

Feature/mqtt feature

See merge request !8
parents 402424fb 22f4b088
...@@ -143,7 +143,7 @@ int XNetSDK_MediaCallBack(XSDK_HANDLE hMedia, int nDataType, int nDataLen, int n ...@@ -143,7 +143,7 @@ int XNetSDK_MediaCallBack(XSDK_HANDLE hMedia, int nDataType, int nDataLen, int n
if (EXCMD_DOWNLOAD_DATA == nDataType) if (EXCMD_DOWNLOAD_DATA == nDataType)
{ {
qDebug()<<"EXCMD_DOWNLOAD_DATA"<<nDataType; qInfo()<<"EXCMD_DOWNLOAD_DATA"<<nDataType;
/*if (g_hRecordDownload > 0 && g_hRecordDownload == hMedia) /*if (g_hRecordDownload > 0 && g_hRecordDownload == hMedia)
{ {
...@@ -197,9 +197,9 @@ int XNetSDK_MediaCallBack(XSDK_HANDLE hMedia, int nDataType, int nDataLen, int n ...@@ -197,9 +197,9 @@ int XNetSDK_MediaCallBack(XSDK_HANDLE hMedia, int nDataType, int nDataLen, int n
// 等待 ffmpeg 进程结束 // 等待 ffmpeg 进程结束
if (ffmpegProcess.waitForFinished(20000)) { if (ffmpegProcess.waitForFinished(20000)) {
//QFile::remove(dName); //QFile::remove(dName);
qDebug() << "ffmpeg process finished successfully."; qInfo() << "ffmpeg process finished successfully.";
} else { } else {
qDebug() << "Error: ffmpeg process did not finish."; qInfo() << "Error: ffmpeg process did not finish.";
} }
// 销毁 QProcess 对象 // 销毁 QProcess 对象
...@@ -354,7 +354,7 @@ void CameraHandle::sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id, ...@@ -354,7 +354,7 @@ void CameraHandle::sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id,
//param.result = sdkInitCallback; // 结果回调(必填) //param.result = sdkInitCallback; // 结果回调(必填)
SMsgReceiver sms(nullptr,XNetSDK_MediaCallBack,this); SMsgReceiver sms(nullptr,XNetSDK_MediaCallBack,this);
param.result=sms; param.result=sms;
qDebug() << "XSDK_MediaRecordDownload hDevice:"<<this->hDevice; qInfo() << "XSDK_MediaRecordDownload hDevice:"<<this->hDevice;
this->mediaHandle = XSDK_MediaRecordDownload(this->hDevice, &param, 0, 4000); this->mediaHandle = XSDK_MediaRecordDownload(this->hDevice, &param, 0, 4000);
if ( this->mediaHandle < 0) if ( this->mediaHandle < 0)
...@@ -390,7 +390,7 @@ int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) { ...@@ -390,7 +390,7 @@ int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
} }
else else
{ {
qDebug() << "OnDevAlarmCallback[Dev:" << hObject << "][Event:" << szString << "]"; qInfo() << "OnDevAlarmCallback[Dev:" << hObject << "][Event:" << szString << "]";
} }
cv::Mat image; cv::Mat image;
MediaFaceImage* mediaFaceImage= MediaFaceImage::getInstance(); MediaFaceImage* mediaFaceImage= MediaFaceImage::getInstance();
...@@ -429,14 +429,16 @@ void CameraHandle::sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel){ ...@@ -429,14 +429,16 @@ void CameraHandle::sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel){
int ret=mediaFaceImage->FaceImageCallBack(hDevice,nChannel, image); int ret=mediaFaceImage->FaceImageCallBack(hDevice,nChannel, image);
if (ret < 0) { if (ret < 0) {
offlineCount++; // 累加计数器 offlineCount++; // 累加计数器
qDebug() << "offlineCount: " << loginParam->sDevId<<offlineCount; qInfo() << "offlineCount: " << loginParam->sDevId<<offlineCount;
if (offlineCount >= 3) { // 判断是否连续3次返回0 if (offlineCount >= 3) { // 判断是否连续3次返回0
qInfo() << "设备离线"; qInfo() << "设备离线";
QString ip=QString::fromUtf8(loginParam->sDevId); QString ip=QString::fromUtf8(loginParam->sDevId);
bool is_ping=vides_data::pingAddress(ip); bool is_ping=vides_data::pingAddress(ip);
if(!is_ping){ qInfo() << "ping 的结果"<<is_ping;
if(is_ping){
deviceReboot(); deviceReboot();
}else { }else {
QString ip=QString::fromUtf8(loginParam->sDevId); QString ip=QString::fromUtf8(loginParam->sDevId);
...@@ -932,9 +934,10 @@ void CameraHandle::licensePlateRecognitionResults(vides_data::requestLicensePlat ...@@ -932,9 +934,10 @@ void CameraHandle::licensePlateRecognitionResults(vides_data::requestLicensePlat
for (auto& plate : location.plates) { for (auto& plate : location.plates) {
plate.img.clear(); plate.img.clear();
} }
httpService.setHttpUrl(httpUrl);
vides_data::response* img_resp = httpService.httpLicensePlateRecognition(location, result); vides_data::response* img_resp = httpService.httpLicensePlateRecognition(location, result);
if (img_resp->code != 0) { if (img_resp->code != 0) {
qInfo()<<"不加图片上次失败"; qInfo()<<"车牌不加图片上传失败";
} }
instace.deleteObj(img_resp); instace.deleteObj(img_resp);
}else{ }else{
...@@ -951,7 +954,7 @@ void CameraHandle::printWifi(XSDK_HANDLE hDevice,XSDK_CFG::NetWork_Wifi &cfg){ ...@@ -951,7 +954,7 @@ void CameraHandle::printWifi(XSDK_HANDLE hDevice,XSDK_CFG::NetWork_Wifi &cfg){
// 获取并解析配置 // 获取并解析配置
int nResult = XSDK_DevGetSysConfigSyn(hDevice, JK_NetWork_Wifi, szOutBuffer, &nInOutSize, 3000, EXCMD_CONFIG_GET); int nResult = XSDK_DevGetSysConfigSyn(hDevice, JK_NetWork_Wifi, szOutBuffer, &nInOutSize, 3000, EXCMD_CONFIG_GET);
qDebug()<<szOutBuffer; qInfo()<<szOutBuffer;
if (nResult >= 0) { if (nResult >= 0) {
cfg.Parse(szOutBuffer); cfg.Parse(szOutBuffer);
...@@ -1006,7 +1009,7 @@ void CameraHandle::sdkDevSystemTimeZoneSyn(QString &time){ ...@@ -1006,7 +1009,7 @@ void CameraHandle::sdkDevSystemTimeZoneSyn(QString &time){
//录像设置 //录像设置
void CameraHandle::sdkRecordCfg(const char * recordJson){ void CameraHandle::sdkRecordCfg(const char * recordJson){
qDebug()<<recordJson; qInfo()<<recordJson;
char szOutBuffer[512] = { 0 }; char szOutBuffer[512] = { 0 };
int nLen = sizeof(szOutBuffer);; int nLen = sizeof(szOutBuffer);;
int res=XSDK_DevSetSysConfigSyn(hDevice,JK_Record,recordJson,strlen(recordJson),szOutBuffer,&nLen,3000,EXCMD_CONFIG_SET); int res=XSDK_DevSetSysConfigSyn(hDevice,JK_Record,recordJson,strlen(recordJson),szOutBuffer,&nLen,3000,EXCMD_CONFIG_SET);
......
...@@ -37,7 +37,7 @@ cv::Mat FaceReconitionHandle::loadImage(const QString &path) { ...@@ -37,7 +37,7 @@ cv::Mat FaceReconitionHandle::loadImage(const QString &path) {
std::string stdPath = path.toStdString(); std::string stdPath = path.toStdString();
cv::Mat image = cv::imread(stdPath, cv::IMREAD_COLOR); cv::Mat image = cv::imread(stdPath, cv::IMREAD_COLOR);
if (!image.empty()) { if (!image.empty()) {
qDebug() << "图像以OpenCV成功加载。"; qInfo() << "图像以OpenCV成功加载。";
return image; return image;
} }
...@@ -151,7 +151,7 @@ void FaceReconitionHandle::featureRemove(){ ...@@ -151,7 +151,7 @@ void FaceReconitionHandle::featureRemove(){
if(customIds.size()>0){ if(customIds.size()>0){
for(auto customId:customIds){ for(auto customId:customIds){
HResult ret= HF_FeaturesGroupFeatureRemove(ctxHandle,customId); HResult ret= HF_FeaturesGroupFeatureRemove(ctxHandle,customId);
qDebug()<<"ret:featureRemove "<<ret; qInfo()<<"ret:featureRemove "<<ret;
} }
setImageChanged(false); setImageChanged(false);
} }
...@@ -180,10 +180,10 @@ cv::Mat FaceReconitionHandle::loadImageFromByteStream(const QString& filePath) { ...@@ -180,10 +180,10 @@ cv::Mat FaceReconitionHandle::loadImageFromByteStream(const QString& filePath) {
} }
return mat; return mat;
} catch (const CImgException& e) { } catch (const CImgException& e) {
qDebug() << "CImg Error: " << e.what(); qInfo() << "CImg Error: " << e.what();
return cv::Mat();; return cv::Mat();;
} catch (const cv::Exception& e) { } catch (const cv::Exception& e) {
qDebug() << "OpenCV Error: " << e.what(); qInfo() << "OpenCV Error: " << e.what();
return cv::Mat(); ; return cv::Mat(); ;
} }
...@@ -218,7 +218,7 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v ...@@ -218,7 +218,7 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v
HF_FaceContextRunFaceTrack(ctxHandle, imageSteamHandle, &multipleFaceData); HF_FaceContextRunFaceTrack(ctxHandle, imageSteamHandle, &multipleFaceData);
if (multipleFaceData.detectedNum <= 0) { if (multipleFaceData.detectedNum <= 0) {
qDebug()<<QString("search 未检测到人脸"); qInfo()<<QString("search 未检测到人脸");
return ; return ;
} }
...@@ -227,11 +227,11 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v ...@@ -227,11 +227,11 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v
HInt32 featureNum; HInt32 featureNum;
HF_GetFeatureLength(ctxHandle, &featureNum); HF_GetFeatureLength(ctxHandle, &featureNum);
for(int j=0;j< multipleFaceData.detectedNum; ++j){ for(int j=0;j< multipleFaceData.detectedNum; ++j){
qDebug()<<QString("doesItExistEmployee==>面部索引: %1").arg(j); qInfo()<<QString("doesItExistEmployee==>面部索引: %1").arg(j);
std::vector<float> newfeature(featureNum,0.0f); std::vector<float> newfeature(featureNum,0.0f);
ret = HF_FaceFeatureExtractCpy(ctxHandle, imageSteamHandle, multipleFaceData.tokens[j], newfeature.data()); ret = HF_FaceFeatureExtractCpy(ctxHandle, imageSteamHandle, multipleFaceData.tokens[j], newfeature.data());
if(ret != HSUCCEED) { if(ret != HSUCCEED) {
qDebug()<<QString("特征提取出错: %1").arg(ret); qInfo()<<QString("特征提取出错: %1").arg(ret);
HF_ReleaseImageStream(imageSteamHandle); HF_ReleaseImageStream(imageSteamHandle);
return ; return ;
} }
...@@ -252,9 +252,9 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v ...@@ -252,9 +252,9 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v
return ; return ;
} }
qDebug()<<QString("搜索置信度: %1").arg(confidence); qInfo()<<QString("搜索置信度: %1").arg(confidence);
qDebug()<<QString("匹配到的tag: %1").arg(searchIdentity.tag); qInfo()<<QString("匹配到的tag: %1").arg(searchIdentity.tag);
qDebug()<<QString("匹配到的customId: %1").arg(searchIdentity.customId); qInfo()<<QString("匹配到的customId: %1").arg(searchIdentity.customId);
// Face Pipeline // Face Pipeline
//printf("人脸特征数量: %d", faceNum); //printf("人脸特征数量: %d", faceNum);
if (confidence > configConfidence) { if (confidence > configConfidence) {
......
...@@ -114,7 +114,7 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess ...@@ -114,7 +114,7 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
qInfo() << "Failed to parse JSON payload"; qInfo() << "Failed to parse JSON payload";
} }
int res=-2; int res=-2;
//1开 2关 3 重启 //1开 2关 3 重启 4 GB28181开 5 GB28181关
CameraHandle*cameraHandle= MainWindow::sp_this->findHandle(response.sn); CameraHandle*cameraHandle= MainWindow::sp_this->findHandle(response.sn);
if(cameraHandle==nullptr){ if(cameraHandle==nullptr){
qInfo() << "不存在该相机"; qInfo() << "不存在该相机";
...@@ -126,10 +126,14 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess ...@@ -126,10 +126,14 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
if(response.msg_type==3){ if(response.msg_type==3){
res= cameraHandle->deviceReboot(); res= cameraHandle->deviceReboot();
} }
if(response.msg_type==4){
res=cameraHandle->updateSdkDevStatus(true);
}
if(response.msg_type==5){
res= cameraHandle->updateSdkDevStatus(false);
}
} }
vides_data::requestMqttData request; vides_data::requestMqttData request;
qInfo() << "res"<<res;
request.code =res>=0?0:0x01; request.code =res>=0?0:0x01;
request.uniq = response.uniq; request.uniq = response.uniq;
request.sn=response.sn ; request.sn=response.sn ;
...@@ -146,7 +150,7 @@ void MqttSubscriber::sendSubscriptionConfirmation(const vides_data::requestMqttD ...@@ -146,7 +150,7 @@ void MqttSubscriber::sendSubscriptionConfirmation(const vides_data::requestMqttD
QByteArray bResponseTopic = responseTopic.toUtf8(); QByteArray bResponseTopic = responseTopic.toUtf8();
char* cResponseTopic = bResponseTopic.data(); char* cResponseTopic = bResponseTopic.data();
qInfo() << "sendSubscriptionConfirmation"<<cResponseTopic; qInfo() << "sendSubscriptionConfirmation"<<cResponseTopic;
// 将 struct 转换成 JSON 格式 // 将 struct 转换成 JSON 格式
QJsonObject json; QJsonObject json;
json["code"] = response.code; json["code"] = response.code;
...@@ -154,7 +158,7 @@ void MqttSubscriber::sendSubscriptionConfirmation(const vides_data::requestMqttD ...@@ -154,7 +158,7 @@ void MqttSubscriber::sendSubscriptionConfirmation(const vides_data::requestMqttD
QJsonDocument jsonDoc(json); QJsonDocument jsonDoc(json);
QByteArray payload = jsonDoc.toJson(QJsonDocument::Compact); QByteArray payload = jsonDoc.toJson(QJsonDocument::Compact);
MQTTAsync_message pubmsg = MQTTAsync_message_initializer; MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
pubmsg.payload = const_cast<char*>(payload.data()); pubmsg.payload = const_cast<char*>(payload.data());
pubmsg.payloadlen = payload.size(); pubmsg.payloadlen = payload.size();
pubmsg.qos = config.qos; pubmsg.qos = config.qos;
......
...@@ -391,7 +391,7 @@ inline QString getDefaultGateway() { ...@@ -391,7 +391,7 @@ inline QString getDefaultGateway() {
return gateway; return gateway;
} }
inline bool pingAddress(const QString &address) { bool pingAddress(const QString &address) {
QProcess process; QProcess process;
QString program = "ping"; QString program = "ping";
QStringList arguments; QStringList arguments;
...@@ -407,21 +407,28 @@ inline bool pingAddress(const QString &address) { ...@@ -407,21 +407,28 @@ inline bool pingAddress(const QString &address) {
return false; return false;
} }
if (!process.waitForFinished(1000)) { // 使用较长的超时值,确保进程有足够时间完成
if (!process.waitForFinished(3000)) {
process.kill(); // 如果超时,强制终止进程
return false; return false;
} }
QString output(process.readAllStandardOutput()); QString output(process.readAllStandardOutput());
// 此处可以使用更复杂的逻辑来解析 Ping 输出 // 简单的 Ping 成功检查逻辑
#ifdef Q_OS_WIN
return output.contains("TTL=");
#else
return output.contains("1 packets transmitted, 1 received"); return output.contains("1 packets transmitted, 1 received");
#endif
} }
inline int GetCpuIdByAsm_arm(char* cpu_id) inline int GetCpuIdByAsm_arm(char* cpu_id)
{ {
FILE *fp = fopen("/proc/cpuinfo", "r"); FILE *fp = fopen("/proc/cpuinfo", "r");
if(nullptr == fp) if(nullptr == fp)
{ {
qDebug()<<"failed to open cpuinfo"; qInfo()<<"failed to open cpuinfo";
return -1; return -1;
} }
...@@ -457,7 +464,7 @@ inline int GetCpuIdByAsm_arm(char* cpu_id) ...@@ -457,7 +464,7 @@ inline int GetCpuIdByAsm_arm(char* cpu_id)
inline QString getCpuSerialNumber() { inline QString getCpuSerialNumber() {
QFile file("/proc/cpuinfo"); QFile file("/proc/cpuinfo");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "无法打开 /proc/cpuinfo 文件"; qInfo() << "无法打开 /proc/cpuinfo 文件";
return QString(); return QString();
} }
QTextStream in(&file); QTextStream in(&file);
......
...@@ -134,5 +134,5 @@ qnx: target.path = /tmp/$${TARGET}/bin ...@@ -134,5 +134,5 @@ qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target !isEmpty(target.path): INSTALLS += target
RESOURCES += \ #RESOURCES += \
BG.qrc # BG.qrc
...@@ -124,7 +124,7 @@ MainWindow::MainWindow() ...@@ -124,7 +124,7 @@ MainWindow::MainWindow()
if (!server.listen(QHostAddress::Any, port)) { if (!server.listen(QHostAddress::Any, port)) {
qInfo() << "Error: Unable to start the server on port 12345"; qInfo() << "Error: Unable to start the server on port 12345";
} else { } else {
qDebug() << "Server started, listening on port 12345"; qInfo() << "Server started, listening on port 12345";
} }
config.mqttConfig.clientId=serialNumber; config.mqttConfig.clientId=serialNumber;
...@@ -253,7 +253,7 @@ void MainWindow::handleMatNewConnection(){ ...@@ -253,7 +253,7 @@ void MainWindow::handleMatNewConnection(){
QRegExp urlRegEx("GET /cameras/([^/]+)/current_image HTTP"); QRegExp urlRegEx("GET /cameras/([^/]+)/current_image HTTP");
if(urlRegEx.indexIn(request) != -1) { if(urlRegEx.indexIn(request) != -1) {
QString sn = urlRegEx.cap(1); QString sn = urlRegEx.cap(1);
qDebug() << "Requested Camera SN: " << sn; qInfo() << "Requested Camera SN: " << sn;
bool foundCamera = false; bool foundCamera = false;
for (auto it = faceDetectionParkingPushs.begin(); it != faceDetectionParkingPushs.end(); ++it) { for (auto it = faceDetectionParkingPushs.begin(); it != faceDetectionParkingPushs.end(); ++it) {
QString currentSn = it->second->getSSn(); QString currentSn = it->second->getSSn();
...@@ -307,7 +307,7 @@ void MainWindow::removeImageFiles(QString id){ ...@@ -307,7 +307,7 @@ void MainWindow::removeImageFiles(QString id){
QString value = localIt->second; QString value = localIt->second;
QFile file(value); QFile file(value);
if (!file.open(QIODevice::WriteOnly)) { if (!file.open(QIODevice::WriteOnly)) {
qDebug() << "removeImageFiles open fail" << value; qInfo() << "removeImageFiles open fail" << value;
} else { } else {
file.remove(); file.remove();
} }
...@@ -370,7 +370,7 @@ void MainWindow::updateLocalFace(const QString &httpurl) { ...@@ -370,7 +370,7 @@ void MainWindow::updateLocalFace(const QString &httpurl) {
if (localIt != localImageMap.end()) { if (localIt != localImageMap.end()) {
QFile file(localIt->second); QFile file(localIt->second);
if (!file.open(QIODevice::WriteOnly)) { if (!file.open(QIODevice::WriteOnly)) {
qDebug() << "open fail" << localIt->second; qInfo() << "open fail" << localIt->second;
} else { } else {
file.remove(); file.remove();
qSetting->beginGroup("localImageMap"); qSetting->beginGroup("localImageMap");
...@@ -716,14 +716,14 @@ void MainWindow::initEncodeToString(QString &enCodeJson) { ...@@ -716,14 +716,14 @@ void MainWindow::initEncodeToString(QString &enCodeJson) {
} }
bool MainWindow::iniWorkSpVMn(vides_data::responseGb28181 *gb28181,QString &workSpWMn,QString &sn){ bool MainWindow::iniWorkSpVMn(vides_data::responseGb28181 *gb28181,QString &workSpWMn,QString &sn){
qDebug()<<"iniWorkSpVMn=="<<sn; qInfo()<<"iniWorkSpVMn=="<<sn;
QString jsonfile=QCoreApplication::applicationDirPath()+"/camera_config.json"; QString jsonfile=QCoreApplication::applicationDirPath()+"/camera_config.json";
bool isEqual=true; bool isEqual=true;
// 读取 JSON 配置文件 // 读取 JSON 配置文件
QFile file(jsonfile); QFile file(jsonfile);
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
qDebug() << "Failed to open the camera_config.json"; qInfo() << "Failed to open the camera_config.json";
return isEqual; return isEqual;
} }
QJsonObject toJsonObject; QJsonObject toJsonObject;
...@@ -975,7 +975,7 @@ void MainWindow::initCameras(vides_data::cameraParameters &parameter,vides_data: ...@@ -975,7 +975,7 @@ void MainWindow::initCameras(vides_data::cameraParameters &parameter,vides_data:
CameraHandle * cameraHandle =new CameraHandle(parameter.sDevId,parameter.httpUrl,parameter.sSn,parameter.channel,image_save,heightReference,devConfig); CameraHandle * cameraHandle =new CameraHandle(parameter.sDevId,parameter.httpUrl,parameter.sSn,parameter.channel,image_save,heightReference,devConfig);
int sdk_handle=cameraHandle->sdkDevLoginSyn(parameter.sDevId,parameter.nDevPort,parameter.sUserName,parameter.sPassword,3000); int sdk_handle=cameraHandle->sdkDevLoginSyn(parameter.sDevId,parameter.nDevPort,parameter.sUserName,parameter.sPassword,3000);
qDebug()<<"句柄为2:"<<sdk_handle; qInfo()<<"句柄为2:"<<sdk_handle;
if(sdk_handle<=0){ if(sdk_handle<=0){
qInfo() << "登录失败"; qInfo() << "登录失败";
return ; return ;
......
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