Commit 784d6dae by “liusq”

新增算法权限和推送设备版本,ip

parent 264b6d6a
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "Json_Header/System_TimeZone.h" #include "Json_Header/System_TimeZone.h"
#include "Json_Header/RecordCfg.h" #include "Json_Header/RecordCfg.h"
#include "Json_Header/NetWork_SPVMN.h" #include "Json_Header/NetWork_SPVMN.h"
#include "Json_Header/SystemInfo.h"
#include "Json_Header/OPMachine.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "ParkingSpaceInfo.h" #include "ParkingSpaceInfo.h"
#include "so_human_sdk.h" #include "so_human_sdk.h"
...@@ -45,25 +47,25 @@ public: ...@@ -45,25 +47,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,uint64 face_frequency); 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);
...@@ -73,90 +75,96 @@ public: ...@@ -73,90 +75,96 @@ public:
void sdkEncodeCfg(const char *enCode); void sdkEncodeCfg(const char *enCode);
//28181更新 //28181更新
void sdkDevSpvMn(const char* spvMn); void sdkDevSpvMn(const char* spvMn);
//重启设备
void deviceReboot();
//获取固件版本
void findFirmwareVersion(QString &firmwareVersion);
//获取ip
void findIp(QString &ip);
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);
QString getSSn(); QString getSSn();
int getMediaHandle(); int getMediaHandle();
void setMediaHandle(int mediaHandle); void setMediaHandle(int mediaHandle);
void setCurrentFace(int currentFace); void setCurrentFace(int currentFace);
void initAlgorithmPermissions(__uint8_t algorithm);
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);
void updateParkMapAndParkingSpaceInfos(const std::list<vides_data::responseArea>&newAreas); void updateParkMapAndParkingSpaceInfos(const std::list<vides_data::responseArea>&newAreas);
std::map<int, vides_data::responseRecognitionData>&getVideoCurrentData(); std::map<int, vides_data::responseRecognitionData>&getVideoCurrentData();
std::map<QString, QString>&getCurrentData(); std::map<QString, QString>&getCurrentData();
// 检查点是否在多边形内 // 检查点是否在多边形内
bool polygonsOverlap(ParkingSpaceInfo &poly1, ParkingSpaceInfo &poly2); bool polygonsOverlap(ParkingSpaceInfo &poly1, ParkingSpaceInfo &poly2);
// 计算两个多边形的交集面积 // 计算两个多边形的交集面积
double calculateIntersectionArea(const QPolygonF &polygon1, const QPolygonF &polygon2); double calculateIntersectionArea(const QPolygonF &polygon1, const QPolygonF &polygon2);
double ccw(const QPointF& a, const QPointF& b, const QPointF& c); double ccw(const QPointF& a, const QPointF& b, const QPointF& c);
void getCurrentFrame(std::vector<uchar> &buffer); void getCurrentFrame(std::vector<uchar> &buffer);
int findPointRegion(ParkingSpaceInfo &prakArea); int findPointRegion(ParkingSpaceInfo &prakArea);
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;
std::map<int, vides_data::responseRecognitionData> videoCurrentData; std::map<int, vides_data::responseRecognitionData> videoCurrentData;
std::map<QString, QString> currentData; std::map<QString, QString> currentData;
//每个区域编号对应一个区域信息 //每个区域编号对应一个区域信息
std::map<int,ParkingSpaceInfo*>parkMap; std::map<int,ParkingSpaceInfo*>parkMap;
//当前相机监视所以车位区域 //当前相机监视所以车位区域
std::vector<ParkingSpaceInfo*>parkingSpaceInfos; std::vector<ParkingSpaceInfo*>parkingSpaceInfos;
//当前人脸数 //当前人脸数
int currentFace; int currentFace;
int mediaHandle; int mediaHandle;
//2秒钟抓一次图 //2秒钟抓一次图
QTimer *dev_snap_syn_timer; QTimer *dev_snap_syn_timer;
int offlineCount=0; int offlineCount=0;
TCV_HumanDetector *detector; TCV_HumanDetector *detector;
P_HLPR_Context ctx ; P_HLPR_Context ctx ;
QSemaphore semaphore; QSemaphore semaphore;
int timeoutMs;
int image_save; int image_save;
std::atomic<uint64> faceCount; std::atomic<uint64> faceCount;
uint64 face_frequency; uint64 face_frequency;
__uint8_t algorithmPermissions;
}; };
#endif // CAMERAHANDLE_H #endif // CAMERAHANDLE_H
#ifndef FACERECOGNITION_H #ifndef FACERECOGNITION_H
#define FACERECOGNITION_H #define FACERECOGNITION_H
#include "hyperface.h" #include "hyperface.h"
#include <opencv2/opencv.hpp>
#include<QCoreApplication>
#include "herror.h" #include "herror.h"
#include "LogHandle.h" #include "LogHandle.h"
#include "VidesData.h" #include "VidesData.h"
#include <QReadWriteLock> #include <opencv2/opencv.hpp>
#include<QCoreApplication>
class FaceReconition class FaceReconition
{ {
...@@ -16,10 +17,8 @@ private: ...@@ -16,10 +17,8 @@ private:
HContextHandle ctxHandle=nullptr; HContextHandle ctxHandle=nullptr;
float configConfidence; float configConfidence;
std::vector<int32_t>customIds;
QReadWriteLock rwLock; std::vector<int32_t>customIds;
FaceReconition(); FaceReconition();
~FaceReconition(); ~FaceReconition();
...@@ -32,11 +31,12 @@ public: ...@@ -32,11 +31,12 @@ public:
return instance; return instance;
} }
cv::Mat loadImage(const QString &path); cv::Mat loadImage(const QString &path);
cv::Mat loadImageFromByteStream(const QString& filePath);
void doesItExistEmployee(const cv::Mat &source,std::list<vides_data::faceRecognitionResult>&face); void doesItExistEmployee(const cv::Mat &source,std::list<vides_data::faceRecognitionResult>&face);
void initSourceImageMap(std::map<QString,QString>&maps,float confidence); void initSourceImageMap(std::map<QString,QString>&maps,int numberFaces,float confidence);
int featureRemove(); int featureRemove();
}; };
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
#include <QImage> #include <QImage>
#include <QThread> #include <QThread>
#define cimg_display 0
#include "CImg.h"
using namespace cimg_library;
FaceReconition::FaceReconition() {} FaceReconition::FaceReconition() {}
...@@ -15,33 +20,44 @@ FaceReconition::~FaceReconition(){ ...@@ -15,33 +20,44 @@ FaceReconition::~FaceReconition(){
FaceReconition* FaceReconition::instance = nullptr; FaceReconition* FaceReconition::instance = nullptr;
//cv::Mat FaceReconition::loadImage(const QString &path) {
// // 尝试使用OpenCV直接加载图像
// std::string stdPath = path.toStdString(); // 将路径转换为std::string
// cv::Mat image = cv::imread(stdPath, cv::IMREAD_COLOR); // 尝试加载图像
// if (!image.empty()) {
// qDebug() << "图像以OpenCV成功加载。";
// return image;
// }
// // 使用OpenCV加载失败,尝试使用QImage
// qDebug() << "使用OpenCV加载图像失败,尝试QImage转换。";
// QImage qimg(path);
// if (qimg.isNull()) {
// qDebug() << "QImage也无法加载图像,检查文件路径或文件损坏。";
// return cv::Mat(); // 返回空的cv::Mat对象
// }
// // 转换QImage格式为RGB888
// QImage converted = qimg.convertToFormat(QImage::Format_RGB888);
// cv::Mat mat(converted.height(), converted.width(), CV_8UC3, const_cast<uchar*>(converted.bits()), static_cast<size_t>(converted.bytesPerLine()));
// // 不进行颜色转换,直接返回
// return mat;
//}
cv::Mat FaceReconition::loadImage(const QString &path) { cv::Mat FaceReconition::loadImage(const QString &path) {
// 尝试使用OpenCV直接加载图像 // 尝试使用OpenCV直接加载图像
std::string stdPath = path.toStdString(); // 将路径转换为std::string 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成功加载。"; qDebug() << "图像以OpenCV成功加载。";
return image; return image;
} }
// 使用OpenCV加载失败,尝试使用QImage return loadImageFromByteStream(path);
qDebug() << "使用OpenCV加载图像失败,尝试QImage转换。";
QImage qimg(path);
if (qimg.isNull()) {
qDebug() << "QImage也无法加载图像,检查文件路径或文件损坏。";
return cv::Mat(); // 返回空的cv::Mat对象
}
// 转换QImage格式为RGB888
QImage converted = qimg.convertToFormat(QImage::Format_RGB888);
cv::Mat mat(converted.height(), converted.width(), CV_8UC3, const_cast<uchar*>(converted.bits()), converted.bytesPerLine());
// 将RGB转换为BGR,以便OpenCV处理
cv::cvtColor(mat, mat, cv::COLOR_RGB2BGR);
return mat;
} }
void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float confidence){ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,int numberFaces,float confidence){
//QWriteLocker locker(&rwLock); //QWriteLocker locker(&rwLock);
featureRemove(); featureRemove();
HResult ret; HResult ret;
...@@ -62,7 +78,7 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con ...@@ -62,7 +78,7 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con
HF_DetectMode detMode = HF_DETECT_MODE_IMAGE; // 选择图像模式 即总是检测 HF_DetectMode detMode = HF_DETECT_MODE_IMAGE; // 选择图像模式 即总是检测
if(ctxHandle==nullptr){ if(ctxHandle==nullptr){
// 创建ctx // 创建ctx
ret = HF_CreateFaceContextFromResourceFileOptional(path, option, detMode, 5, &ctxHandle); ret = HF_CreateFaceContextFromResourceFileOptional(path, option, detMode, numberFaces, &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;
...@@ -149,6 +165,45 @@ int FaceReconition::featureRemove(){ ...@@ -149,6 +165,45 @@ int FaceReconition::featureRemove(){
} }
} }
} }
cv::Mat FaceReconition::loadImageFromByteStream(const QString& filePath) {
try {
// 使用 CImg 读取 JPEG 图像
QByteArray bPath =filePath.toUtf8();
const char* ctr=bPath.data();
CImg<unsigned char> cimg_image(ctr);
// 将 CImg 对象转换为 OpenCV 的 Mat 格式
int width = cimg_image.width();
int height = cimg_image.height();
int channels = cimg_image.spectrum(); // 图像通道数
// 创建一个对应的空 Mat 对象
cv::Mat opencv_image(height, width, channels == 1 ? CV_8UC1 : CV_8UC3);
// 复制图像数据到 Mat 对象
cimg_forXY(cimg_image, x, y) {
if (channels == 1) {
opencv_image.at<unsigned char>(y, x) = cimg_image(x, y, 0, 0);
} else {
// 注意 OpenCV 默认使用 BGR 而不是 RGB
cv::Vec3b& opencv_pixel = opencv_image.at<cv::Vec3b>(y, x);
opencv_pixel[2] = cimg_image(x, y, 0, 0); // Red
opencv_pixel[1] = cimg_image(x, y, 0, 1); // Green
opencv_pixel[0] = cimg_image(x, y, 0, 2); // Blue
}
}
return opencv_image;
} catch (const CImgException& e) {
qDebug() << "CImg Error: " << e.what();
return cv::Mat();;
} catch (const cv::Exception& e) {
qDebug() << "OpenCV Error: " << e.what();
return cv::Mat(); ;
}
return cv::Mat();
}
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){
//QReadLocker locker(&rwLock); //QReadLocker locker(&rwLock);
HResult ret; HResult ret;
...@@ -207,34 +262,6 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d ...@@ -207,34 +262,6 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d
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);
// Face Pipeline // Face Pipeline
ret = HF_MultipleFacePipelineProcess(ctxHandle, imageSteamHandle, &multipleFaceData, parameter);
if (ret != HSUCCEED) {
//printf("pipeline执行失败: %ld", ret);
qInfo()<<QString("pipeline执行失败: %1").arg(ret);
return ;
}
HF_RGBLivenessConfidence livenessConfidence = {0};
ret = HF_GetRGBLivenessConfidence(ctxHandle, &livenessConfidence);
if (ret != HSUCCEED) {
qInfo()<<QString("获取活体数据失败1");
return ;
}
//printf("活体置信度: %f", livenessConfidence.confidence[0]);
qDebug()<<QString("活体置信度====>:%1").arg(livenessConfidence.confidence[0],0,'Q',4);
HF_FaceMaskConfidence maskConfidence = {0};
ret = HF_GetFaceMaskConfidence(ctxHandle, &maskConfidence);
if (ret != HSUCCEED) {
qInfo()<<QString("获口罩数据失败");
return ;
}
HInt32 faceNum;
ret = HF_FeatureGroupGetCount(ctxHandle, &faceNum);
if (ret != HSUCCEED) {
// printf("获取失败");
qInfo()<<QString("获取失败");
return ;
}
//printf("人脸特征数量: %d", faceNum); //printf("人脸特征数量: %d", faceNum);
if (confidence > configConfidence) { if (confidence > configConfidence) {
vides_data::faceRecognitionResult newface; vides_data::faceRecognitionResult newface;
......
...@@ -14,36 +14,52 @@ HttpService::~HttpService() { ...@@ -14,36 +14,52 @@ HttpService::~HttpService() {
vides_data::response* HttpService::httpPostDeviceStatus(vides_data::requestDeviceStatus & deviceStatus) { vides_data::response* HttpService::httpPostDeviceStatus(vides_data::requestDeviceStatus & deviceStatus) {
httpUrl.append("/api/v1.0/device/ping"); httpUrl.append("/api/v1.0/device/ping");
// 创建主 JSON 对象
QJsonObject json; QJsonObject json;
json.insert("sn",deviceStatus.sSn); json.insert("sn", deviceStatus.sSn);
json.insert("type",deviceStatus.type); json.insert("type", deviceStatus.type);
json.insert("state",deviceStatus.status); json.insert("state", deviceStatus.status);
json.insert("ip_addr",deviceStatus.ip_addr); json.insert("ip_addr", deviceStatus.ip_addr);
QJsonDocument jsonDoc; json.insert("firmware_version", deviceStatus.firmware_version); // 将固件版本添加到主 JSON 对象中
jsonDoc.setObject(json);
QByteArray bytearr= jsonDoc.toJson(QJsonDocument::Compact); // 创建摄像头信息列表 JSON 数组
QJsonArray cameraArray;
vides_data::response *resp=new vides_data::response(); for (const auto& cameraInfo : deviceStatus.camera_info_list) {
QJsonObject cameraObject;
cameraObject.insert("sn", cameraInfo.sSn);
cameraObject.insert("ip_addr", cameraInfo.ip_addr);
cameraObject.insert("firmware_version", cameraInfo.firmware_version);
cameraArray.append(cameraObject);
}
// 将摄像头信息列表添加到主 JSON 对象中
json.insert("camera_info_list", cameraArray);
// 将 JSON 对象转换为 JSON 文档
QJsonDocument jsonDoc(json);
QByteArray bytearr = jsonDoc.toJson(QJsonDocument::Compact);
vides_data::response *resp = new vides_data::response();
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl(httpUrl)); request.setUrl(QUrl(httpUrl));
request.setRawHeader(vides_data::HEADER_TYPE_KAY, vides_data::HEADER_TYPE_VALUE); request.setRawHeader(vides_data::HEADER_TYPE_KAY, vides_data::HEADER_TYPE_VALUE);
QMutexLocker locker(&m_httpClientMutex); QMutexLocker locker(&m_httpClientMutex);
if(m_httpClient.post(request,bytearr)){ if (m_httpClient.post(request, bytearr)) {
QByteArray && byte=m_httpClient.text().toUtf8(); QByteArray && byte = m_httpClient.text().toUtf8();
QJsonDocument docujson= QJsonDocument::fromJson(byte.data()); QJsonDocument docujson = QJsonDocument::fromJson(byte.data());
QJsonObject maps= docujson.object(); QJsonObject maps = docujson.object();
QVariantMap map =std::move(maps.toVariantMap()); QVariantMap map = std::move(maps.toVariantMap());
resp->code=map["code"].toInt(); resp->code = map["code"].toInt();
resp->msg=map["message"].toString(); resp->msg = map["message"].toString();
}else{ } else {
qDebug()<<"httpPostDeviceStatus"<<m_httpClient.errorCode(); qDebug() << "httpPostDeviceStatus" << m_httpClient.errorCode();
resp->code=2; resp->code = 2;
resp->msg=OPERATION_FAILED; resp->msg = m_httpClient.errorString();
} }
return resp; return resp;
} }
vides_data::response* HttpService::httpPostRecord(int id,int recongnition_type,QString sn,QString videw_addr){ vides_data::response* HttpService::httpPostRecord(int id,int recongnition_type,QString sn,QString videw_addr){
httpUrl.append("/api/v1.0/recongnition/record"); httpUrl.append("/api/v1.0/recongnition/record");
...@@ -108,7 +124,8 @@ vides_data::response *HttpService::httpFindCameras(QString &serialNumber,vides_d ...@@ -108,7 +124,8 @@ vides_data::response *HttpService::httpFindCameras(QString &serialNumber,vides_d
HttpService::stsCredentials.endpoint=responseData.sts_credentials.endpoint = stsCredentialsObj["endpoint"].toString(); HttpService::stsCredentials.endpoint=responseData.sts_credentials.endpoint = stsCredentialsObj["endpoint"].toString();
HttpService::stsCredentials.expiration=responseData.sts_credentials.expiration = stsCredentialsObj["expiration"].toString(); HttpService::stsCredentials.expiration=responseData.sts_credentials.expiration = stsCredentialsObj["expiration"].toString();
HttpService::stsCredentials.security_token=responseData.sts_credentials.security_token = stsCredentialsObj["security_token"].toString(); HttpService::stsCredentials.security_token=responseData.sts_credentials.security_token = stsCredentialsObj["security_token"].toString();
int algorithm= dataObj["algorithm"].toInt();
responseData.algorithm=algorithm;
QJsonArray dataArray = dataObj["list"].toArray(); QJsonArray dataArray = dataObj["list"].toArray();
for (const QJsonValue& value : dataArray) { for (const QJsonValue& value : dataArray) {
vides_data::responseDeviceStatus status; vides_data::responseDeviceStatus status;
...@@ -116,6 +133,7 @@ vides_data::response *HttpService::httpFindCameras(QString &serialNumber,vides_d ...@@ -116,6 +133,7 @@ vides_data::response *HttpService::httpFindCameras(QString &serialNumber,vides_d
status.sSn = deviceObject["sn"].toString(); status.sSn = deviceObject["sn"].toString();
status.type = static_cast<int8_t>(deviceObject["type"].toInt()); status.type = static_cast<int8_t>(deviceObject["type"].toInt());
status.is_reboot=deviceObject["is_reboot"].toBool();
status.merchant_id = static_cast<int8_t>(deviceObject["merchant_id"].toInt()); status.merchant_id = static_cast<int8_t>(deviceObject["merchant_id"].toInt());
// 处理"areas"数组 // 处理"areas"数组
...@@ -268,6 +286,39 @@ vides_data::response* HttpService::httpFindFaceReconition(QString &serialNumber, ...@@ -268,6 +286,39 @@ vides_data::response* HttpService::httpFindFaceReconition(QString &serialNumber,
} }
return resp; return resp;
} }
vides_data::response *HttpService::httpPostUniforms(QByteArray &img,int &number,QString sn,qint64 time){
httpUrl.append("/api/v1.0/recongnition/uniform");
QJsonObject json;
json.insert("img", QJsonValue::fromVariant(img));
json.insert("sn",sn);
json.insert("number",number);
json.insert("time",QJsonValue::fromVariant(time));
QJsonDocument jsonDoc;
jsonDoc.setObject(json);
QByteArray bytearr= jsonDoc.toJson(QJsonDocument::Compact);
vides_data::response *resp=new vides_data::response();
QNetworkRequest request;
request.setUrl(QUrl(httpUrl));
request.setRawHeader(vides_data::HEADER_TYPE_KAY, vides_data::HEADER_TYPE_VALUE);
QMutexLocker locker(&m_httpClientMutex);
if(m_httpClient.post(request,bytearr)){
QByteArray && byte=m_httpClient.text().toUtf8();
QJsonDocument docujson= QJsonDocument::fromJson(byte.data());
QJsonObject maps= docujson.object();
QVariantMap map =maps.toVariantMap();
resp->code=map["code"].toInt();
resp->msg=map["message"].toString();
}else{
qDebug()<<m_httpClient.errorCode();
qDebug()<<"httpPostUniforms"<<m_httpClient.errorString();
resp->code=2;
resp->msg=OPERATION_FAILED;
}
return resp;
}
vides_data::response *HttpService::httpPostFacePopulation(QByteArray &img,int &number,QString sn,qint64 time){ vides_data::response *HttpService::httpPostFacePopulation(QByteArray &img,int &number,QString sn,qint64 time){
httpUrl.append("/api/v1.0/recongnition/population"); httpUrl.append("/api/v1.0/recongnition/population");
QJsonObject json; QJsonObject json;
......
...@@ -35,6 +35,9 @@ public: ...@@ -35,6 +35,9 @@ public:
vides_data::response *httpPostFaceReconition(vides_data::requestFaceReconition & faceReconition); vides_data::response *httpPostFaceReconition(vides_data::requestFaceReconition & faceReconition);
//人数变化推送 //人数变化推送
vides_data::response *httpPostFacePopulation(QByteArray &img,int &number,QString sn,qint64 time); vides_data::response *httpPostFacePopulation(QByteArray &img,int &number,QString sn,qint64 time);
//工服推送
vides_data::response *httpPostUniforms(QByteArray &img,int &number,QString sn,qint64 time);
//客户端组列表 //客户端组列表
vides_data::response *httpFindStream(QString &serialNumber); vides_data::response *httpFindStream(QString &serialNumber);
......
...@@ -15,10 +15,34 @@ int HumanDetection::findHuManCar(const cv::Mat &source,int res,TCV_HumanDetector ...@@ -15,10 +15,34 @@ int HumanDetection::findHuManCar(const cv::Mat &source,int res,TCV_HumanDetector
// 执行一帧目标检测 // 执行一帧目标检测
TCV_HumanDetectorProcessFrame(detector, stream); TCV_HumanDetectorProcessFrame(detector, stream);
int num = (res == 0) ? TCV_HumanDetectorGetNumOfHuman(detector) :TCV_HumanDetectorGetNumOfCar(detector); int num=-1;
qDebug() << (res == 0 ? "Number of people detected:" : "Number of cars detected:") << num; if(res==0x00 || res==0x02){
TCV_ReleaseCameraStream(stream); num= TCV_HumanDetectorGetNumOfHuman(detector);
if (num > 0 && res==0x02) {
// 创建一个接收检测结果的对象数组
TCV_ObjectLocation result[num];
// 提取行人检测结果
TCV_HumanDetectorGetHumanLocation(detector, result, num);
int num_uniforms = 0;
//工服
for (int i = 0; i < num; ++i) {
if (result[i].uniform == 0) {
++num_uniforms;
}
}
num=num_uniforms;
}
qDebug() << (res == 0 ? "Number of people detected:" : "Number of people with uniform == 0 detected:") << num;
}else if (res==0x01) {
num=TCV_HumanDetectorGetNumOfCar(detector);
qDebug() << "Number of cars detected:" << num;
}else {
qDebug() << "参数错误";
}
TCV_ReleaseCameraStream(stream);
return num; return num;
} }
...@@ -21,6 +21,7 @@ void ParkingSpaceInfo::removeQueue(){ ...@@ -21,6 +21,7 @@ void ParkingSpaceInfo::removeQueue(){
queuels.dequeue(); queuels.dequeue();
} }
} }
void ParkingSpaceInfo::removeNoQueue() { void ParkingSpaceInfo::removeNoQueue() {
QMutexLocker locker(&queueMutex); QMutexLocker locker(&queueMutex);
if (!queuels.isEmpty() && queuels.size() > 3) { if (!queuels.isEmpty() && queuels.size() > 3) {
......
...@@ -23,14 +23,27 @@ struct response ...@@ -23,14 +23,27 @@ struct response
QString msg; QString msg;
response() {} response() {}
}; };
struct requestCameraInfo{
QString ip_addr;
QString firmware_version;
QString sSn;
requestCameraInfo() {}
};
struct requestDeviceStatus struct requestDeviceStatus
{ {
QString sSn; QString sSn;
int8_t type; int8_t type;
int8_t status; int8_t status;
QString ip_addr; QString ip_addr;
QString firmware_version;
std::list<requestCameraInfo>camera_info_list;
requestDeviceStatus() {} requestDeviceStatus() {}
}; };
struct responseStsCredentials{ struct responseStsCredentials{
QString access_key_id; QString access_key_id;
QString access_key_secret; QString access_key_secret;
...@@ -67,10 +80,12 @@ struct responseDeviceStatus ...@@ -67,10 +80,12 @@ struct responseDeviceStatus
QString sSn; QString sSn;
int8_t type; int8_t type;
int8_t merchant_id; int8_t merchant_id;
bool is_reboot;
std::list<responseArea>areas; std::list<responseArea>areas;
responseDeviceStatus() {} responseDeviceStatus() : is_reboot(false) {}
}; };
struct responseDeviceData{ struct responseDeviceData{
int algorithm ;
std::list<responseDeviceStatus> list; std::list<responseDeviceStatus> list;
responseStsCredentials sts_credentials; responseStsCredentials sts_credentials;
}; };
...@@ -257,19 +272,22 @@ inline bool pingAddress(const QString &address) { ...@@ -257,19 +272,22 @@ inline bool pingAddress(const QString &address) {
return output.contains("1 packets transmitted, 1 received"); return output.contains("1 packets transmitted, 1 received");
} }
inline QString getSerialNumber() {
inline QString getCpuSerialNumber() {
QProcess process; QProcess process;
// 使用管道将两个命令的执行结果串联起来,直接查找包含"Serial"的行 // 启动一个进程运行shell命令
process.start("bash", QStringList() << "-c" << "cat /proc/cpuinfo | grep Serial"); process.start("sh", QStringList() << "-c" << "cat /proc/cpuinfo | grep Serial");
process.waitForFinished(-1); // 等待命令执行完成 // 等待命令执行完成
process.waitForFinished();
// 读取命令的标准输出
QString output = process.readAllStandardOutput(); QString output = process.readAllStandardOutput();
QString serialNumber; QString serialNumber;
if (!output.isEmpty()) { if (!output.isEmpty()) {
// 已经确保了输出仅包含 Serial 行,所以直接分割并提取 // 已经确保了输出仅包含 Serial 行,所以直接分割并提取
serialNumber = output.split(":").at(1).trimmed(); serialNumber = output.split(":").last().trimmed();
} }
return serialNumber; return serialNumber;
} }
} }
......
...@@ -3,7 +3,7 @@ QT += core gui network multimedia sql concurrent ...@@ -3,7 +3,7 @@ QT += core gui network multimedia sql concurrent
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 CONFIG += c++11
TARGET = GAMERAVIDEO TARGET = cameravideo
TEMPLATE = app TEMPLATE = app
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use
...@@ -11,45 +11,46 @@ TEMPLATE = app ...@@ -11,45 +11,46 @@ TEMPLATE = app
# depend on your compiler). Please consult the documentation of the # depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it. # deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += APP_VERSION=\\\"1.0.0\\\"
QMAKE_LIBDIR += /usr/local/lib #QMAKE_LIBDIR += /usr/local/lib
INCLUDEPATH+=/usr/local/include/opencv4 #INCLUDEPATH+=/usr/local/include/opencv4
INCLUDEPATH+=/usr/local/include/hyperface #INCLUDEPATH+=/usr/local/include/hyperface
INCLUDEPATH+=/usr/local/include/hyper #INCLUDEPATH+=/usr/local/include/hyper
INCLUDEPATH+=/usr/local/include/XNetSDK #INCLUDEPATH+=/usr/local/include/XNetSDK
INCLUDEPATH+=/usr/local/include/human #INCLUDEPATH+=/usr/local/include/human
#INCLUDEPATH+=/usr/local/include/CImg
unix:contains(QMAKE_HOST.arch, x86_64) {
#unix:contains(QMAKE_HOST.arch, x86_64) { QMAKE_LIBDIR += /home/mark/Public/x86_opencv/lib
# QMAKE_LIBDIR += /home/mark/Public/x86_opencv/lib }
#} unix:contains(QMAKE_HOST.arch, arm) {
#unix:contains(QMAKE_HOST.arch, arm) { QMAKE_LIBDIR += /usr/local/lib
# QMAKE_LIBDIR += /usr/local/lib }
#}
# 根据编译器类型选择库路径和头文件路径
## 根据编译器类型选择库路径和头文件路径 unix: {
#unix: { # x86 架构
# # x86 架构 contains(QMAKE_HOST.arch, x86_64) {
# contains(QMAKE_HOST.arch, x86_64) { INCLUDEPATH+=/home/mark/Public/x86_opencv/include/opencv4
# INCLUDEPATH+=/home/mark/Public/x86_opencv/include/opencv4 INCLUDEPATH+=/home/mark/Public/x86_opencv/include/hyperface
# INCLUDEPATH+=/home/mark/Public/x86_opencv/include/hyperface INCLUDEPATH+=/home/mark/Public/x86_opencv/include/hyper
# INCLUDEPATH+=/home/mark/Public/x86_opencv/include/hyper INCLUDEPATH+=/home/mark/Public/x86_opencv/include/XNetSDK
# INCLUDEPATH+=/home/mark/Public/x86_opencv/include/XNetSDK INCLUDEPATH+=/home/mark/Public/x86_opencv/include/human
# INCLUDEPATH+=/home/mark/Public/x86_opencv/include/human INCLUDEPATH+=/home/mark/Public/x86_opencv/include/CImg
# } }
# # ARM 架构 # ARM 架构
# contains(QMAKE_HOST.arch, arm) { contains(QMAKE_HOST.arch, arm) {
# INCLUDEPATH+=/usr/local/include/opencv4 INCLUDEPATH+=/usr/local/include/opencv4
# INCLUDEPATH+=/usr/local/include/hyperface INCLUDEPATH+=/usr/local/include/hyperface
# INCLUDEPATH+=/usr/local/include/hyper INCLUDEPATH+=/usr/local/include/hyper
# INCLUDEPATH+=/usr/local/include/XNetSDK INCLUDEPATH+=/usr/local/include/XNetSDK
# INCLUDEPATH+=/usr/local/include/human INCLUDEPATH+=/usr/local/include/human
# } }
#} }
# You can also make your code fail to compile if it uses deprecated APIs. # You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line. # In order to do so, uncomment the following line.
......
...@@ -40,37 +40,40 @@ public: ...@@ -40,37 +40,40 @@ public:
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,int algorithm,std::list<vides_data::requestCameraInfo>&camera_info_list);
__uint8_t intToUint8t(int algorithm);
static MainWindow * sp_this; static MainWindow * sp_this;
CameraHandle* findHandle(QString sn);
void sendJsonResponse(QTcpSocket* socket, int code, const QString& data, const QString& msg); void sendJsonResponse(QTcpSocket* socket, int code, const QString& data, const QString& msg);
void sendEmptyResponse(QTcpSocket* socket); void sendEmptyResponse(QTcpSocket* socket);
void sendNotFoundResponse(QTcpSocket* socket); void sendNotFoundResponse(QTcpSocket* socket);
void updateLocalFace(const QString &httpurl); void updateLocalFace(const QString &httpurl);
void removeImageFiles(QString id); void removeImageFiles(QString id);
void modifyImagesAndNames(QString &modId); void modifyImagesAndNames(QString &modId);
void findLocalSerialNumber(QString &serialNumber); void findLocalSerialNumber(QString &serialNumber);
void initDevConfigSyn(CameraHandle *cameraHandle); void initDevConfigSyn(CameraHandle *cameraHandle);
void iniRecordingToString(QString &recorJson); void iniRecordingToString(QString &recorJson);
void iniEncodeToString(QString &enCodeJson); void iniEncodeToString(QString &enCodeJson);
void clearOfflineCameraHandle(QString sDevId, int nDevPort); void clearOfflineCameraHandle(QString sDevId, int nDevPort);
bool iniWorkSpVMn(vides_data::responseGb28181 *gb28181,QString &workSpWMn,QString &sn); bool iniWorkSpVMn(vides_data::responseGb28181 *gb28181,QString &workSpWMn,QString &sn);
bool isDeviceInList(const QString& deviceId, const std::list<vides_data::responseDeviceStatus>& devices); bool isDeviceInList(const QString& deviceId, const std::list<vides_data::responseDeviceStatus>& devices);
// 过滤函数 // 过滤函数
void deleteCloudNotCamer (const std::map<QString,vides_data::localDeviceStatus*>& localDevices, void deleteCloudNotCamer (const std::map<QString,vides_data::localDeviceStatus*>& localDevices,
...@@ -84,9 +87,9 @@ private slots: ...@@ -84,9 +87,9 @@ private slots:
void startCamera(const QString &httpurl); void startCamera(const QString &httpurl);
void deleteLogFile(); void deleteLogFile();
void clearHandle(QString sDevId, int nDevPort); void clearHandle(QString sDevId, int nDevPort);
void deleteMkvFileTimer(); void deleteMkvFileTimer();
void handleMatNewConnection(); void handleMatNewConnection();
...@@ -98,11 +101,12 @@ private: ...@@ -98,11 +101,12 @@ private:
QTimer *deleteLogFileTimer; QTimer *deleteLogFileTimer;
QTimer *deleteFrameFileTimer; QTimer *deleteFrameFileTimer;
QTimer*dePermissionSynTimer; QTimer*dePermissionSynTimer;
QTcpServer server; QTcpServer server;
QString localSn;
//本地id:图片路径 //本地id:图片路径
std::map<QString,QString>localImageMap; std::map<QString,QString>localImageMap;
......
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