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
eb6e5838
Commit
eb6e5838
authored
Oct 09, 2024
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
复位gb28181和配置WIFI
parent
8f978a25
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
621 additions
and
140 deletions
+621
-140
CameraHandle.cpp
+370
-50
CameraHandle.h
+20
-4
Common.cpp
+6
-4
Common.h
+3
-1
MqttSubscriber.cpp
+65
-28
MqttSubscriber.h
+1
-1
VidesData.h
+61
-11
mainwindow.cpp
+80
-31
mainwindow.h
+15
-10
No files found.
CameraHandle.cpp
View file @
eb6e5838
...
...
@@ -281,18 +281,19 @@ void CameraHandle::initFaceFrequency(uint64 face_frequency){
this
->
face_frequency
=
face_frequency
;
}
void
CameraHandle
::
initSdkRealTimeDevSnapSyn
(
int
hDevice
,
int
syn_timer
,
uint64
face_frequency
)
{
connect
(
dev_snap_syn_timer
,
&
QTimer
::
timeout
,
this
,
[
this
,
hDevice
]()
{
this
->
sdkRealTimeDevSnapSyn
(
hDevice
);
void
CameraHandle
::
initSdkRealTimeDevSnapSyn
(
int
syn_timer
,
uint64
face_frequency
)
{
connect
(
dev_snap_syn_timer
,
&
QTimer
::
timeout
,
this
,
[
this
]()
{
this
->
sdkRealTimeDevSnapSyn
();
},
Qt
::
QueuedConnection
);
this
->
face_frequency
=
face_frequency
;
dev_snap_syn_timer
->
start
(
syn_timer
);
}
void
CameraHandle
::
sdkRealTimeDevSnapSyn
(
int
hDevice
)
{
void
CameraHandle
::
sdkRealTimeDevSnapSyn
()
{
QThreadPool
*
threadPool
=
QThreadPool
::
globalInstance
();
auto
taskSyn
=
[
this
,
hDevice
]()
{
sdkDevSnapSyn
(
hDevice
,
this
->
channel
);
auto
taskSyn
=
[
this
]()
{
sdkDevSnapSyn
(
this
->
hDevice
,
this
->
channel
);
};
if
(
threadPool
->
activeThreadCount
()
>=
threadPool
->
maxThreadCount
())
{
...
...
@@ -368,7 +369,7 @@ void CameraHandle::sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id,
}
int
CameraHandle
::
callbackFunction
(
XSDK_HANDLE
hObject
,
QString
&
szString
)
{
if
(
!
semaphore
.
tryAcquire
())
{
if
(
!
semaphore
.
tryAcquire
())
{
qInfo
()
<<
QString
(
"SN(%1): sdkDevSnapSyn:正在执行线程"
).
arg
(
sSn
);
return
-
1
;
}
...
...
@@ -411,6 +412,47 @@ int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
updateImage
(
image
,
currentTime
);
}
/**
增加一键配网mqtt命令
对应设备连接局域网得情况下可通过盒子配置IP,实现快捷配网。
消息输入IP时配置为对应IP,不输入时则自动配置相同局域网网段ip
* @brief CameraHandle::distributionNetwork
*/
bool
CameraHandle
::
distributionNetwork
(
QString
&
ip
){
qInfo
()
<<
QString
(
"SN(%1): 一键配网的IP地址%2"
).
arg
(
sSn
).
arg
(
ip
);
int
old
=
hDevice
;
MainWindow
::
sp_this
->
setIsResetting
(
true
);
ScopeSemaphoreExit
guard
([]()
{
MainWindow
::
sp_this
->
setIsResetting
(
false
);
});
QString
reachableIp
;
MainWindow
::
sp_this
->
modifySnMapIp
(
sSn
,
url
);
if
(
ip
.
length
()
>
0
){
reachableIp
=
ip
;
qInfo
()
<<
QString
(
"SN(%1): reachableIpIP地址%2"
).
arg
(
sSn
).
arg
(
ip
);
qInfo
()
<<
QString
(
"SN(%1): IP地址%2"
).
arg
(
sSn
).
arg
(
reachableIp
);
}
else
{
reachableIp
=
vides_data
::
findReachableIp
();
if
(
!
reachableIp
.
isEmpty
())
{
qInfo
()
<<
QString
(
"SN(%1): 未使用的IP地址%2"
).
arg
(
sSn
).
arg
(
reachableIp
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 找不到可使用的IP地址"
).
arg
(
sSn
);
return
false
;
}
}
bool
result
=
changeCameraIp
(
reachableIp
);
if
(
!
result
){
qInfo
()
<<
QString
(
"newIP(%1): wifiChangeIp"
).
arg
(
reachableIp
);
result
=
wifiChangeIp
(
reachableIp
,
false
,
old
);
}
return
result
;
}
void
CameraHandle
::
sdkDevSnapSyn
(
XSDK_HANDLE
hDevice
,
int
nChannel
){
if
(
hDevice
<=
0
){
...
...
@@ -482,7 +524,7 @@ void CameraHandle::checkAndUpdateCurrentPlate(ParkingSpaceInfo*park,const cv::Ma
}
}
qInfo
()
<<
QString
(
"SN(%1): 最新车牌%2,当前区域车牌:%3"
).
arg
(
sSn
).
arg
(
newInfo
.
getLicensePlate
()).
arg
(
park
->
getCurrentPlate
().
getLicensePlate
());
qInfo
()
<<
QString
(
"SN(%1): 最新车牌%2,当前区域车牌:%3"
).
arg
(
sSn
).
arg
(
newInfo
.
getLicensePlate
()).
arg
(
park
->
getCurrentPlate
().
getLicensePlate
());
qInfo
()
<<
QString
(
"SN(%1): 区域:%2,数量:%3"
).
arg
(
sSn
).
arg
(
park
->
getSpaceIndex
()).
arg
(
count
);
if
(
count
>=
3
)
{
...
...
@@ -502,14 +544,14 @@ void CameraHandle::checkAndUpdateCurrentPlate(ParkingSpaceInfo*park,const cv::Ma
qInfo
()
<<
QString
(
"SN(%1): 当前车形数量:%2"
).
arg
(
sSn
).
arg
(
car_size
);
if
(
car_size
<=
0
&&
car_size
!=-
2
)
{
qInfo
()
<<
QString
(
"SN(%1): 区域:%2出场"
).
arg
(
sSn
).
arg
(
park
->
getSpaceIndex
());
qInfo
()
<<
QString
(
"SN(%1): 区域:%2出场"
).
arg
(
sSn
).
arg
(
park
->
getSpaceIndex
());
//如果有车辆检测到并且不在停车区域内部,视为出场
park
->
setCurrentPlate
(
newInfo
);
result
=
Exit
;
}
else
{
// 没有车辆或车辆在停车区域内部,移除队列
park
->
removeNoQueue
();
qDebug
()
<<
QString
(
"SN(%1): no出场::%2"
).
arg
(
sSn
).
arg
(
car_size
);
qDebug
()
<<
QString
(
"SN(%1): no出场::%2"
).
arg
(
sSn
).
arg
(
car_size
);
}
}
else
{
//当前不为空,新车,新车入场,老车出场
...
...
@@ -602,7 +644,7 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
std
::
vector
<
vides_data
::
ParkingArea
>
currentPlates
;
int
uniforms
=
0x00
;
std
::
map
<
int
,
int
>
resMap
;
qInfo
()
<<
QString
(
"SN(%1): 相机算法:%2"
).
arg
(
sSn
).
arg
(
algorithmPermissions
);
qInfo
()
<<
QString
(
"SN(%1): 相机算法:%2"
).
arg
(
sSn
).
arg
(
algorithmPermissions
);
if
((
algorithmPermissions
&
0x01
<<
3
)
!=
0
)
{
//穿工服算法
if
((
algorithmPermissions
&
0x01
<<
2
)
!=
0
)
{
...
...
@@ -620,11 +662,15 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
}
}
if
(
uniforms
==-
2
||
faSize
==-
2
){
qInfo
()
<<
QString
(
"SN(%1): 没有可用的HumanDetection对象可以调度"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 没有可用的HumanDetection对象可以调度"
).
arg
(
sSn
);
return
;
}
QPoint
point_info
(
faSize
,
uniforms
);
if
(
isChanged
(
point_info
,
faceMapWorker
)){
qInfo
()
<<
QString
(
"SN(%1): 人形计算器:%2"
).
arg
(
sSn
).
arg
(
faceCount
);
qInfo
()
<<
QString
(
"SN(%1): 人形频率:%2"
).
arg
(
sSn
).
arg
(
face_frequency
);
if
(
faceCount
.
load
(
std
::
memory_order_relaxed
)
%
face_frequency
==
0
){
int
worker
=
0x00
;
if
((
algorithmPermissions
&
0x01
<<
2
)
!=
0
)
{
...
...
@@ -638,17 +684,17 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
httpService
.
setHttpUrl
(
httpUrl
);
vides_data
::
response
*
img_resp
=
httpService
.
httpPostFacePopulation
(
num_imgs
,
faSize
,
worker
,
sSn
,
currentTime
);
if
(
img_resp
->
code
!=
0
)
{
qInfo
()
<<
QString
(
"SN(%1):不加图片人数变化推送信息推送失败,失败信息%2"
).
arg
(
sSn
).
arg
(
img_resp
->
msg
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 不加图片人数变化推送信息推送成功"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1):不加图片人数变化推送信息推送失败,失败信息%2"
).
arg
(
sSn
).
arg
(
img_resp
->
msg
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 不加图片人数变化推送信息推送成功"
).
arg
(
sSn
);
}
instace
.
deleteObj
(
img_resp
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 人数变化推送失败,失败信息%2"
).
arg
(
sSn
).
arg
(
resp
->
msg
);
qInfo
()
<<
QString
(
"SN(%1): 人数变化推送失败,失败信息%2"
).
arg
(
sSn
).
arg
(
resp
->
msg
);
}
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 人数变化推送成功"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 人数变化推送成功"
).
arg
(
sSn
);
}
instace
.
deleteObj
(
resp
);
...
...
@@ -685,17 +731,17 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
faceReconition
.
img
.
clear
();
httpService
.
setHttpUrl
(
httpUrl
);
vides_data
::
response
*
img_resp
=
httpService
.
httpPostFaceReconition
(
faceReconition
);
if
(
img_resp
->
code
!=
0
)
{
qInfo
()
<<
QString
(
"SN(%1): 不加图片人脸信息推送失败,失败信息%2,人脸id%3"
).
arg
(
sSn
).
arg
(
resp
->
msg
).
arg
(
face
.
id
);
if
(
img_resp
->
code
!=
0
)
{
qInfo
()
<<
QString
(
"SN(%1): 不加图片人脸信息推送失败,失败信息%2,人脸id%3"
).
arg
(
sSn
).
arg
(
resp
->
msg
).
arg
(
face
.
id
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 不加图片人脸信息推送成功"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 不加图片人脸信息推送成功"
).
arg
(
sSn
);
}
instace
.
deleteObj
(
img_resp
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 人脸信息推送失败,失败信息%2"
).
arg
(
sSn
).
arg
(
resp
->
msg
);
qInfo
()
<<
QString
(
"SN(%1): 人脸信息推送失败,失败信息%2"
).
arg
(
sSn
).
arg
(
resp
->
msg
);
}
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 人脸信息推送成功"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 人脸信息推送成功"
).
arg
(
sSn
);
}
instace
.
deleteObj
(
resp
);
}
...
...
@@ -716,23 +762,20 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
httpService
.
setHttpUrl
(
httpUrl
);
vides_data
::
response
*
img_resp
=
httpService
.
httpPostUniforms
(
num_imgs
,
strUniform
,
sSn
,
currentTime
);
if
(
img_resp
->
code
!=
0
)
{
qInfo
()
<<
QString
(
"SN(%1): 不加图片推送未穿工服人数失败,失败信息%2"
).
arg
(
sSn
).
arg
(
img_resp
->
msg
);
qInfo
()
<<
QString
(
"SN(%1): 不加图片推送未穿工服人数失败,失败信息%2"
).
arg
(
sSn
).
arg
(
img_resp
->
msg
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 不加图片推送未穿工服人数成功"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 不加图片推送未穿工服人数成功"
).
arg
(
sSn
);
}
instace
.
deleteObj
(
img_resp
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 推送未穿工服人数失败,失败信息%2"
).
arg
(
sSn
).
arg
(
resp
->
msg
);
qInfo
()
<<
QString
(
"SN(%1): 推送未穿工服人数失败,失败信息%2"
).
arg
(
sSn
).
arg
(
resp
->
msg
);
}
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 推送未穿工服人数成功"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 推送未穿工服人数成功"
).
arg
(
sSn
);
}
instace
.
deleteObj
(
resp
);
}
}
}
}
else
{
qDebug
()
<<
sSn
<<
":人形识别算法关闭,只有车牌算法了"
;
...
...
@@ -774,8 +817,6 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
}
}
vides_data
::
requestLicensePlate
newPlate
;
newPlate
.
sn
=
sSn
;
...
...
@@ -801,7 +842,7 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
if
(
parkAreaMap
!=
parkMap
.
end
())
{
value
=
parkAreaMap
->
second
;
// 成功找到,获取
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 区域%2不存在"
).
arg
(
sSn
).
arg
(
key
);
qInfo
()
<<
QString
(
"SN(%1): 区域%2不存在"
).
arg
(
sSn
).
arg
(
key
);
continue
;
}
vides_data
::
requestLicensePlate
resultPlate
;
...
...
@@ -845,13 +886,13 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
RecognizedInfo
recognizedInfo
;
if
(
maxPlate
.
new_color
==
"蓝牌"
&&
maxPlate
.
new_plate
.
length
()
!=
7
)
{
qDebug
()
<<
QString
(
"SN(%1): 蓝牌车牌号%2,recognition.new_plate.length()=%3"
).
arg
(
sSn
).
arg
(
maxPlate
.
new_plate
).
arg
(
maxPlate
.
new_plate
.
length
());
qDebug
()
<<
QString
(
"SN(%1): 蓝牌车牌号%2,recognition.new_plate.length()=%3"
).
arg
(
sSn
).
arg
(
maxPlate
.
new_plate
).
arg
(
maxPlate
.
new_plate
.
length
());
continue
;
}
else
if
(
maxPlate
.
new_color
==
"绿牌新能源"
&&
maxPlate
.
new_plate
.
length
()
!=
8
)
{
qDebug
()
<<
QString
(
"SN(%1): 绿牌车牌号%2,recognition.new_plate.length()=%3"
).
arg
(
sSn
).
arg
(
maxPlate
.
new_plate
).
arg
(
maxPlate
.
new_plate
.
length
());
qDebug
()
<<
QString
(
"SN(%1): 绿牌车牌号%2,recognition.new_plate.length()=%3"
).
arg
(
sSn
).
arg
(
maxPlate
.
new_plate
).
arg
(
maxPlate
.
new_plate
.
length
());
continue
;
}
else
if
(
maxPlate
.
new_plate
.
length
()
<
7
)
{
qDebug
()
<<
QString
(
"SN(%1): 非绿牌蓝牌车牌号%2,recognition.new_plate.length()=%3"
).
arg
(
sSn
).
arg
(
maxPlate
.
new_plate
).
arg
(
maxPlate
.
new_plate
.
length
());
qDebug
()
<<
QString
(
"SN(%1): 非绿牌蓝牌车牌号%2,recognition.new_plate.length()=%3"
).
arg
(
sSn
).
arg
(
maxPlate
.
new_plate
).
arg
(
maxPlate
.
new_plate
.
length
());
continue
;
}
if
(
maxPlate
.
text_confidence
>=
carConfidenceMax
){
...
...
@@ -868,8 +909,8 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
this
->
checkAndUpdateCurrentPlate
(
value
,
areaMat
,
recognizedInfo
,
res
);
}
if
(
maxPlate
.
text_confidence
<=
carConfidenceMin
){
qDebug
()
<<
QString
(
"SN(%1): recognition.text_confidence<=instace.getCarConfidenceMin:%2"
).
arg
(
sSn
).
arg
(
carConfidenceMin
);
qDebug
()
<<
QString
(
"SN(%1): recognition.text_confidence<=instace.getCarConfidenceMin:%2"
).
arg
(
sSn
).
arg
(
carConfidenceMin
);
continue
;
}
if
(
maxPlate
.
text_confidence
>
carConfidenceMin
...
...
@@ -962,17 +1003,35 @@ void CameraHandle::licensePlateRecognitionResults(vides_data::requestLicensePlat
if
(
img_resp
->
code
!=
0
)
{
qInfo
()
<<
QString
(
"SN(%1): 车牌不加图片上传失败:失败信息%2"
).
arg
(
sSn
).
arg
(
img_resp
->
msg
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 车牌不加图片上传成功"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 车牌不加图片上传成功"
).
arg
(
sSn
);
}
instace
.
deleteObj
(
img_resp
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 车牌识别结果上传失败:失败信息%2"
).
arg
(
sSn
).
arg
(
resp
->
msg
);
qInfo
()
<<
QString
(
"SN(%1): 车牌识别结果上传失败:失败信息%2"
).
arg
(
sSn
).
arg
(
resp
->
msg
);
// 在达到最大重试次数且仍然没有成功的情况下执行相应的处理逻辑
}
}
instace
.
deleteObj
(
resp
);
}
bool
CameraHandle
::
isWifiConnect
(
XSDK_HANDLE
hDevice
,
XSDK_CFG
::
NetWork_Wifi
&
cfg
){
char
szOutBuffer
[
4000
]
=
{
0
};
int
nInOutSize
=
sizeof
(
szOutBuffer
);
// 获取并解析配置
int
nResult
=
XSDK_DevGetSysConfigSyn
(
hDevice
,
JK_NetWork_Wifi
,
szOutBuffer
,
&
nInOutSize
,
3000
,
EXCMD_CONFIG_GET
);
qInfo
()
<<
szOutBuffer
;
if
(
nResult
>=
0
)
{
cfg
.
Parse
(
szOutBuffer
);
return
strlen
(
cfg
.
SSID
.
Value
())
>
0
;
}
else
{
printf
(
"Failed to get Wi-Fi configuration. Error code: %d
\n
"
,
nResult
);
return
false
;
}
}
void
CameraHandle
::
printWifi
(
XSDK_HANDLE
hDevice
,
XSDK_CFG
::
NetWork_Wifi
&
cfg
){
char
szOutBuffer
[
4000
]
=
{
0
};
int
nInOutSize
=
sizeof
(
szOutBuffer
);
...
...
@@ -988,30 +1047,281 @@ void CameraHandle::printWifi(XSDK_HANDLE hDevice,XSDK_CFG::NetWork_Wifi &cfg){
}
}
void
CameraHandle
::
sdkWifi
(
QString
&
pwd
,
QString
&
ssid
){
/**
* @brief CameraHandle::resetGb28181
* 1. 关闭对应摄像头GB28181
2. 修改设备IP并保存当前IP
3. 定时(增加配置 默认5s)后修改为原IP(保证本地NVR可用)
4. 启动GB28181
需注意和定时任务对比GB28181配置冲突处理
需确认修改IP后抓图是否正常,如不正常需在命令开始前增加删除句柄,命令完成后增加句柄以保证抓图实时性
*/
int
CameraHandle
::
resetGb28181
(){
int
old
=
hDevice
;
MainWindow
::
sp_this
->
setIsResetting
(
true
);
bool
is_wifi
=
false
;
ScopeSemaphoreExit
guard
([
this
]()
{
MainWindow
::
sp_this
->
setIsResetting
(
false
);
});
this
->
updateSdkDevStatus
(
false
);
QString
ip
=
QString
::
fromUtf8
(
loginParam
->
sDevId
);
QString
reachableIp
=
vides_data
::
findReachableIp
();
if
(
!
reachableIp
.
isEmpty
())
{
qInfo
()
<<
QString
(
"SN(%1): 未使用的IP地址%2"
).
arg
(
sSn
).
arg
(
reachableIp
);
}
else
{
qInfo
()
<<
QString
(
"SN(%1): 找不到可使用的IP地址"
).
arg
(
sSn
);
return
-
1
;
}
this
->
hDevice
=-
1
;
MainWindow
::
sp_this
->
modifySnMapIp
(
sSn
,
url
);
bool
result
=
changeCameraIp
(
reachableIp
);
int
newHandle
=-
1
;
if
(
!
result
){
result
=
wifiChangeIp
(
reachableIp
,
false
,
old
);
is_wifi
=
true
;
if
(
result
){
//老句柄抓图不正常了
int
sdk_handle
=
this
->
sdkDevLoginSyn
(
reachableIp
,
loginParam
->
nDevPort
,
loginParam
->
sUserName
,
loginParam
->
sPassword
,
3000
);
if
(
sdk_handle
<
0
){
qInfo
()
<<
QString
(
"SN(%1): WIFI新句柄生成失败"
).
arg
(
sSn
);
return
-
1
;
}
else
{
qInfo
()
<<
QString
(
"SN(%1): WIFI新句柄生成成功"
).
arg
(
sSn
);
newHandle
=
sdk_handle
;
this
->
hDevice
=-
1
;
XSDK_DevLogout
(
old
);
}
}
}
// 阻塞等待5秒
QThread
::
sleep
(
5
);
QString
old_ip
;
MainWindow
::
sp_this
->
findSnMapIp
(
this
->
sSn
,
old_ip
);
if
(
old_ip
.
length
()
>
0
){
if
(
is_wifi
){
result
=
wifiChangeIp
(
old_ip
,
true
,
newHandle
);
int
sdk_handle
=
this
->
sdkDevLoginSyn
(
old_ip
,
loginParam
->
nDevPort
,
loginParam
->
sUserName
,
loginParam
->
sPassword
,
3000
);
if
(
sdk_handle
<
0
){
qInfo
()
<<
QString
(
"SN(%1): WIFI新句柄生成失败"
).
arg
(
sSn
);
}
else
{
XSDK_DevLogout
(
newHandle
);
qInfo
()
<<
QString
(
"SN(%1): WIFI新句柄生成成功"
).
arg
(
sSn
);
}
}
else
{
bool
result
=
this
->
changeCameraIp
(
old_ip
);
if
(
result
){
int
sdk_handle
=
this
->
sdkDevLoginSyn
(
old_ip
,
loginParam
->
nDevPort
,
loginParam
->
sUserName
,
loginParam
->
sPassword
,
3000
);
if
(
sdk_handle
<
0
){
qInfo
()
<<
QString
(
"SN(%1): 有线新句柄生成失败"
).
arg
(
sSn
);
}
else
{
XSDK_DevLogout
(
old
);
qInfo
()
<<
QString
(
"SN(%1): 有线新句柄生成成功"
).
arg
(
sSn
);
}
}
}
}
return
this
->
updateSdkDevStatus
(
true
);
}
bool
CameraHandle
::
changeCameraIp
(
QString
&
reachableIp
){
QString
localMac
,
subnetMask
,
gateway
;
bool
success
=
vides_data
::
GetNetworkInfoByQNetworkInterface
(
localMac
,
subnetMask
,
gateway
);
if
(
!
success
)
{
qInfo
()
<<
QString
(
"SN(%1): 获取本地MAC失败"
).
arg
(
sSn
);
return
false
;
}
QByteArray
&&
byJson
=
localMac
.
toUtf8
();
const
char
*
mac
=
byJson
.
data
();
QByteArray
&&
byJsonIp
=
reachableIp
.
toUtf8
();
const
char
*
charIp
=
byJsonIp
.
data
();
signed
char
newEncryptPsw
[
512
]
=
{
0
};
int
nMaxCount
=
100
;
SXSDK_CONFIG_NET_COMMON
*
pRet
=
new
SXSDK_CONFIG_NET_COMMON
[
nMaxCount
];
SXSDK_CONFIG_NET_COMMON
*
pDevice
=
nullptr
;
ScopeSemaphoreExit
guard
([
&
pRet
]()
{
delete
[]
pRet
;
});
memset
(
pRet
,
0
,
sizeof
(
SXSDK_CONFIG_NET_COMMON
)
*
nMaxCount
);
int
nCount
=
XSDK_SearchDevicesSyn
(
pRet
,
nMaxCount
);
if
(
nCount
<=
0
)
{
qInfo
()
<<
QString
(
"SN(%1): 搜索不到设备"
).
arg
(
sSn
);
delete
[]
pRet
;
return
false
;
}
for
(
int
i
=
0
;
i
<
nCount
;
i
++
)
{
qInfo
()
<<
QString
(
"[%1][IP:%2.%3.%4.%5][SN:%6][Mac:%7]"
)
.
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
])
.
arg
(
pRet
[
i
].
sSn
)
.
arg
(
pRet
[
i
].
sMac
);
if
(
QString
(
pRet
[
i
].
sSn
)
==
sSn
)
{
pDevice
=
new
SXSDK_CONFIG_NET_COMMON
;
memset
(
pDevice
,
0
,
sizeof
(
SXSDK_CONFIG_NET_COMMON
));
memcpy
(
pDevice
,
&
pRet
[
i
],
sizeof
(
SXSDK_CONFIG_NET_COMMON
));
break
;
}
}
if
(
pDevice
==
nullptr
)
{
qInfo
()
<<
QString
(
"SN(%1): 有线未找到匹配的设备"
).
arg
(
sSn
);
}
else
{
// 处理找到的设备信息
qInfo
()
<<
QString
(
"有线找到匹配的设备: SN(%1) IP:%2.%3.%4.%5 Mac:%6"
)
.
arg
(
pDevice
->
sSn
)
.
arg
(
pDevice
->
HostIP
.
c
[
0
])
.
arg
(
pDevice
->
HostIP
.
c
[
1
])
.
arg
(
pDevice
->
HostIP
.
c
[
2
])
.
arg
(
pDevice
->
HostIP
.
c
[
3
])
.
arg
(
pDevice
->
sMac
);
// 在这里进行设备IP地址的更改操作
SXSDK_CONFIG_NET_COMMON_V2
devInfo
;
memset
(
&
devInfo
,
0
,
sizeof
(
SXSDK_CONFIG_NET_COMMON_V2
));
XSDK_EncryptPassword
(
""
,
newEncryptPsw
,
512
);
devInfo
.
HostIP
.
l
=
inet_addr
(
charIp
);
devInfo
.
Gateway
.
l
=
inet_addr
(
gateway
.
toStdString
().
c_str
());
devInfo
.
Submask
.
l
=
inet_addr
(
subnetMask
.
toStdString
().
c_str
());
strcpy
(
devInfo
.
HostName
,
pDevice
->
HostName
);
devInfo
.
HttpPort
=
pDevice
->
HttpPort
;
strcpy
(
devInfo
.
LocalMac
,
mac
);
devInfo
.
MaxBps
=
pDevice
->
MaxBps
;
devInfo
.
MaxConn
=
pDevice
->
MaxConn
;
devInfo
.
MonMode
=
pDevice
->
MonMode
;
devInfo
.
nPasswordType
=
1
;
strcpy
(
devInfo
.
sMac
,
pDevice
->
sMac
);
strcpy
(
devInfo
.
Password
,
(
const
char
*
)
newEncryptPsw
);
devInfo
.
SSLPort
=
pDevice
->
SSLPort
;
devInfo
.
TCPPort
=
pDevice
->
TCPPort
;
devInfo
.
TransferPlan
=
pDevice
->
TransferPlan
;
devInfo
.
UDPPort
=
pDevice
->
UDPPort
;
strcpy
(
devInfo
.
UserName
,
loginParam
->
sUserName
);
int
nRet
=
XSDK_ModifyDevIP
((
const
char
*
)
&
devInfo
,
sizeof
(
SXSDK_CONFIG_NET_COMMON_V2
),
10000
);
delete
pDevice
;
if
(
nRet
<
0
){
qInfo
()
<<
QString
(
"SN(%1): 有线修复ip失败错误码:%2"
).
arg
(
sSn
).
arg
(
nRet
);
return
false
;
}
}
return
true
;
}
bool
CameraHandle
::
wifiChangeIp
(
QString
&
Ip
,
bool
is_connect
,
int
h_device
){
XSDK_CFG
::
NetWork_Wifi
wif
;
printWifi
(
h_device
,
wif
);
if
(
is_connect
){
if
(
!
isWifiConnect
(
h_device
,
wif
)){
qInfo
()
<<
QString
(
"SN(%1): 不是wifi连接"
).
arg
(
sSn
);
return
false
;
}
}
QString
hex
=
DecIpToHexIp
(
Ip
);
QByteArray
&&
byIp
=
hex
.
toUtf8
();
const
char
*
cpIp
=
byIp
.
data
();
wif
.
HostIP
.
SetValue
(
cpIp
);
wif
.
Enable
.
SetValue
(
true
);
wif
.
KeyType
.
SetValue
(
1
);
wif
.
EncrypType
.
SetValue
(
"AES"
);
wif
.
Auth
.
SetValue
(
"WPA2PSK"
);
const
char
*
wipCfg
=
wif
.
ToString
();
char
szOutBuffer
[
512
]
=
{
0
};
int
nLen
=
sizeof
(
szOutBuffer
);
int
res
=
XSDK_DevSetSysConfigSyn
(
h_device
,
JK_NetWork_Wifi
,
wipCfg
,
strlen
(
wipCfg
),
szOutBuffer
,
&
nLen
,
3000
,
EXCMD_CONFIG_SET
);
if
(
res
<
0
){
qInfo
()
<<
QString
(
"SN(%1): 无线修改wifi失败:%2"
).
arg
(
sSn
).
arg
(
res
);
return
false
;
}
return
true
;
}
QString
CameraHandle
::
DecIpToHexIp
(
const
QString
&
decIp
)
{
// 将 IP 地址按点号分割成多个部分
QStringList
parts
=
decIp
.
split
(
"."
);
// 检查 IP 地址是否有效(应包含 4 个部分)
if
(
parts
.
size
()
!=
4
)
{
return
QString
();
// 如果无效,返回空字符串
}
QString
hexIp
;
// 用于存储最终的十六进制表示
// 从最后一个部分开始遍历
for
(
int
i
=
3
;
i
>=
0
;
--
i
)
{
// 将每个部分转换为整数
bool
ok
;
int
part
=
parts
[
i
].
toInt
(
&
ok
);
if
(
!
ok
)
return
QString
();
// 如果转换失败,返回空字符串
// 将整数转换为十六进制字符串,并在必要时补零
QString
hexPart
=
QString
::
number
(
part
,
16
).
rightJustified
(
2
,
'0'
);
// 将十六进制字符串添加到结果中
hexIp
.
append
(
hexPart
);
}
// 在结果前添加 "0x" 以表示十六进制
hexIp
.
prepend
(
"0x"
);
return
hexIp
;
// 返回最终的十六进制表示
}
bool
CameraHandle
::
sdkWifi
(
QString
&
pwd
,
QString
&
ssid
){
XSDK_CFG
::
NetWork_Wifi
wif
;
printWifi
(
hDevice
,
wif
);
QByteArray
&&
byPwd
=
pwd
.
toUtf8
();
const
char
*
cpwd
=
byPwd
.
data
();
wif
.
Keys
.
SetValue
(
cpwd
);
QString
reachableIp
=
vides_data
::
findReachableIp
();
QString
hex
=
DecIpToHexIp
(
reachableIp
);
QByteArray
&&
byJson
=
ssid
.
toUtf8
();
const
char
*
cssid
=
byJson
.
data
();
wif
.
SSID
.
SetValue
(
cssid
);
wif
.
Enable
.
SetValue
(
true
);
wif
.
KeyType
.
SetValue
(
1
);
wif
.
EncrypType
.
SetValue
(
"AES"
);
wif
.
Auth
.
SetValue
(
"WPA2PSK"
);
QByteArray
&&
byHex
=
hex
.
toUtf8
();
const
char
*
c_hex
=
byHex
.
data
();
wif
.
HostIP
.
SetValue
(
c_hex
);
//wif.HostIP.SetValue(newc_ip);
const
char
*
wipCfg
=
wif
.
ToString
();
qInfo
()
<<
"wipCfg==>"
<<
wipCfg
;
char
szOutBuffer
[
512
]
=
{
0
};
int
nLen
=
sizeof
(
szOutBuffer
);
int
res
=
XSDK_DevSetSysConfigSyn
(
hDevice
,
JK_NetWork_Wifi
,
wipCfg
,
strlen
(
wipCfg
),
szOutBuffer
,
&
nLen
,
3000
,
EXCMD_CONFIG_SET
);
if
(
res
<
0
){
qInfo
()
<<
QString
(
"SN(%1): 修改wifi失败
"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 修改wifi失败
:%2"
).
arg
(
sSn
).
arg
(
res
);
return
false
;
}
deviceReboot
();
return
true
;
}
void
CameraHandle
::
sdkDevSystemTimeZoneSyn
(
QString
&
time
){
...
...
@@ -1023,12 +1333,12 @@ void CameraHandle::sdkDevSystemTimeZoneSyn(QString &time){
int
res
=
XSDK_DevSetSysConfigSyn
(
hDevice
,
JK_System_TimeZone
,
zoneCfg
,
strlen
(
zoneCfg
),
outBuffer
,
&
nInOutBufSize
,
3000
,
EXCMD_CONFIG_GET
);
if
(
res
<
0
){
qInfo
()
<<
QString
(
"SN(%1): FirstUserTimeZone 修改失败"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): FirstUserTimeZone 修改失败"
).
arg
(
sSn
);
}
res
=
XSDK_DevSynTime
(
hDevice
,
cTime
,
0
);
if
(
res
<
0
){
qInfo
()
<<
QString
(
"SN(%1): sdkDevSystemTimeZoneSyn修改失败"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): sdkDevSystemTimeZoneSyn修改失败"
).
arg
(
sSn
);
}
}
...
...
@@ -1038,7 +1348,7 @@ void CameraHandle::sdkRecordCfg(const char * recordJson){
int
nLen
=
sizeof
(
szOutBuffer
);;
int
res
=
XSDK_DevSetSysConfigSyn
(
hDevice
,
JK_Record
,
recordJson
,
strlen
(
recordJson
),
szOutBuffer
,
&
nLen
,
3000
,
EXCMD_CONFIG_SET
);
if
(
res
<
0
){
qInfo
()
<<
QString
(
"SN(%1): sdkRecordCfg 录像设置->修改失败"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): sdkRecordCfg 录像设置->修改失败"
).
arg
(
sSn
);
}
}
...
...
@@ -1048,17 +1358,23 @@ void CameraHandle::sdkEncodeCfg(const char* pCfg){
int
nLen
=
sizeof
(
szOutBuffer
);
int
res
=
XSDK_DevSetSysConfigSyn
(
hDevice
,
JK_Simplify_Encode
,
pCfg
,
strlen
(
pCfg
),
szOutBuffer
,
&
nLen
,
3000
,
EXCMD_CONFIG_SET
);
if
(
res
<
0
){
qInfo
()
<<
QString
(
"SN(%1): sdkEncodeCfg 配置编码设置->修改失败"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): sdkEncodeCfg 配置编码设置->修改失败"
).
arg
(
sSn
);
}
}
int
CameraHandle
::
updateSdkDevStatus
(
bool
status
){
this
->
isOperateGb28181
.
store
(
true
,
std
::
memory_order_release
);
ScopeSemaphoreExit
streamGuard
([
this
]()
{
isOperateGb28181
.
store
(
false
,
std
::
memory_order_release
);
});
char
szOutBuffer
[
40960
]
=
{
0
};
int
nInOutSize
=
sizeof
(
szOutBuffer
);
int
res
=
XSDK_DevGetSysConfigSyn
(
hDevice
,
JK_NetWork_SPVMN
,
szOutBuffer
,
&
nInOutSize
,
4000
,
EXCMD_CONFIG_GET
);
if
(
res
<
0
){
qInfo
()
<<
QString
(
"SN(%1): GB28181可远程开关"
).
arg
(
sSn
);
qInfo
()
<<
QString
(
"SN(%1): GB28181可远程开关"
).
arg
(
sSn
);
return
0
;
}
...
...
@@ -1070,6 +1386,10 @@ int CameraHandle::updateSdkDevStatus(bool status){
return
res
;
}
void
CameraHandle
::
updateSdkDevSpvMn
(
vides_data
::
responseGb28181
*
gb28181
){
if
(
isOperateGb28181
.
load
(
std
::
memory_order_acquire
)){
qInfo
()
<<
QString
(
"SN(%1): mqtt正在操作GB28181"
).
arg
(
sSn
);
return
;
}
char
szOutBuffer
[
40960
]
=
{
0
};
int
nInOutSize
=
sizeof
(
szOutBuffer
);
int
res
=
XSDK_DevGetSysConfigSyn
(
hDevice
,
JK_NetWork_SPVMN
,
szOutBuffer
,
&
nInOutSize
,
4000
,
EXCMD_CONFIG_GET
);
...
...
@@ -1181,7 +1501,7 @@ int CameraHandle::deviceShutdown()
const
char
*
pCfg
=
cfg
.
ToString
();
nRet
=
XSDK_DevSetSysConfig
(
hDevice
,
JK_OPMachine
,
pCfg
,
strlen
(
pCfg
),
1
,
3000
,
EXCMD_SYSMANAGER_REQ
);
if
(
nRet
<
0
){
qInfo
()
<<
QString
(
"SN(%1): 设备关机失败:%2"
).
arg
(
sSn
).
arg
(
nRet
);
qInfo
()
<<
QString
(
"SN(%1): 设备关机失败:%2"
).
arg
(
sSn
).
arg
(
nRet
);
return
0
;
}
...
...
CameraHandle.h
View file @
eb6e5838
...
...
@@ -31,6 +31,7 @@
#include <opencv2/opencv.hpp>
#include <QSemaphore>
#include <atomic>
#include <arpa/inet.h>
enum
CAR_INFORMATION
{
Exit
,
//出场
...
...
@@ -57,11 +58,12 @@ public:
void
clearCameraHandle
();
bool
distributionNetwork
(
QString
&
ip
);
// void rebindTimer(int hDevice);
//相机参数更新
void
cameraParameterUpdate
(
vides_data
::
responseConfig
&
cloudConfig
);
void
initSdkRealTimeDevSnapSyn
(
int
hDevice
,
int
syn_timer
,
uint64
face_frequency
);
void
initSdkRealTimeDevSnapSyn
(
int
syn_timer
,
uint64
face_frequency
);
void
notificationUpdateImageMap
(
std
::
map
<
QString
,
QString
>&
maps
,
int
numberFaces
,
float
confidence
);
...
...
@@ -85,10 +87,17 @@ 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
void
sdkWifi
(
QString
&
pwd
,
QString
&
ssid
);
bool
sdkWifi
(
QString
&
pwd
,
QString
&
ssid
);
//时间设置
void
sdkDevSystemTimeZoneSyn
(
QString
&
time
);
//录像设置
...
...
@@ -107,7 +116,11 @@ public:
int
deviceShutdown
();
//获取固件版本
void
findFirmwareVersion
(
QString
&
firmwareVersion
);
//复位GB28181
int
resetGb28181
();
//修改相机ip
bool
changeCameraIp
(
QString
&
reachableIp
);
//获取ip
void
findIp
(
QString
&
ip
);
...
...
@@ -162,7 +175,7 @@ signals:
void
afterDownloadFile
(
int
id
,
int
recognitionType
,
QString
ossUrl
);
private
slots
:
void
sdkRealTimeDevSnapSyn
(
int
hDevice
);
void
sdkRealTimeDevSnapSyn
();
void
pushRecordToCloud
(
int
id
,
int
recognitionType
,
QString
ossUrl
);
//void releaseSemaphore();
...
...
@@ -199,6 +212,9 @@ private :
int
image_save
;
std
::
atomic
<
uint64
>
faceCount
;
std
::
atomic
<
bool
>
isOperateGb28181
{
false
};
uint64
face_frequency
;
__uint8_t
algorithmPermissions
;
...
...
Common.cpp
View file @
eb6e5838
...
...
@@ -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,6 +62,8 @@ void Common::setImages(QString images){
images
.
append
(
"/"
);
this
->
images
=
images
;
}
QString
Common
::
GetLocalIp
()
{
QString
ipAddress
;
QList
<
QHostAddress
>
list
=
QNetworkInterface
::
allAddresses
();
...
...
Common.h
View file @
eb6e5838
...
...
@@ -10,7 +10,7 @@
#include <QCryptographicHash>
#include <QMessageAuthenticationCode>
#include <QNetworkInterface>
#include <map>
#include <QDebug>
class
Common
{
...
...
@@ -38,6 +38,7 @@ public:
QString
getVideoDownload
();
void
setVideoDownload
(
QString
videoDownload
);
QString
getImages
();
void
setImages
(
QString
images
);
...
...
@@ -61,6 +62,7 @@ private:
QString
videoOut
;
QString
videoDownload
;
QString
images
;
Common
();
~
Common
();
...
...
MqttSubscriber.cpp
View file @
eb6e5838
...
...
@@ -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,10 +182,21 @@ 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
)
{
...
...
@@ -200,38 +211,64 @@ 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
.
uniq
=
response
.
uniq
;
request
.
sn
=
response
.
sn
;
sendSubscriptionConfirmation
(
request
);
request
.
msg
=
(
res
>=
0
)
?
"成功"
:
"失败"
;
request
.
uniq
=
response
.
uniq
;
sendSubscriptionConfirmation
(
request
,
response
.
sn
);
MQTTAsync_freeMessage
(
&
m
);
MQTTAsync_free
(
topicName
);
return
1
;
}
void
MqttSubscriber
::
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
)
{
QString
responseTopic
=
"/thingshub/"
+
response
.
sn
+
"/device/post"
;
void
MqttSubscriber
::
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
,
QString
&
sn
)
{
QString
responseTopic
=
"/thingshub/"
+
response
.
uniq
+
"/device/post"
;
QByteArray
bResponseTopic
=
responseTopic
.
toUtf8
();
char
*
cResponseTopic
=
bResponseTopic
.
data
();
qInfo
()
<<
"sendSubscriptionConfirmation"
<<
cResponseTopic
;
qInfo
()
<<
QString
(
"SN(%1): sendSubscriptionConfirmation->cResponseTopic%2"
).
arg
(
sn
).
arg
(
cResponseTopic
);
// response.sn
QJsonObject
json
;
json
[
"code"
]
=
response
.
code
;
json
[
"uniq"
]
=
response
.
uniq
;
json
[
"msg"
]
=
response
.
msg
;
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
);
...
...
@@ -240,7 +277,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 @
eb6e5838
...
...
@@ -45,7 +45,7 @@ private:
void
onPublishSuccess
(
MQTTAsync_successData
*
response
);
void
onPublishFailure
(
MQTTAsync_failureData
*
response
);
void
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
);
void
sendSubscriptionConfirmation
(
const
vides_data
::
requestMqttData
&
response
,
QString
&
sn
);
static
MqttSubscriber
*
instance
;
};
...
...
VidesData.h
View file @
eb6e5838
...
...
@@ -48,8 +48,6 @@ struct requestDeviceStatus
std
::
list
<
requestCameraInfo
>
camera_info_list
;
requestDeviceStatus
()
{}
};
struct
responseStsCredentials
{
QString
access_key_id
;
QString
access_key_secret
;
...
...
@@ -109,6 +107,8 @@ struct localDeviceStatus
QString
password
;
localDeviceStatus
()
{}
};
struct
requestFaceReconition
{
QString
id
;
...
...
@@ -260,7 +260,7 @@ struct LicensePlateConfig {
float
carConfidenceMax
;
float
carConfidenceMin
;
int
licensePlateLen
;
quint64
updateAt
;
quint64
updateAt
;
int
maxNum
;
///< 识别最大数量
bool
useHalf
;
///< 是否使用半精度推理模式
float
boxConfThreshold
;
///< 检测框阈值
...
...
@@ -312,11 +312,12 @@ struct responseMqttData{
uint8_t
msg_type
;
QString
sn
;
QString
uniq
;
QString
msg_body
;
};
struct
requestMqttData
{
QString
sn
;
int
code
;
QString
msg
;
int
code
;
QString
uniq
;
};
struct
DetectionParams
{
...
...
@@ -399,16 +400,48 @@ 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
())
{
...
...
@@ -424,11 +457,28 @@ 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
#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 地址,则返回空字符串
}
inline
int
GetCpuIdByAsm_arm
(
char
*
cpu_id
)
...
...
mainwindow.cpp
View file @
eb6e5838
...
...
@@ -3,7 +3,7 @@
MainWindow
*
MainWindow
::
sp_this
=
nullptr
;
MainWindow
::
MainWindow
()
MainWindow
::
MainWindow
()
:
isResetting
(
false
)
{
sp_this
=
this
;
...
...
@@ -16,7 +16,7 @@ MainWindow::MainWindow()
qSetting
->
setIniCodec
(
QTextCodec
::
codecForName
(
"UTF-8"
));
modelPaths
=
qSetting
->
value
(
"licensePlateRecognition/model_paths"
).
toString
();
QThreadPool
*
threadPool
=
QThreadPool
::
globalInstance
();
threadPool
->
setMaxThreadCount
(
12
);
...
...
@@ -47,7 +47,7 @@ MainWindow::MainWindow()
configFetched
=
true
;
}
}
initCommon
();
deleteLogFileTimer
=
new
QTimer
(
this
);
...
...
@@ -65,11 +65,11 @@ MainWindow::MainWindow()
int
licensePlateLen
=
config
.
licensePlateConfig
.
licensePlateLen
;
int
faceLen
=
config
.
faceConfig
.
faceLen
;
float
carShapeConfidence
=
config
.
uniformConfig
.
carShapeConfidence
;
bool
is_high
=
config
.
licensePlateConfig
.
isHigh
;
int
maxNum
=
config
.
licensePlateConfig
.
maxNum
;
bool
useHalf
=
config
.
licensePlateConfig
.
useHalf
;
float
boxThreshold
=
config
.
licensePlateConfig
.
boxConfThreshold
;
...
...
@@ -128,11 +128,12 @@ MainWindow::MainWindow()
}
config
.
mqttConfig
.
clientId
=
serialNumber
;
QString
topic
=
QStringLiteral
(
"/thingshub/%1/device/reply"
).
arg
(
serialNumber
);
config
.
mqttConfig
.
topic
=
topic
;
this
->
mqttConfig
=
config
.
mqttConfig
;
runOrRebootMqtt
(
mqttConfig
,
httpurl
,
serialNumber
);
}
void
MainWindow
::
runOrRebootMqtt
(
vides_data
::
MqttConfig
&
mqtt_config
,
QString
&
httpUrl
,
QString
&
serialNumber
){
MqttSubscriber
*
subscriber
=
MqttSubscriber
::
getInstance
(
this
);
subscriber
->
init
(
mqtt_config
,
httpUrl
,
serialNumber
);
...
...
@@ -142,24 +143,24 @@ void MainWindow::runOrRebootMqtt(vides_data::MqttConfig &mqtt_config,QString &ht
void
MainWindow
::
divParameterUpdate
(
vides_data
::
responseConfig
&
cloudConfig
,
QString
&
httpUrl
,
QString
&
serialNumber
){
bool
faceAlgorithm
=
false
,
licensePlateAlgorithm
=
false
,
uniformAlgorithm
=
false
,
timeChange
=
false
;
AlgorithmTaskManage
&
algorithmTaskManage
=
AlgorithmTaskManage
::
getInstance
();
if
(
cloudConfig
.
faceConfig
.
updateAt
!=
config
.
faceConfig
.
updateAt
){
config
.
faceConfig
=
cloudConfig
.
faceConfig
;
faceAlgorithm
=
true
;
}
if
(
cloudConfig
.
licensePlateConfig
.
updateAt
!=
config
.
licensePlateConfig
.
updateAt
){
config
.
licensePlateConfig
=
cloudConfig
.
licensePlateConfig
;
licensePlateAlgorithm
=
true
;
}
if
(
cloudConfig
.
uniformConfig
.
updateAt
!=
config
.
uniformConfig
.
updateAt
){
config
.
uniformConfig
=
cloudConfig
.
uniformConfig
;
uniformAlgorithm
=
true
;
}
if
(
config
.
timerSettings
.
updateAt
!=
cloudConfig
.
timerSettings
.
updateAt
){
timeChange
=
true
;
}
...
...
@@ -171,9 +172,9 @@ void MainWindow::divParameterUpdate(vides_data::responseConfig &cloudConfig,QStr
runOrRebootMqtt
(
cloudConfig
.
mqttConfig
,
httpUrl
,
serialNumber
);
}
__uint8_t
alg
=
this
->
intToUint8t
(
faceAlgorithm
,
licensePlateAlgorithm
,
uniformAlgorithm
,
false
)
;
vides_data
::
DetectionParams
params
;
params
.
newHumanDetectionLen
=
cloudConfig
.
uniformConfig
.
humanDetectionLen
;
params
.
newLicensePlateLen
=
cloudConfig
.
licensePlateConfig
.
licensePlateLen
;
params
.
newFaceLen
=
cloudConfig
.
faceConfig
.
faceLen
;
...
...
@@ -190,8 +191,8 @@ void MainWindow::divParameterUpdate(vides_data::responseConfig &cloudConfig,QStr
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
){
...
...
@@ -208,7 +209,34 @@ void MainWindow::divParameterUpdate(vides_data::responseConfig &cloudConfig,QStr
}
}
void
MainWindow
::
modifySnMapIp
(
QString
&
sn
,
QString
&
ip
){
qSetting
->
beginGroup
(
"SnMapIp"
);
QStringList
lokeys
=
qSetting
->
childKeys
();
bool
keyExists
=
false
;
// 遍历现有键
foreach
(
QString
lk
,
lokeys
)
{
// 如果键存在,修改对应的值
if
(
lk
==
sn
)
{
qSetting
->
setValue
(
lk
,
ip
);
keyExists
=
true
;
break
;
}
}
// 如果键不存在,添加新键值对
if
(
!
keyExists
)
{
qSetting
->
setValue
(
sn
,
ip
);
}
qSetting
->
endGroup
();
}
void
MainWindow
::
findSnMapIp
(
QString
&
sn
,
QString
&
ip
){
// 直接通过键路径获取 IP 地址
ip
=
qSetting
->
value
(
QString
(
"SnMapIp/%1"
).
arg
(
sn
),
""
).
toString
();
}
CameraHandle
*
MainWindow
::
findHandle
(
QString
sn
){
for
(
auto
it
=
faceDetectionParkingPushs
.
begin
();
it
!=
faceDetectionParkingPushs
.
end
();
++
it
)
{
...
...
@@ -464,9 +492,15 @@ void MainWindow::clearHandle(QString sDevId, int nDevPort){
void
MainWindow
::
clearOfflineCameraHandle
(
QString
sDevId
,
int
nDevPort
)
{
emit
shutdownSignals
(
sDevId
,
nDevPort
);
}
//平台有 盒子没有 盒子开启
void
MainWindow
::
setIsResetting
(
bool
running
)
{
this
->
isResetting
.
store
(
running
,
std
::
memory_order_release
);
}
//平台没有 盒子有 盒子关闭
void
MainWindow
::
startCamera
(
const
QString
&
httpurl
){
if
(
this
->
isResetting
.
load
(
std
::
memory_order_acquire
)){
qInfo
()
<<
"正在执行复位GB28181 程序,请等待"
;
}
Common
&
instace
=
Common
::
getInstance
();
MediaFaceImage
*
mediaFaceImage
=
MediaFaceImage
::
getInstance
();
QString
nonConstHttpUrl
=
std
::
remove_const
<
QString
>::
type
(
httpurl
);
...
...
@@ -498,7 +532,7 @@ void MainWindow::startCamera(const QString &httpurl){
instace
.
deleteObj
(
res
);
return
;
}
vides_data
::
responseConfig
cloudConfig
;
HttpService
http_config
(
httpurl
);
vides_data
::
response
*
res_config
=
http_config
.
httpDeviceConfig
(
serialNumber
,
cloudConfig
);
...
...
@@ -509,7 +543,7 @@ void MainWindow::startCamera(const QString &httpurl){
}
instace
.
deleteObj
(
res_config
);
divParameterUpdate
(
cloudConfig
,
nonConstHttpUrl
,
serialNumber
);
for
(
const
auto
&
device
:
devices
.
list
)
{
if
(
localDevices
.
count
(
device
.
sSn
)
>
0
){
vides_data
::
localDeviceStatus
*
localDevice
=
localDevices
.
at
(
device
.
sSn
);
...
...
@@ -553,10 +587,25 @@ void MainWindow::startCamera(const QString &httpurl){
offlineCameraHandle
->
findFirmwareVersion
(
camera_info
.
firmware_version
);
reStatus
.
camera_info_list
.
push_front
(
camera_info
);
HttpService
http_gb28181
(
httpurl
);
vides_data
::
response
*
res
=
http_gb28181
.
httpFindGb28181Config
(
camera_info
.
sSn
);
if
(
res
->
code
!=
0
){
qInfo
()
<<
"请求摄像头gb28181配置失败"
;
instace
.
deleteObj
(
res
);
return
;
}
vides_data
::
responseGb28181
*
gb281
=
reinterpret_cast
<
vides_data
::
responseGb28181
*>
(
res
->
data
);
offlineCameraHandle
->
updateSdkDevSpvMn
(
gb281
);
instace
.
deleteObj
(
gb281
);
instace
.
deleteObj
(
res
);
__uint8_t
new_algorithm
=
intToUint8t
(
devConfig
.
faceConfig
.
isOn
,
devConfig
.
licensePlateConfig
.
isOn
,
devConfig
.
uniformConfig
.
isOn
,
devConfig
.
humanConfig
.
isOn
);
uint64
face_frequency
=
devConfig
.
humanConfig
.
faceFrequency
;
offlineCameraHandle
->
initFaceFrequency
(
face_frequency
);
uint64
face_frequency
=
devConfig
.
humanConfig
.
faceFrequency
;
offlineCameraHandle
->
initFaceFrequency
(
face_frequency
);
offlineCameraHandle
->
cameraParameterUpdate
(
devConfig
);
offlineCameraHandle
->
initAlgorithmPermissions
(
new_algorithm
);
if
(
!
offlineCameraHandle
->
compareLists
(
device
.
areas
)){
...
...
@@ -621,9 +670,9 @@ void MainWindow::initDevConfigSyn(CameraHandle *cameraHandle,vides_data::respons
QByteArray
bRecor
=
recor
.
toUtf8
();
const
char
*
cRecor
=
bRecor
.
data
();
cameraHandle
->
sdkRecordCfg
(
cRecor
);
QString
enCode_one
;
initDeviceEncodeToString
(
devConfig
,
enCode_one
);
QByteArray
benCode_one
=
enCode_one
.
toUtf8
();
const
char
*
b_one
=
benCode_one
.
data
();
...
...
@@ -962,7 +1011,7 @@ __uint8_t MainWindow::intToUint8t(bool faceAlgorithm, bool licensePlateAlgorithm
__uint8_t
result
=
0
;
//人形识别对应最高高位(第3位)
result
|=
(
humanAlgorithm
?
1
:
0
)
<<
3
;
// 工服识别对应最高位(第2位)
result
|=
(
uniformAlgorithm
?
1
:
0
)
<<
2
;
...
...
@@ -971,7 +1020,7 @@ __uint8_t MainWindow::intToUint8t(bool faceAlgorithm, bool licensePlateAlgorithm
// 车牌识别对应最低位(第0位)
result
|=
(
licensePlateAlgorithm
?
1
:
0
);
return
result
;
}
void
MainWindow
::
initCameras
(
vides_data
::
cameraParameters
&
parameter
,
vides_data
::
responseConfig
&
devConfig
,
const
std
::
list
<
vides_data
::
responseArea
>&
areas
,
std
::
list
<
vides_data
::
requestCameraInfo
>&
camera_info_list
){
...
...
@@ -984,25 +1033,25 @@ void MainWindow::initCameras(vides_data::cameraParameters ¶meter,vides_data:
int
sdk_handle
=
cameraHandle
->
sdkDevLoginSyn
(
parameter
.
sDevId
,
parameter
.
nDevPort
,
parameter
.
sUserName
,
parameter
.
sPassword
,
3000
);
qDebug
()
<<
QString
(
"SN(%1): 句柄为%2"
).
arg
(
parameter
.
sSn
).
arg
(
sdk_handle
);
if
(
sdk_handle
<=
0
){
qInfo
()
<<
QString
(
"SN(%1): 登录失败"
).
arg
(
parameter
.
sSn
);
return
;
}
mediaFaceImage
->
setMap
(
sdk_handle
,
cameraHandle
);
initDevConfigSyn
(
cameraHandle
,
devConfig
);
cameraHandle
->
sdkDevSetAlarmListener
(
sdk_handle
,
0
);
int
synTime
=
devConfig
.
camera
.
devSnapSynTimer
;
uint64
face_frequency
=
devConfig
.
humanConfig
.
faceFrequency
;
float
carConfidenceMax
=
devConfig
.
licensePlateConfig
.
carConfidenceMax
;
float
carConfidenceMin
=
devConfig
.
licensePlateConfig
.
carConfidenceMin
;
cameraHandle
->
initSdkRealTimeDevSnapSyn
(
s
dk_handle
,
s
ynTime
,
face_frequency
);
cameraHandle
->
initSdkRealTimeDevSnapSyn
(
synTime
,
face_frequency
);
cameraHandle
->
setCarConfidenceMaxAndMin
(
carConfidenceMax
,
carConfidenceMin
);
// QString pwd="admin2024";
...
...
@@ -1014,7 +1063,7 @@ void MainWindow::initCameras(vides_data::cameraParameters ¶meter,vides_data:
cameraHandle
->
findFirmwareVersion
(
camera_info
.
firmware_version
);
camera_info_list
.
push_front
(
camera_info
);
__uint8_t
new_algorithm
=
intToUint8t
(
devConfig
.
faceConfig
.
isOn
,
devConfig
.
licensePlateConfig
.
isOn
,
devConfig
.
uniformConfig
.
isOn
,
devConfig
.
humanConfig
.
isOn
);
cameraHandle
->
initAlgorithmPermissions
(
new_algorithm
);
...
...
mainwindow.h
View file @
eb6e5838
...
...
@@ -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,15 +43,17 @@ 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
);
...
...
@@ -81,8 +83,10 @@ 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
);
...
...
@@ -101,7 +105,7 @@ private:
QSettings
*
qSetting
;
QTimer
*
deleteLogFileTimer
;
QTimer
*
dePermissionSynTimer
;
QTcpServer
server
;
...
...
@@ -118,9 +122,10 @@ 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