Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gamera_videos_no_ui
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liusq
gamera_videos_no_ui
Commits
84806c68
Commit
84806c68
authored
Oct 09, 2024
by
guof
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'revert-
25af28ce
' into 'release'
Revert
25af28ce
See merge request
!31
parents
59627230
abb7cb7b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
123 additions
and
243 deletions
+123
-243
AlgorithmTaskManage.cpp
+9
-9
CameraHandle.cpp
+0
-0
CameraHandle.h
+4
-24
Common.cpp
+4
-6
Common.h
+1
-3
FaceReconitionHandle.cpp
+11
-11
FaceReconitionHandle.h
+1
-1
HttpService.cpp
+7
-2
Httpclient.cpp
+1
-1
HumanDetection.cpp
+5
-2
HumanDetection.h
+1
-1
LicensePlateRecognition.cpp
+2
-0
LogHandle.h
+1
-1
LogHandler.cpp
+7
-18
MediaFaceImage.cpp
+15
-15
MediaFaceImage.h
+1
-1
MqttSubscriber.cpp
+28
-65
MqttSubscriber.h
+1
-1
ParkingSpaceInfo.cpp
+1
-0
VidesData.h
+13
-62
gamera_videos.pro
+0
-5
mainwindow.cpp
+0
-0
mainwindow.h
+10
-15
No files found.
AlgorithmTaskManage.cpp
View file @
84806c68
...
...
@@ -153,7 +153,7 @@ void* AlgorithmTaskManage::schedulingAlgorithm(int scheType) {
}
else
if
(
scheType
==
0x03
)
{
return
schedulingAlgorithmTemplate
(
faceReconitionHandles
,
mtxFace
);
}
else
{
q
Debug
()
<<
"参数错误"
;
q
Info
()
<<
"参数错误"
;
return
nullptr
;
}
}
...
...
@@ -170,10 +170,10 @@ void AlgorithmTaskManage::executeFindDoesItExistEmployee(const cv::Mat &source,s
if
(
selectedFaceReconition
!=
nullptr
&&
!
selectedFaceReconition
->
getImageChanged
())
{
selectedFaceReconition
->
setIsRunning
(
true
);
// 调用选定对象的doesItExistEmployee函数
q
Debug
()
<<
"人脸识别算法抢到===>sn"
<<
sSn
<<
selectedFaceReconition
;
selectedFaceReconition
->
doesItExistEmployee
(
s
Sn
,
s
ource
,
faces
);
q
Info
()
<<
"人脸识别算法抢到===>sn"
<<
sSn
<<
selectedFaceReconition
;
selectedFaceReconition
->
doesItExistEmployee
(
source
,
faces
);
}
else
{
q
Debug
()
<<
"没有可用的selectedFaceReconition对象可以调度"
;
q
Info
()
<<
"没有可用的selectedFaceReconition对象可以调度"
;
return
;
}
}
...
...
@@ -192,10 +192,10 @@ void AlgorithmTaskManage::executeFindlicensePlateNumber(const cv::Mat &source, Q
if
(
selectedLicensePlate
!=
nullptr
)
{
selectedLicensePlate
->
setIsRunning
(
true
);
// 调用选定对象的findHuManCar函数
q
Debug
()
<<
"车牌调度算法抢到===>sn"
<<
sSn
<<
selectedLicensePlate
;
q
Info
()
<<
"车牌调度算法抢到===>sn"
<<
sSn
<<
selectedLicensePlate
;
selectedLicensePlate
->
licensePlateNumber
(
source
,
lpNumber
,
plate
,
currentTime
);
}
else
{
q
Debug
()
<<
"没有可用的selectedLicensePlate对象可以调度"
;
q
Info
()
<<
"没有可用的selectedLicensePlate对象可以调度"
;
return
;
}
}
...
...
@@ -214,11 +214,11 @@ int AlgorithmTaskManage::executeFindHuManCar(const cv::Mat &source, int res,
selectedHumanDetection
->
setIsRunning
(
true
);
// 调用选定对象的findHuManCar函数
q
Debug
()
<<
"人形调度算法抢到===>sn"
<<
sSn
<<
"res"
<<
selectedHumanDetection
;
int
detectionResult
=
selectedHumanDetection
->
findHuManCar
(
source
,
res
,
resMap
,
sSn
,
heightReference
,
currentPlate
);
q
Info
()
<<
"人形调度算法抢到===>sn"
<<
sSn
<<
"res"
<<
selectedHumanDetection
;
int
detectionResult
=
selectedHumanDetection
->
findHuManCar
(
source
,
res
,
resMap
,
heightReference
,
currentPlate
);
return
detectionResult
;
}
else
{
q
Debug
()
<<
"没有可用的HumanDetection对象可以调度"
;
q
Info
()
<<
"没有可用的HumanDetection对象可以调度"
;
return
-
2
;
}
}
CameraHandle.cpp
View file @
84806c68
This diff is collapsed.
Click to expand it.
CameraHandle.h
View file @
84806c68
...
...
@@ -31,7 +31,6 @@
#include <opencv2/opencv.hpp>
#include <QSemaphore>
#include <atomic>
#include <arpa/inet.h>
enum
CAR_INFORMATION
{
Exit
,
//出场
...
...
@@ -58,12 +57,11 @@ public:
void
clearCameraHandle
();
bool
distributionNetwork
(
QString
&
ip
);
// void rebindTimer(int hDevice);
//相机参数更新
void
cameraParameterUpdate
(
vides_data
::
responseConfig
&
cloudConfig
);
void
initSdkRealTimeDevSnapSyn
(
int
syn_timer
,
uint64
face_frequency
);
void
initSdkRealTimeDevSnapSyn
(
int
hDevice
,
int
syn_timer
,
uint64
face_frequency
);
void
notificationUpdateImageMap
(
std
::
map
<
QString
,
QString
>&
maps
,
int
numberFaces
,
float
confidence
);
...
...
@@ -87,17 +85,10 @@ public:
void
printWifi
(
XSDK_HANDLE
hDevice
,
XSDK_CFG
::
NetWork_Wifi
&
cfg
);
bool
isWifiConnect
(
XSDK_HANDLE
hDevice
,
XSDK_CFG
::
NetWork_Wifi
&
cfg
);
void
setCarConfidenceMaxAndMin
(
float
carConfidenceMax
,
float
carConfidenceMin
);
QString
DecIpToHexIp
(
const
QString
&
decIp
);
//修改相机IP
bool
wifiChangeIp
(
QString
&
Ip
,
bool
is_connect
,
int
h_device
);
//设置相机连接的wifi
bool
sdkWifi
(
QString
&
pwd
,
QString
&
ssid
);
void
sdkWifi
(
QString
&
pwd
,
QString
&
ssid
);
//时间设置
void
sdkDevSystemTimeZoneSyn
(
QString
&
time
);
//录像设置
...
...
@@ -116,11 +107,7 @@ public:
int
deviceShutdown
();
//获取固件版本
void
findFirmwareVersion
(
QString
&
firmwareVersion
);
//复位GB28181
int
resetGb28181
();
//修改相机ip
bool
changeCameraIp
(
QString
&
reachableIp
);
//获取ip
void
findIp
(
QString
&
ip
);
...
...
@@ -140,10 +127,6 @@ public:
void
setMediaHandle
(
int
mediaHandle
);
void
initAlgorithmPermissions
(
__uint8_t
algorithm
);
void
initFaceFrequency
(
uint64
face_frequency
);
void
initParkingSpaceInfo
(
const
std
::
list
<
vides_data
::
responseArea
>&
areas
);
bool
compareLists
(
const
std
::
list
<
vides_data
::
responseArea
>&
newAreas
);
...
...
@@ -175,7 +158,7 @@ signals:
void
afterDownloadFile
(
int
id
,
int
recognitionType
,
QString
ossUrl
);
private
slots
:
void
sdkRealTimeDevSnapSyn
();
void
sdkRealTimeDevSnapSyn
(
int
hDevice
);
void
pushRecordToCloud
(
int
id
,
int
recognitionType
,
QString
ossUrl
);
//void releaseSemaphore();
...
...
@@ -212,9 +195,6 @@ private :
int
image_save
;
std
::
atomic
<
uint64
>
faceCount
;
std
::
atomic
<
bool
>
isOperateGb28181
{
false
};
uint64
face_frequency
;
__uint8_t
algorithmPermissions
;
...
...
Common.cpp
View file @
84806c68
...
...
@@ -24,7 +24,7 @@ QString Common::generateSignature(const QString& accessKeySecret, const QString&
date
+
"
\n
"
+
ossHeaders
+
"
\n
"
+
// 添加'\n'分隔符,并确保ossHeaders末尾没有多余的空白
canonicalizedResource
;
// 将密钥和消息转换为字节数组
QByteArray
hmacKey
=
accessKeySecret
.
toUtf8
();
QByteArray
message
=
stringToSign
.
toUtf8
();
...
...
@@ -32,10 +32,10 @@ QString Common::generateSignature(const QString& accessKeySecret, const QString&
QMessageAuthenticationCode
mac
(
QCryptographicHash
::
Sha1
);
mac
.
setKey
(
hmacKey
);
mac
.
addData
(
message
);
QByteArray
signature
=
mac
.
result
().
toBase64
();
// 直接使用QMessageAuthenticationCode的结果
return
QString
(
signature
);
}
QString
Common
::
getVideoOut
(){
...
...
@@ -62,8 +62,6 @@ void Common::setImages(QString images){
images
.
append
(
"/"
);
this
->
images
=
images
;
}
QString
Common
::
GetLocalIp
()
{
QString
ipAddress
;
QList
<
QHostAddress
>
list
=
QNetworkInterface
::
allAddresses
();
...
...
Common.h
View file @
84806c68
...
...
@@ -10,7 +10,7 @@
#include <QCryptographicHash>
#include <QMessageAuthenticationCode>
#include <QNetworkInterface>
#include <map>
#include <QDebug>
class
Common
{
...
...
@@ -38,7 +38,6 @@ public:
QString
getVideoDownload
();
void
setVideoDownload
(
QString
videoDownload
);
QString
getImages
();
void
setImages
(
QString
images
);
...
...
@@ -62,7 +61,6 @@ private:
QString
videoOut
;
QString
videoDownload
;
QString
images
;
Common
();
~
Common
();
...
...
FaceReconitionHandle.cpp
View file @
84806c68
...
...
@@ -192,7 +192,7 @@ cv::Mat FaceReconitionHandle::loadImageFromByteStream(const QString& filePath) {
void
FaceReconitionHandle
::
doesItExistEmployee
(
const
QString
&
sn
,
const
cv
::
Mat
&
source
,
std
::
list
<
vides_data
::
faceRecognitionResult
>&
faces
){
void
FaceReconitionHandle
::
doesItExistEmployee
(
const
cv
::
Mat
&
source
,
std
::
list
<
vides_data
::
faceRecognitionResult
>&
faces
){
thread_time
.
store
(
QDateTime
::
currentMSecsSinceEpoch
(),
std
::
memory_order_release
);
ScopeSemaphoreExit
streamGuard
([
this
]()
{
isRunning
.
store
(
false
,
std
::
memory_order_release
);
...
...
@@ -211,14 +211,14 @@ void FaceReconitionHandle::doesItExistEmployee(const QString &sn,const cv::Mat &
ret
=
HF_CreateImageStream
(
&
imageData
,
&
imageSteamHandle
);
if
(
ret
!=
HSUCCEED
)
{
qInfo
()
<<
QString
(
"
SN(%1): image handle error:%2"
).
arg
(
sn
).
arg
((
long
)
imageSteamHandle
,
0
,
10
);
qInfo
()
<<
QString
(
"
image handle error:%1"
).
arg
((
long
)
imageSteamHandle
,
0
,
10
);
return
;
}
HF_MultipleFaceData
multipleFaceData
=
{
0
};
HF_FaceContextRunFaceTrack
(
ctxHandle
,
imageSteamHandle
,
&
multipleFaceData
);
if
(
multipleFaceData
.
detectedNum
<=
0
)
{
qInfo
()
<<
QString
(
"
SN(%1): 未检测到人脸"
).
arg
(
sn
);
qInfo
()
<<
QString
(
"
search 未检测到人脸"
);
return
;
}
...
...
@@ -227,12 +227,11 @@ void FaceReconitionHandle::doesItExistEmployee(const QString &sn,const cv::Mat &
HInt32
featureNum
;
HF_GetFeatureLength
(
ctxHandle
,
&
featureNum
);
for
(
int
j
=
0
;
j
<
multipleFaceData
.
detectedNum
;
++
j
){
//qInfo()<<QString("doesItExistEmployee==>面部索引: %1").arg(j);
qDebug
()
<<
QString
(
"SN(%1): 面部索引:%2"
).
arg
(
sn
).
arg
(
j
);
qInfo
()
<<
QString
(
"doesItExistEmployee==>面部索引: %1"
).
arg
(
j
);
std
::
vector
<
float
>
newfeature
(
featureNum
,
0.0
f
);
ret
=
HF_FaceFeatureExtractCpy
(
ctxHandle
,
imageSteamHandle
,
multipleFaceData
.
tokens
[
j
],
newfeature
.
data
());
if
(
ret
!=
HSUCCEED
)
{
qInfo
()
<<
QString
(
"SN(%1): 特征提取出错:%2"
).
arg
(
sn
).
arg
(
ret
);
qInfo
()
<<
QString
(
"特征提取出错: %1"
).
arg
(
ret
);
HF_ReleaseImageStream
(
imageSteamHandle
);
return
;
}
...
...
@@ -249,12 +248,13 @@ void FaceReconitionHandle::doesItExistEmployee(const QString &sn,const cv::Mat &
HFloat
confidence
;
ret
=
HF_FeaturesGroupFeatureSearch
(
ctxHandle
,
feature
,
&
confidence
,
&
searchIdentity
);
if
(
ret
!=
HSUCCEED
)
{
qInfo
()
<<
QString
(
"SN(%1): 搜索失败:%2"
).
arg
(
sn
).
arg
(
ret
);
qInfo
()
<<
QString
(
"搜索失败: %1"
).
arg
(
ret
);
return
;
}
qInfo
()
<<
QString
(
"SN(%1): 搜索置信度:%2"
).
arg
(
sn
).
arg
(
confidence
);
qInfo
()
<<
QString
(
"SN(%1): 匹配到的tag:%2"
).
arg
(
sn
).
arg
(
searchIdentity
.
tag
);
qInfo
()
<<
QString
(
"SN(%1): 匹配到的customId:%2"
).
arg
(
sn
).
arg
(
searchIdentity
.
customId
);
qInfo
()
<<
QString
(
"搜索置信度: %1"
).
arg
(
confidence
);
qInfo
()
<<
QString
(
"匹配到的tag: %1"
).
arg
(
searchIdentity
.
tag
);
qInfo
()
<<
QString
(
"匹配到的customId: %1"
).
arg
(
searchIdentity
.
customId
);
// Face Pipeline
//printf("人脸特征数量: %d", faceNum);
if
(
confidence
>
configConfidence
)
{
...
...
@@ -275,7 +275,7 @@ void FaceReconitionHandle::doesItExistEmployee(const QString &sn,const cv::Mat &
// printf("image released");
}
else
{
//printf("image release error: %ld", ret);
qInfo
()
<<
QString
(
"SN(%1): image release error:%2"
).
arg
(
sn
).
arg
(
ret
);
qInfo
()
<<
QString
(
"image release error: %1"
).
arg
(
ret
);
}
}
FaceReconitionHandle.h
View file @
84806c68
...
...
@@ -33,7 +33,7 @@ public:
void
setImageChanged
(
bool
imageChanged
);
void
doesItExistEmployee
(
const
QString
&
sn
,
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
,
int
numberFaces
,
float
confidence
);
...
...
HttpService.cpp
View file @
84806c68
...
...
@@ -161,7 +161,7 @@ vides_data::response *HttpService::httpFindCameras(QString &serialNumber,vides_d
}
else
{
qInfo
()
<<
m_httpClient
.
errorCode
();
resp
->
code
=
2
;
resp
->
msg
=
m_httpClient
.
errorCode
()
;
resp
->
msg
=
OPERATION_FAILED
;
}
return
resp
;
}
...
...
@@ -354,6 +354,11 @@ vides_data::response *HttpService::httpPostFacePopulation(QByteArray &img,int &h
resp
->
code
=
map
[
"code"
].
toInt
();
resp
->
msg
=
map
[
"message"
].
toString
();
}
else
{
qInfo
()
<<
"httpPostFacePopulation===>"
;
qInfo
()
<<
m_httpClient
.
errorCode
();
qInfo
()
<<
m_httpClient
.
errorString
();
qInfo
()
<<
"httpPostFacePopulation===>end"
;
resp
->
code
=
2
;
resp
->
msg
=
m_httpClient
.
errorCode
();
}
...
...
@@ -506,6 +511,7 @@ vides_data::response *HttpService::httpDeviceConfig(const QString &serialNumber,
QJsonObject
faceConfigObj
=
dataObj
[
"faceConfig"
].
toObject
();
config
.
faceConfig
.
isOn
=
faceConfigObj
[
"isOn"
].
toBool
();
config
.
faceConfig
.
faceNumbers
=
faceConfigObj
[
"faceNumbers"
].
toInt
();
config
.
faceConfig
.
faceFrequency
=
faceConfigObj
[
"faceFrequency"
].
toInt
();
config
.
faceConfig
.
confidence
=
faceConfigObj
[
"confidence"
].
toVariant
().
toFloat
();
config
.
faceConfig
.
updateAt
=
faceConfigObj
[
"updateAt"
].
toVariant
().
toULongLong
();
config
.
faceConfig
.
faceLen
=
faceConfigObj
[
"faceLen"
].
toInt
();
...
...
@@ -536,7 +542,6 @@ vides_data::response *HttpService::httpDeviceConfig(const QString &serialNumber,
QJsonObject
humanConfigObj
=
dataObj
[
"humanConfig"
].
toObject
();
config
.
humanConfig
.
isOn
=
humanConfigObj
[
"isOn"
].
toBool
();
config
.
humanConfig
.
updateAt
=
humanConfigObj
[
"updateAt"
].
toVariant
().
toULongLong
();
config
.
humanConfig
.
faceFrequency
=
humanConfigObj
[
"faceFrequency"
].
toVariant
().
toUInt
();
// 解析 devicesConfig
QJsonObject
devicesConfigObj
=
dataObj
[
"camera"
].
toObject
();
...
...
Httpclient.cpp
View file @
84806c68
...
...
@@ -7,7 +7,7 @@ HttpClient::HttpClient(QObject *parent)
{
m_networkAccessManager
=
new
QNetworkAccessManager
(
this
);
m_timer
=
new
QTimer
(
this
);
m_timer
->
setInterval
(
8
000
);
m_timer
->
setInterval
(
6
000
);
m_timer
->
setSingleShot
(
true
);
connect
(
m_timer
,
SIGNAL
(
timeout
()),
&
m_eventLoop
,
SLOT
(
quit
()));
}
...
...
HumanDetection.cpp
View file @
84806c68
...
...
@@ -77,7 +77,7 @@ void HumanDetection::setHuManParameter(int &uniformColor){
}
//0 人形 1 车形 2 工服
int
HumanDetection
::
findHuManCar
(
const
cv
::
Mat
&
source
,
int
res
,
std
::
map
<
int
,
int
>&
reMap
,
QString
&
sSn
,
float
&
heightReference
,
std
::
vector
<
vides_data
::
ParkingArea
>
&
currentPlate
)
{
int
HumanDetection
::
findHuManCar
(
const
cv
::
Mat
&
source
,
int
res
,
std
::
map
<
int
,
int
>&
reMap
,
float
&
heightReference
,
std
::
vector
<
vides_data
::
ParkingArea
>
&
currentPlate
)
{
thread_time
.
store
(
QDateTime
::
currentMSecsSinceEpoch
(),
std
::
memory_order_release
);
TCV_CameraStream
*
stream
=
TCV_CreateCameraStream
();
...
...
@@ -100,7 +100,8 @@ int HumanDetection::findHuManCar(const cv::Mat &source, int res,std::map<int,int
if
(
res
==
0x00
||
res
==
0x02
)
{
num
=
TCV_HumanDetectorGetNumOfHuman
(
detector
);
qInfo
()
<<
QString
(
"SN(%1): 获取人形数量:%2"
).
arg
(
sSn
).
arg
(
num
);
qInfo
()
<<
"TCV_HumanDetectorGetNumOfHuman==>"
<<
num
;
if
(
num
==
0
)
return
num
;
// 无行人检测结果,提前返回
std
::
vector
<
TCV_ObjectLocation
>
results
(
num
);
TCV_HumanDetectorGetHumanLocation
(
detector
,
results
.
data
(),
num
);
...
...
@@ -132,6 +133,8 @@ int HumanDetection::findHuManCar(const cv::Mat &source, int res,std::map<int,int
}
reMap
[
0x02
]
=
count_no_uniform
;
// 未穿工服的行人数量
reMap
[
0x00
]
=
count_all
;
// 所有满足条件的行人数量
qInfo
()
<<
"count_all==>"
<<
count_all
;
qInfo
()
<<
"count_no_uniform==>"
<<
count_no_uniform
;
num
=
(
res
==
0x00
)
?
count_all
:
count_no_uniform
;
}
...
...
HumanDetection.h
View file @
84806c68
...
...
@@ -16,7 +16,7 @@ public:
float
carShapeConfidence
);
~
HumanDetection
();
int
findHuManCar
(
const
cv
::
Mat
&
source
,
int
res
,
std
::
map
<
int
,
int
>&
reMap
,
QString
&
sSn
,
int
findHuManCar
(
const
cv
::
Mat
&
source
,
int
res
,
std
::
map
<
int
,
int
>&
reMap
,
float
&
heightReference
,
std
::
vector
<
vides_data
::
ParkingArea
>
&
currentPlate
);
void
setHuManParameter
(
int
&
uniformColor
);
...
...
LicensePlateRecognition.cpp
View file @
84806c68
...
...
@@ -82,6 +82,7 @@ void LicensePlateRecognition::oldLicensePlateNumber(const cv::Mat &source,const
}
else
{
type
=
types
[
results
.
plates
[
i
].
type
];
}
qInfo
()
<<
QString
(
"车牌号:%1"
).
arg
(
results
.
plates
[
i
].
code
);
QString
plateResult
=
QString
(
"第%1个,%2,车牌号:%3,置信度:%4,左上角点x坐标:%5,左上角点y坐标:%6,右下角点x坐标:%7,右下角点y坐标:%8"
)
.
arg
(
i
+
1
).
arg
(
type
.
c_str
()).
arg
(
results
.
plates
[
i
].
code
)
.
arg
(
results
.
plates
[
i
].
text_confidence
).
arg
(
results
.
plates
[
i
].
x1
,
0
,
'Q'
,
4
)
...
...
@@ -167,6 +168,7 @@ void LicensePlateRecognition::licensePlateNumber(const cv::Mat &source, QString
newPlate
.
new_color
=
QString
::
fromStdString
(
type
);
QString
car_nuber
=
QString
::
fromUtf8
(
results
.
plates
[
i
].
code
);
replaceWith1And0
(
car_nuber
);
qInfo
()
<<
"I O (i o)大小写替换为 1 0结果:==>"
<<
car_nuber
;
newPlate
.
new_plate
=
car_nuber
;
newPlate
.
text_confidence
=
results
.
plates
[
i
].
text_confidence
;
vides_data
::
ParkingArea
area
;
...
...
LogHandle.h
View file @
84806c68
...
...
@@ -12,7 +12,7 @@
#include <QTextStream>
#include <QTextCodec>
const
int
g_logLimitSize
=
4
5
;
const
int
g_logLimitSize
=
5
;
struct
LogHandlerPrivate
{
LogHandlerPrivate
();
...
...
LogHandler.cpp
View file @
84806c68
...
...
@@ -25,13 +25,13 @@ LogHandlerPrivate::LogHandlerPrivate() {
openAndBackupLogFile
();
// 十分钟检查一次日志文件创建时间
renameLogFileTimer
.
setInterval
(
1000
*
60
*
10
);
// TODO: 可从配置文件读取
renameLogFileTimer
.
setInterval
(
1000
*
2
);
// TODO: 可从配置文件读取
renameLogFileTimer
.
start
();
QObject
::
connect
(
&
renameLogFileTimer
,
&
QTimer
::
timeout
,
[
this
]
{
QMutexLocker
locker
(
&
LogHandlerPrivate
::
logMutex
);
openAndBackupLogFile
();
// 打开日志文件
checkLogFiles
();
// 检测当前日志文件大小
// autoDeleteLog(); // 自动删除30天前的日志
// autoDeleteLog(); // 自动删除30天前的日志
});
// 定时刷新日志输出到文件,尽快的能在日志文件里看到最新的日志
...
...
@@ -91,17 +91,10 @@ void LogHandlerPrivate::openAndBackupLogFile() {
logFile
->
close
();
delete
logOut
;
delete
logFile
;
QDate
renameDate
=
logFileCreatedDate
;
if
(
logFileCreatedDate
==
QDate
::
currentDate
())
{
renameDate
=
QDate
::
currentDate
().
addDays
(
-
1
);
// 设置为昨天的日期
}
QString
newLogPath
=
logDir
.
absoluteFilePath
(
rename
Date
.
toString
(
"yyyy-MM-dd.log"
));
//
QFile::rename(logPath, newLogPath); // 将原始日志文件重命名为新的文件名
QString
newLogPath
=
logDir
.
absoluteFilePath
(
logFileCreated
Date
.
toString
(
"yyyy-MM-dd.log"
));
QFile
::
rename
(
logPath
,
newLogPath
);
// 将原始日志文件重命名为新的文件名
QFile
::
copy
(
logPath
,
newLogPath
);
QFile
::
remove
(
logPath
);
logFile
=
new
QFile
(
logPath
);
logOut
=
(
logFile
->
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
|
QIODevice
::
Append
))
?
new
QTextStream
(
logFile
)
:
nullptr
;
logFileCreatedDate
=
QDate
::
currentDate
();
...
...
@@ -112,8 +105,8 @@ void LogHandlerPrivate::openAndBackupLogFile() {
// 检测当前日志文件大小
void
LogHandlerPrivate
::
checkLogFiles
()
{
// 如果 protocal.log 文件大小超过5
5
M,重新创建一个日志文件,原文件存档为yyyy-MM-dd_hhmmss.log
if
(
logFile
->
size
()
>
1024
*
1024
*
g_logLimitSize
)
{
// 如果 protocal.log 文件大小超过5M,重新创建一个日志文件,原文件存档为yyyy-MM-dd_hhmmss.log
if
(
logFile
->
size
()
>
1024
*
g_logLimitSize
)
{
logFile
->
flush
();
logFile
->
close
();
delete
logOut
;
...
...
@@ -121,11 +114,7 @@ void LogHandlerPrivate::checkLogFiles() {
QString
logPath
=
logDir
.
absoluteFilePath
(
"today.log"
);
// 日志的路径
QString
newLogPath
=
logDir
.
absoluteFilePath
(
logFileCreatedDate
.
toString
(
"yyyy-MM-dd.log"
));
// QFile::rename(logPath, newLogPath);
QFile
::
copy
(
logPath
,
newLogPath
);
QFile
::
remove
(
logPath
);
QFile
::
rename
(
logPath
,
newLogPath
);
logFile
=
new
QFile
(
logPath
);
logOut
=
(
logFile
->
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
|
QIODevice
::
Append
))
?
new
QTextStream
(
logFile
)
:
NULL
;
logFileCreatedDate
=
QDate
::
currentDate
();
...
...
MediaFaceImage.cpp
View file @
84806c68
...
...
@@ -62,7 +62,7 @@ static int sdkInitCallback(XSDK_HANDLE hObject, int nMsgId, int nParam1,
auto
taskCallBack
=
std
::
bind
(
&
CameraHandle
::
callbackFunction
,
cameraHandle
,
hObject
,
qString
);
auto
taskRunnable
=
new
TaskRunnable
(
taskCallBack
,
hObject
,
cameraHandle
->
getChannel
(),
RunFunction
::
SdkCallbackFunction
);
threadPool
->
start
(
taskRunnable
);
}
}
break
;
...
...
@@ -92,8 +92,8 @@ int MediaFaceImage::SdkSearchDevicesSyn(std::map<QString, vides_data::localDevic
for
(
int
i
=
0
;
i
<
nActualCount
;
i
++
)
{
qInfo
()
<<
QString
(
"[%1][IP:%2.%3.%4.%5][SN:%6][Mac:%7]"
)
.
arg
(
i
)
.
arg
(
pRet
[
i
].
HostIP
.
c
[
0
])
.
arg
(
i
)
.
arg
(
pRet
[
i
].
HostIP
.
c
[
0
])
.
arg
(
pRet
[
i
].
HostIP
.
c
[
1
])
.
arg
(
pRet
[
i
].
HostIP
.
c
[
2
])
.
arg
(
pRet
[
i
].
HostIP
.
c
[
3
])
...
...
@@ -230,54 +230,54 @@ int MediaFaceImage::ToFile(const char* pFileName, const void* pData, int nLength
// return pInOutBufferSize; // pOutBuffer由智能指针管理,此处无需手动释放
//}
int
MediaFaceImage
::
FaceImageCallBack
(
XSDK_HANDLE
hMedia
,
int
nChannel
,
cv
::
Mat
&
image
,
QString
&
sSn
)
{
int
MediaFaceImage
::
FaceImageCallBack
(
XSDK_HANDLE
hMedia
,
int
nChannel
,
cv
::
Mat
&
image
)
{
const
int
BufferSize
=
1024
*
1024
*
2
;
// 缓冲区大小
image
.
release
();
// 释放之前的图像
std
::
unique_ptr
<
unsigned
char
[]
>
pOutBuffer
(
new
unsigned
char
[
BufferSize
]);
// 智能指针管理内存
int
pInOutBufferSize
=
0
;
int
ret
=
XSDK_DevSnapSyn
(
hMedia
,
nChannel
,
""
,
pOutBuffer
.
get
(),
&
pInOutBufferSize
);
if
(
ret
<
0
||
pInOutBufferSize
<=
0
)
{
qInfo
()
<<
QString
(
"SN(%1): 同步设备端抓图失败"
).
arg
(
sSn
);
;
qInfo
()
<<
"同步设备端抓图失败"
;
return
-
1
;
}
// 使用 std::vector 管理缓冲区数据
std
::
vector
<
uchar
>
buffer
(
pInOutBufferSize
);
memcpy
(
buffer
.
data
(),
pOutBuffer
.
get
(),
pInOutBufferSize
);
try
{
cv
::
Mat
decodedImage
=
cv
::
imdecode
(
buffer
,
cv
::
IMREAD_UNCHANGED
);
if
(
decodedImage
.
empty
())
{
qInfo
()
<<
QString
(
"SN(%1): 图像解码失败"
).
arg
(
sSn
);
;
qInfo
()
<<
"图像解码失败"
;
return
-
1
;
}
image
=
std
::
move
(
decodedImage
);
}
catch
(
const
cv
::
Exception
&
e
)
{
qInfo
()
<<
QString
(
"SN(%1): 图像解码过程中捕获异常:%2"
).
arg
(
sSn
).
arg
(
e
.
what
());
qInfo
()
<<
"图像解码过程中捕获异常:"
<<
e
.
what
();
return
-
1
;
}
return
pInOutBufferSize
;
}
int
MediaFaceImage
::
CameraImage
(
XSDK_HANDLE
hMedia
,
int
nChannel
,
std
::
vector
<
uchar
>
&
buffer
){
static
const
int
BufferSize
=
1024
*
1024
*
2
;
// 2MB buffer size
static
unsigned
char
pOutBuffer
[
BufferSize
];
// 初始化为0,用于接收实际填充的大小
int
pInOutBufferSize
=
0
;
// 尝试从设备获取快照数据
int
ret
=
XSDK_DevSnapSyn
(
hMedia
,
nChannel
,
""
,
pOutBuffer
,
&
pInOutBufferSize
);
if
(
ret
<
0
||
pInOutBufferSize
<=
0
)
{
qInfo
()
<<
"同步设备端抓图失败"
;
return
-
1
;
// 返回-1表示失败
}
// 用pOutBuffer里的数据初始化vector,复制数据到vector中
buffer
=
std
::
vector
<
uchar
>
(
pOutBuffer
,
pOutBuffer
+
pInOutBufferSize
);
// 返回实际填入Vector的数据大小
return
pInOutBufferSize
;
}
...
...
MediaFaceImage.h
View file @
84806c68
...
...
@@ -18,7 +18,7 @@ public:
static
MediaFaceImage
*
getInstance
();
// 单例模式获取实例的静态成员函数
void
ParserImageData
(
const
unsigned
char
*
pData
,
int
nDataLen
,
char
*
pJpg
,
int
*
nJpgLen
,
char
*
pJson
);
int
FaceImageCallBack
(
XSDK_HANDLE
hMedia
,
int
nChannel
,
cv
::
Mat
&
image
,
QString
&
sSn
);
int
FaceImageCallBack
(
XSDK_HANDLE
hMedia
,
int
nChannel
,
cv
::
Mat
&
image
);
int
CameraImage
(
XSDK_HANDLE
hMedia
,
int
nChannel
,
std
::
vector
<
uchar
>
&
buffer
);
int
ToFile
(
const
char
*
pFileName
,
const
void
*
pData
,
int
nLenght
);
...
...
MqttSubscriber.cpp
View file @
84806c68
...
...
@@ -24,29 +24,29 @@ void MqttSubscriber::init(vides_data::MqttConfig &config, QString &httpUrl, QStr
qInfo
()
<<
"客户端断开连接失败,返回编码"
<<
rc
;
}
}
// 销毁现有的MQTT客户端
MQTTAsync_destroy
(
&
client
);
client
=
nullptr
;
// 重置客户端指针
}
// 保存配置信息
this
->
config
=
config
;
this
->
httpUrl
=
httpUrl
;
this
->
serialNumber
=
serialNumber
;
// 初始化新的MQTT客户端
QByteArray
bAddress
=
config
.
address
.
toUtf8
();
char
*
cAddress
=
bAddress
.
data
();
QByteArray
bClientId
=
config
.
clientId
.
toUtf8
();
char
*
cClientId
=
bClientId
.
data
();
int
rc
=
MQTTAsync_create
(
&
client
,
cAddress
,
cClientId
,
MQTTCLIENT_PERSISTENCE_NONE
,
nullptr
);
if
(
rc
!=
MQTTASYNC_SUCCESS
)
{
qInfo
()
<<
"MQTT客户端创建失败,返回编码"
<<
rc
;
return
;
}
// 设置回调函数
MQTTAsync_setCallbacks
(
client
,
this
,
[](
void
*
context
,
char
*
cause
)
{
static_cast
<
MqttSubscriber
*>
(
context
)
->
connectionLost
(
cause
);
...
...
@@ -57,7 +57,7 @@ void MqttSubscriber::init(vides_data::MqttConfig &config, QString &httpUrl, QStr
MqttSubscriber
::
MqttSubscriber
(
QObject
*
parent
)
:
QObject
(
parent
),
retryTimer
(
new
QTimer
(
this
)),
client
(
nullptr
)
{
// 连接信号和槽
connect
(
this
,
&
MqttSubscriber
::
connectionLostSignal
,
this
,
&
MqttSubscriber
::
reconnectAndFetchConfig
,
Qt
::
QueuedConnection
);
retryTimer
->
setInterval
(
10000
);
// 设置重试间隔为10秒
...
...
@@ -76,18 +76,18 @@ MqttSubscriber::~MqttSubscriber() {
void
MqttSubscriber
::
start
()
{
// 确保定时器停止
retryTimer
->
stop
();
// 设置连接选项
MQTTAsync_connectOptions
conn_opts
=
MQTTAsync_connectOptions_initializer
;
conn_opts
.
keepAliveInterval
=
20
;
conn_opts
.
cleansession
=
1
;
QByteArray
bUsername
=
config
.
username
.
toUtf8
();
char
*
cUsername
=
bUsername
.
data
();
QByteArray
bPassword
=
config
.
password
.
toUtf8
();
char
*
cPassword
=
bPassword
.
data
();
conn_opts
.
username
=
cUsername
;
conn_opts
.
password
=
cPassword
;
conn_opts
.
onSuccess
=
[](
void
*
context
,
MQTTAsync_successData
*
response
)
{
...
...
@@ -97,7 +97,7 @@ void MqttSubscriber::start() {
static_cast
<
MqttSubscriber
*>
(
context
)
->
onConnectFailure
(
response
);
};
conn_opts
.
context
=
this
;
// 启动连接
int
rc
;
if
((
rc
=
MQTTAsync_connect
(
client
,
&
conn_opts
))
!=
MQTTASYNC_SUCCESS
)
{
...
...
@@ -116,7 +116,7 @@ void MqttSubscriber::onConnect(MQTTAsync_successData* response) {
static_cast
<
MqttSubscriber
*>
(
context
)
->
onSubscribeFailure
(
response
);
};
opts
.
context
=
this
;
QByteArray
bTopic
=
config
.
topic
.
toUtf8
();
char
*
cTopic
=
bTopic
.
data
();
int
rc
;
...
...
@@ -129,7 +129,7 @@ void MqttSubscriber::reconnectAndFetchConfig() {
qInfo
()
<<
"重新连接并获取配置"
;
Common
&
instace
=
Common
::
getInstance
();
vides_data
::
responseConfig
re_config
;
// 使用 HttpService 从远程云端拉取配置
HttpService
httpService
(
httpUrl
);
// 替换为实际的远程URL
vides_data
::
response
*
res
=
httpService
.
httpDeviceConfig
(
serialNumber
,
re_config
);
...
...
@@ -174,7 +174,7 @@ void MqttSubscriber::connectionLost(char* cause) {
int
MqttSubscriber
::
messageArrived
(
char
*
topicName
,
int
topicLen
,
MQTTAsync_message
*
m
)
{
QString
topic
(
topicName
);
QString
payload
=
QString
::
fromUtf8
(
reinterpret_cast
<
const
char
*>
(
m
->
payload
),
m
->
payloadlen
);
QJsonObject
msgBodyOb
;
vides_data
::
responseMqttData
response
;
QJsonDocument
jsonDoc
=
QJsonDocument
::
fromJson
(
payload
.
toUtf8
());
if
(
!
jsonDoc
.
isNull
()
&&
jsonDoc
.
isObject
())
{
...
...
@@ -182,21 +182,10 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
response
.
msg_type
=
jsonObj
[
"msg_type"
].
toInt
();
response
.
sn
=
jsonObj
[
"sn"
].
toString
();
response
.
uniq
=
jsonObj
[
"uniq"
].
toString
();
// 解析 msg_body 字段
if
(
jsonObj
.
contains
(
"msg_body"
))
{
QString
msgBodyStr
=
jsonObj
[
"msg_body"
].
toString
();
// 将 msg_body 字符串转换为 QJsonDocument
QJsonDocument
msgBodyDoc
=
QJsonDocument
::
fromJson
(
msgBodyStr
.
toUtf8
());
if
(
!
msgBodyDoc
.
isNull
()
&&
msgBodyDoc
.
isObject
())
{
msgBodyOb
=
msgBodyDoc
.
object
();
}
else
{
qInfo
()
<<
"Failed to parse msg_body as a JSON object."
;
}
}
}
else
{
qInfo
()
<<
"Failed to parse JSON payload"
;
}
//1开 2关 3 重启 4 GB28181开 5 GB28181 关 6 一键配网 7 WIFI配留 8 复位GB28181
int
res
=
-
2
;
CameraHandle
*
cameraHandle
=
MainWindow
::
sp_this
->
findHandle
(
response
.
sn
);
if
(
cameraHandle
==
nullptr
)
{
...
...
@@ -211,64 +200,38 @@ int MqttSubscriber::messageArrived(char* topicName, int topicLen, MQTTAsync_mess
res
=
cameraHandle
->
updateSdkDevStatus
(
true
);
}
else
if
(
response
.
msg_type
==
5
)
{
res
=
cameraHandle
->
updateSdkDevStatus
(
false
);
}
else
if
(
response
.
msg_type
==
6
)
{
QString
ipAddress
;
// 提取 ip 地址
if
(
msgBodyOb
.
contains
(
"ip"
)
&&
msgBodyOb
[
"ip"
].
isString
())
{
ipAddress
=
msgBodyOb
[
"ip"
].
toString
();
qInfo
()
<<
"IP Address: "
<<
ipAddress
;
}
else
{
qInfo
()
<<
"IP address not found in msg_body."
;
}
res
=
cameraHandle
->
distributionNetwork
(
ipAddress
);
}
else
if
(
response
.
msg_type
==
7
)
{
// 提取 ip 地址
if
(
msgBodyOb
.
contains
(
"username"
)
&&
msgBodyOb
.
contains
(
"password"
))
{
QString
username
=
msgBodyOb
[
"username"
].
toString
();
QString
password
=
msgBodyOb
[
"password"
].
toString
();
res
=
(
cameraHandle
->
sdkWifi
(
password
,
username
)
==
true
?
0
:
0x01
);
}
else
{
qInfo
()
<<
"IP username not found in msg_body."
;
qInfo
()
<<
"IP password not found in msg_body."
;
}
}
else
if
(
response
.
msg_type
==
8
)
{
res
=
(
cameraHandle
->
resetGb28181
()
==
true
?
0
:
0x01
);
}
}
vides_data
::
requestMqttData
request
;
request
.
code
=
(
res
>=
0
)
?
0
:
0x01
;
request
.
msg
=
(
res
>=
0
)
?
"成功"
:
"失败"
;
request
.
uniq
=
response
.
uniq
;
sendSubscriptionConfirmation
(
request
,
response
.
sn
);
request
.
uniq
=
response
.
uniq
;
request
.
sn
=
response
.
sn
;
sendSubscriptionConfirmation
(
request
);
MQTTAsync_freeMessage
(
&
m
);
MQTTAsync_free
(
topicName
);
return
1
;
}
void
MqttSubscriber
::
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
,
QString
&
sn
)
{
QString
responseTopic
=
"/thingshub/"
+
response
.
uniq
+
"/device/post"
;
void
MqttSubscriber
::
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
)
{
QString
responseTopic
=
"/thingshub/"
+
response
.
sn
+
"/device/post"
;
QByteArray
bResponseTopic
=
responseTopic
.
toUtf8
();
char
*
cResponseTopic
=
bResponseTopic
.
data
();
qInfo
()
<<
QString
(
"SN(%1): sendSubscriptionConfirmation->cResponseTopic%2"
).
arg
(
sn
).
arg
(
cResponseTopic
);
// response.sn
qInfo
()
<<
"sendSubscriptionConfirmation"
<<
cResponseTopic
;
QJsonObject
json
;
json
[
"code"
]
=
response
.
code
;
json
[
"msg"
]
=
response
.
msg
;
json
[
"uniq"
]
=
response
.
uniq
;
QJsonDocument
jsonDoc
(
json
);
QByteArray
payload
=
jsonDoc
.
toJson
(
QJsonDocument
::
Compact
);
MQTTAsync_message
pubmsg
=
MQTTAsync_message_initializer
;
pubmsg
.
payload
=
const_cast
<
char
*>
(
payload
.
data
());
pubmsg
.
payloadlen
=
payload
.
size
();
pubmsg
.
qos
=
config
.
qos
;
pubmsg
.
retained
=
0
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
opts
.
onSuccess
=
[](
void
*
context
,
MQTTAsync_successData
*
response
)
{
static_cast
<
MqttSubscriber
*>
(
context
)
->
onPublishSuccess
(
response
);
...
...
@@ -277,7 +240,7 @@ void MqttSubscriber::sendSubscriptionConfirmation(const vides_data::requestMqttD
static_cast
<
MqttSubscriber
*>
(
context
)
->
onPublishFailure
(
response
);
};
opts
.
context
=
this
;
int
rc
;
if
((
rc
=
MQTTAsync_sendMessage
(
client
,
cResponseTopic
,
&
pubmsg
,
&
opts
))
!=
MQTTASYNC_SUCCESS
)
{
qInfo
()
<<
"发送消息失败,返回编码"
<<
rc
;
...
...
MqttSubscriber.h
View file @
84806c68
...
...
@@ -45,7 +45,7 @@ private:
void
onPublishSuccess
(
MQTTAsync_successData
*
response
);
void
onPublishFailure
(
MQTTAsync_failureData
*
response
);
void
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
,
QString
&
sn
);
void
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
);
static
MqttSubscriber
*
instance
;
};
...
...
ParkingSpaceInfo.cpp
View file @
84806c68
...
...
@@ -10,6 +10,7 @@ ParkingSpaceInfo::ParkingSpaceInfo(){
}
ParkingSpaceInfo
::~
ParkingSpaceInfo
(){
qInfo
()
<<
"ParkingSpaceInfo:关闭"
;
}
void
ParkingSpaceInfo
::
addQueue
(
RecognizedInfo
&
info
){
QMutexLocker
locker
(
&
queueMutex
);
...
...
VidesData.h
View file @
84806c68
...
...
@@ -48,6 +48,8 @@ struct requestDeviceStatus
std
::
list
<
requestCameraInfo
>
camera_info_list
;
requestDeviceStatus
()
{}
};
struct
responseStsCredentials
{
QString
access_key_id
;
QString
access_key_secret
;
...
...
@@ -107,8 +109,6 @@ struct localDeviceStatus
QString
password
;
localDeviceStatus
()
{}
};
struct
requestFaceReconition
{
QString
id
;
...
...
@@ -250,6 +250,7 @@ struct Camera {
struct
FaceConfig
{
bool
isOn
;
int
faceNumbers
;
uint64
faceFrequency
;
float
confidence
;
int
faceLen
;
quint64
updateAt
;
...
...
@@ -260,7 +261,7 @@ struct LicensePlateConfig {
float
carConfidenceMax
;
float
carConfidenceMin
;
int
licensePlateLen
;
quint64
updateAt
;
quint64
updateAt
;
int
maxNum
;
///< 识别最大数量
bool
useHalf
;
///< 是否使用半精度推理模式
float
boxConfThreshold
;
///< 检测框阈值
...
...
@@ -280,7 +281,7 @@ struct UniformConfig {
};
struct
HumanConfig
{
bool
isOn
;
uint64
faceFrequency
;
int
humanDetectionLen
;
quint64
updateAt
;
};
...
...
@@ -312,12 +313,11 @@ struct responseMqttData{
uint8_t
msg_type
;
QString
sn
;
QString
uniq
;
QString
msg_body
;
};
struct
requestMqttData
{
QString
msg
;
int
code
;
QString
sn
;
int
code
;
QString
uniq
;
};
struct
DetectionParams
{
...
...
@@ -400,48 +400,16 @@ inline QString getDefaultGateway() {
return
gateway
;
}
inline
void
convertQStringToSXSDK_IPAddress
(
const
QString
&
ipString
,
SXSDK_IPAddress
&
hostIP
)
{
QHostAddress
address
(
ipString
);
quint32
ip
=
address
.
toIPv4Address
();
hostIP
.
c
[
0
]
=
(
ip
>>
24
)
&
0xFF
;
hostIP
.
c
[
1
]
=
(
ip
>>
16
)
&
0xFF
;
hostIP
.
c
[
2
]
=
(
ip
>>
8
)
&
0xFF
;
hostIP
.
c
[
3
]
=
ip
&
0xFF
;
}
// 获取本地 MAC 地址、子网掩码和网关IP
inline
bool
GetNetworkInfoByQNetworkInterface
(
QString
&
mac
,
QString
&
subnetMask
,
QString
&
gateway
)
{
QList
<
QNetworkInterface
>
interfaces
=
QNetworkInterface
::
allInterfaces
();
foreach
(
QNetworkInterface
interface
,
interfaces
)
{
if
(
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsUp
)
&&
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsRunning
)
&&
!
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsLoopBack
))
{
mac
=
interface
.
hardwareAddress
();
QList
<
QNetworkAddressEntry
>
addressEntries
=
interface
.
addressEntries
();
foreach
(
QNetworkAddressEntry
entry
,
addressEntries
)
{
if
(
entry
.
ip
().
protocol
()
==
QAbstractSocket
::
IPv4Protocol
)
{
subnetMask
=
entry
.
netmask
().
toString
();
gateway
=
entry
.
broadcast
().
toString
();
// 这里假设网关是广播地址
return
true
;
}
}
}
}
return
false
;
// Return false if no suitable interface is found
}
inline
bool
pingAddress
(
const
QString
&
address
)
{
QProcess
process
;
QString
program
=
"ping"
;
QStringList
arguments
;
#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
arguments
<<
"-n"
<<
"1"
<<
address
;
#else
#else
arguments
<<
"-c"
<<
"1"
<<
address
;
#endif
#endif
process
.
start
(
program
,
arguments
);
if
(
!
process
.
waitForStarted
())
{
...
...
@@ -457,28 +425,11 @@ inline bool pingAddress(const QString &address) {
QString
output
(
process
.
readAllStandardOutput
());
// 简单的 Ping 成功检查逻辑
#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
return
output
.
contains
(
"TTL="
);
#else
#else
return
output
.
contains
(
"1 packets transmitted, 1 received"
);
#endif
}
inline
QString
findReachableIp
()
{
QList
<
QHostAddress
>
ipAddressesList
=
QNetworkInterface
::
allAddresses
();
for
(
const
QHostAddress
&
address
:
ipAddressesList
)
{
if
(
address
.
protocol
()
==
QAbstractSocket
::
IPv4Protocol
&&
!
address
.
isLoopback
())
{
QString
ipAddress
=
address
.
toString
();
QString
currentSubnet
=
ipAddress
.
left
(
ipAddress
.
lastIndexOf
(
'.'
)
+
1
);
// 返回子网部分
for
(
int
i
=
254
;
i
>=
1
;
--
i
)
{
// 从 254 开始递减
QString
ip
=
currentSubnet
+
QString
::
number
(
i
);
if
(
!
pingAddress
(
ip
))
{
return
ip
;
}
}
}
}
return
QString
();
// 如果没有找到可用的 IP 地址,则返回空字符串
#endif
}
inline
int
GetCpuIdByAsm_arm
(
char
*
cpu_id
)
...
...
gamera_videos.pro
View file @
84806c68
...
...
@@ -13,8 +13,6 @@ TEMPLATE = app
# deprecated API in order to know how to port your code away from it.
DEFINES
+=
QT_DEPRECATED_WARNINGS
DEFINES
+=
APP_VERSION
=
\\\
"1.3.2\\\"
DEFINES
+=
QT_MESSAGELOGCONTEXT
DEFINES
+=
QT_NO_DEBUG_OUTPUT
QMAKE_LIBDIR
+=
/
usr
/
local
/
lib
...
...
@@ -26,9 +24,6 @@ INCLUDEPATH+=/usr/local/include/human
INCLUDEPATH
+=/
usr
/
local
/
include
/
CImg
INCLUDEPATH
+=/
usr
/
local
/
include
/
mqtt
# 禁用所有警告
QMAKE_CXXFLAGS
+=
-
w
...
...
mainwindow.cpp
View file @
84806c68
This diff is collapsed.
Click to expand it.
mainwindow.h
View file @
84806c68
...
...
@@ -33,7 +33,7 @@ public:
explicit
MainWindow
();
void
initCommon
();
void
setVideoPath
(
int
flag
,
const
QString
&
path
);
void
createDirectory
(
int
flag
,
const
QString
&
dirName
,
const
QString
&
successMsg
,
const
QString
&
failureMsg
);
...
...
@@ -43,17 +43,15 @@ public:
void
initFaceFaceRecognition
();
void
initCameras
(
vides_data
::
cameraParameters
&
parameter
,
vides_data
::
responseConfig
&
devConfig
,
const
std
::
list
<
vides_data
::
responseArea
>&
areas
,
std
::
list
<
vides_data
::
requestCameraInfo
>&
camera_info_list
);
__uint8_t
intToUint8t
(
bool
faceAlgorithm
,
bool
licensePlateAlgorithm
,
bool
uniformAlgorithm
,
bool
humanAlgorithm
);
//盒子参数更新
void
divParameterUpdate
(
vides_data
::
responseConfig
&
cloudConfig
,
QString
&
httpUrl
,
QString
&
serialNumber
);
//盒子参数更新
void
divParameterUpdate
(
vides_data
::
responseConfig
&
cloudConfig
,
QString
&
httpUrl
,
QString
&
serialNumber
);
static
MainWindow
*
sp_this
;
CameraHandle
*
findHandle
(
QString
sn
);
void
modifySnMapIp
(
QString
&
sn
,
QString
&
ip
);
void
findSnMapIp
(
QString
&
sn
,
QString
&
ip
);
void
sendJsonResponse
(
QTcpSocket
*
socket
,
int
code
,
const
QString
&
data
,
const
QString
&
msg
);
void
sendEmptyResponse
(
QTcpSocket
*
socket
);
...
...
@@ -83,10 +81,8 @@ public:
// 过滤函数
void
deleteCloudNotCamer
(
const
std
::
map
<
QString
,
vides_data
::
localDeviceStatus
*>&
localDevices
,
const
std
::
list
<
vides_data
::
responseDeviceStatus
>&
devices
);
void
setIsResetting
(
bool
running
);
~
MainWindow
();
signals
:
void
shutdownSignals
(
QString
sDevId
,
int
nDevPort
);
...
...
@@ -105,7 +101,7 @@ private:
QSettings
*
qSetting
;
QTimer
*
deleteLogFileTimer
;
QTimer
*
dePermissionSynTimer
;
QTcpServer
server
;
...
...
@@ -122,10 +118,9 @@ private:
std
::
map
<
QString
,
CameraHandle
*>
faceDetectionParkingPushs
;
vides_data
::
responseConfig
config
;
vides_data
::
MqttConfig
mqttConfig
;
vides_data
::
MqttConfig
mqttConfig
;
std
::
atomic
<
bool
>
isResetting
;
};
#endif // MAINWINDOW_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment