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
3dea4220
Commit
3dea4220
authored
Jan 10, 2025
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增NVR处理抓图失败01
parent
b2696176
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
146 additions
and
46 deletions
+146
-46
RecognizedInfo.cpp
+39
-0
RecognizedInfo.h
+0
-0
CameraHandle.cpp
+43
-32
CameraHandle.h
+5
-3
HttpService.cpp
+1
-0
ParkingSpaceInfo.h
+1
-1
RecognizedInfo.cpp
+1
-1
RecognizedInfo.h
+25
-0
VidesData.h
+1
-0
gamera_videos.pro
+2
-3
mainwindow.cpp
+24
-6
mainwindow.h
+4
-0
No files found.
RecognizedInfo.cpp
0 → 100644
View file @
3dea4220
#include " RecognizedInfo.h"
RecognizedInfo
::
RecognizedInfo
(){
}
RecognizedInfo
::
RecognizedInfo
(
const
QString
&
plate
,
qint64
time
,
QString
color
)
:
licensePlate
(
plate
),
recognizeTime
(
time
),
color
(
color
)
{
}
// Getter 方法
QString
RecognizedInfo
::
getLicensePlate
()
{
return
licensePlate
;
}
qint64
RecognizedInfo
::
getRecognizeTime
()
{
return
recognizeTime
;
}
QString
RecognizedInfo
::
getColor
(){
return
color
;
}
// Setter 方法
void
RecognizedInfo
::
setLicensePlate
(
const
QString
&
plate
)
{
this
->
licensePlate
=
plate
;
}
void
RecognizedInfo
::
setRecognizeTime
(
qint64
time
)
{
this
->
recognizeTime
=
time
;
}
void
RecognizedInfo
::
setColor
(
QString
&
color
){
this
->
color
=
color
;
}
RecognizedInfo
::~
RecognizedInfo
(){
}
Recognition
Info.h
→
Recognized
Info.h
100755 → 100644
View file @
3dea4220
File moved
CameraHandle.cpp
View file @
3dea4220
...
...
@@ -222,9 +222,9 @@ int XNetSDK_MediaCallBack(XSDK_HANDLE hMedia, int nDataType, int nDataLen, int n
int
CameraHandle
::
sdkDevSetAlarmListener
(
XSDK_HANDLE
hDevice
,
int
bListener
)
{
return
XSDK_DevSetAlarmListener
(
hDevice
,
bListener
);
}
void
CameraHandle
::
setHkDevice
(
int
hk_Device
){
void
CameraHandle
::
setHkDevice
(
bool
hk_status
,
int
hk_Device
){
this
->
hk_Device
=
hk_Device
;
this
->
hk_status
=
hk_status
;
}
int
CameraHandle
::
getChannel
(){
...
...
@@ -410,6 +410,10 @@ int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
if
(
image
.
empty
())
{
qInfo
()
<<
"FaceImageCallBack抓图失败,尝试调用FaceHkImageCallBack"
;
if
(
!
hk_status
){
qInfo
()
<<
QString
(
"SN(%1): callbackFunction通过IP获取到对应通道号失败"
).
arg
(
sSn
);
return
-
1
;
}
int
hk_channel
=
mediaFaceImage
->
getIPChannelInfo
(
hk_Device
,
QString
(
loginParam
->
sDevId
));
if
(
hk_channel
<
0
){
qInfo
()
<<
QString
(
"SN(%1): callbackFunction通过IP获取到对应通道号失败"
).
arg
(
sSn
);
...
...
@@ -431,6 +435,29 @@ int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
updateImage
(
image
,
currentTime
);
}
bool
CameraHandle
::
threeConsecutiveImage
(){
Common
&
instace
=
Common
::
getInstance
();
offlineCount
++
;
// 累加计数器
if
(
offlineCount
>=
3
)
{
// 判断是否连续3次返回0
qInfo
()
<<
QString
(
"SN(%1): 设备离线"
).
arg
(
sSn
);
QString
ip
=
QString
::
fromUtf8
(
loginParam
->
sDevId
);
bool
is_ping
=
instace
.
pingAddress
(
ip
);
qInfo
()
<<
sSn
<<
":ping 的结果"
<<
is_ping
;
if
(
is_ping
){
deviceReboot
();
}
else
{
QString
ip
=
QString
::
fromUtf8
(
loginParam
->
sDevId
);
MainWindow
::
sp_this
->
clearOfflineCameraHandle
(
ip
,
loginParam
->
nDevPort
);
}
// 执行离线处理逻辑
// TODO: 可以在此处更新设备状态、发送告警通知等
// 重置计数器,以便下次再次检测连续离线
offlineCount
=
0
;
return
true
;
}
return
false
;
}
void
CameraHandle
::
sdkDevSnapSyn
(
XSDK_HANDLE
hDevice
,
int
nChannel
){
if
(
hDevice
<=
0
){
...
...
@@ -444,8 +471,6 @@ void CameraHandle::sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel){
ScopeSemaphoreExit
guard
([
this
]()
{
semaphore
.
release
();
// 释放信号量
});
Common
&
instace
=
Common
::
getInstance
();
if
(
algorithmPermissions
==
0x00
){
return
;
}
...
...
@@ -454,38 +479,24 @@ void CameraHandle::sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel){
qint64
currentTime
=
QDateTime
::
currentSecsSinceEpoch
();
int
ret
=
mediaFaceImage
->
FaceImageCallBack
(
hDevice
,
nChannel
,
image
,
sSn
);
if
(
ret
<
0
)
{
int
hk_channel
=
mediaFaceImage
->
getIPChannelInfo
(
hk_Device
,
QString
(
loginParam
->
sDevId
));
if
(
hk_channel
<
0
){
qInfo
()
<<
QString
(
"SN(%1): sdkDevSnapSyn 通过IP获取到对应通道号失败"
).
arg
(
sSn
);
return
;
}
int
retHk
=
mediaFaceImage
->
FaceHkImageCallBack
(
hk_Device
,
hk_channel
,
image
,
sSn
);
if
(
retHk
<
0
){
offlineCount
++
;
// 累加计数器
if
(
offlineCount
>=
3
)
{
// 判断是否连续3次返回0
qInfo
()
<<
QString
(
"SN(%1): 设备离线"
).
arg
(
sSn
);
QString
ip
=
QString
::
fromUtf8
(
loginParam
->
sDevId
);
bool
is_ping
=
instace
.
pingAddress
(
ip
);
qInfo
()
<<
sSn
<<
":ping 的结果"
<<
is_ping
;
if
(
is_ping
){
deviceReboot
();
}
else
{
QString
ip
=
QString
::
fromUtf8
(
loginParam
->
sDevId
);
MainWindow
::
sp_this
->
clearOfflineCameraHandle
(
ip
,
loginParam
->
nDevPort
);
}
// 执行离线处理逻辑
// TODO: 可以在此处更新设备状态、发送告警通知等
// 重置计数器,以便下次再次检测连续离线
if
(
!
hk_status
){
if
(
threeConsecutiveImage
())
return
;
}
else
{
int
hk_channel
=
mediaFaceImage
->
getIPChannelInfo
(
hk_Device
,
QString
(
loginParam
->
sDevId
));
if
(
hk_channel
<
0
){
qInfo
()
<<
QString
(
"SN(%1): sdkDevSnapSyn 通过IP获取到对应通道号失败"
).
arg
(
sSn
);
return
;
}
int
retHk
=
mediaFaceImage
->
FaceHkImageCallBack
(
hk_Device
,
hk_channel
,
image
,
sSn
);
if
(
retHk
<
0
){
if
(
threeConsecutiveImage
())
return
;
}
else
{
// NVR抓图成功,则重置计数器
offlineCount
=
0
;
return
;
}
}
else
{
// 如果不连续,则重置计数器
offlineCount
=
0
;
}
}
else
{
//
如果不连续,则
重置计数器
//
第一次相机抓图成功,
重置计数器
offlineCount
=
0
;
}
if
(
image
.
empty
())
...
...
CameraHandle.h
View file @
3dea4220
#ifndef CAMERAHANDLE_H
#define CAMERAHANDLE_H
#include "
Recognition
Info.h"
#include "
Recognized
Info.h"
#include "FaceReconitionHandle.h"
#include "HttpService.h"
#include "LicensePlateRecognition.h"
...
...
@@ -52,7 +52,7 @@ public:
//int SdkMediaGetFaceImage(int hDevice, int nSeq, int nTimeout);
int
sdkDevSetAlarmListener
(
XSDK_HANDLE
hDevice
,
int
bListener
);
void
setHkDevice
(
int
hk_Device
);
void
setHkDevice
(
bool
hk_status
,
int
hk_Device
);
int
getHdevice
();
int
getChannel
();
...
...
@@ -83,6 +83,8 @@ public:
void
licensePlateRecognitionResults
(
vides_data
::
requestLicensePlate
&
location
);
bool
threeConsecutiveImage
();
void
sdkDevSnapSyn
(
XSDK_HANDLE
hDevice
,
int
nChannel
);
void
printWifi
(
XSDK_HANDLE
hDevice
,
XSDK_CFG
::
NetWork_Wifi
&
cfg
);
...
...
@@ -186,7 +188,7 @@ private slots:
private
:
int
hDevice
;
int
hk_Device
;
bool
hk_status
;
int
channel
;
QString
httpUrl
;
...
...
HttpService.cpp
View file @
3dea4220
...
...
@@ -564,6 +564,7 @@ vides_data::response *HttpService::httpDeviceConfig(const QString &serialNumber,
config
.
humanConfig
.
faceFrequency
=
humanConfigObj
[
"faceFrequency"
].
toVariant
().
toUInt
();
//解析nvrConfig;
QJsonObject
nvrConfigObj
=
dataObj
[
"nvrConfig;"
].
toObject
();
config
.
nvrConfig
.
isOn
=
nvrConfigObj
[
"isOn"
].
toBool
();
config
.
nvrConfig
.
ip
=
nvrConfigObj
[
"ip"
].
toString
();
config
.
nvrConfig
.
port
=
(
unsigned
short
)
nvrConfigObj
[
"port"
].
toInt
();
config
.
nvrConfig
.
password
=
nvrConfigObj
[
"password"
].
toString
();
...
...
ParkingSpaceInfo.h
View file @
3dea4220
#ifndef PARKINGSPACEINFO_H
#define PARKINGSPACEINFO_H
#include "VidesData.h"
#include "
Recognition
Info.h"
#include "
Recognized
Info.h"
#include <QMutex>
#include <QQueue>
class
ParkingSpaceInfo
{
...
...
RecognizedInfo.cpp
View file @
3dea4220
#include "
Recognition
Info.h"
#include "
Recognized
Info.h"
RecognizedInfo
::
RecognizedInfo
(){
...
...
RecognizedInfo.h
0 → 100755
View file @
3dea4220
#ifndef RECOGNITIONINFO_H
#define RECOGNITIONINFO_H
#include <QString>
#include <map>
class
RecognizedInfo
{
public
:
RecognizedInfo
(
const
QString
&
plate
,
qint64
time
,
QString
color
);
RecognizedInfo
();
~
RecognizedInfo
();
QString
getLicensePlate
();
qint64
getRecognizeTime
()
;
QString
getColor
();
void
setLicensePlate
(
const
QString
&
plate
);
void
setRecognizeTime
(
qint64
time
);
void
setColor
(
QString
&
color
);
private
:
QString
licensePlate
;
// 车牌号码
qint64
recognizeTime
;
// 识别时间
QString
color
;
};
#endif // RECOGNITIONINFO_H
VidesData.h
View file @
3dea4220
...
...
@@ -312,6 +312,7 @@ struct MqttConfig {
quint64
updateAt
;
};
struct
NvrConfig
{
bool
isOn
;
QString
ip
;
QString
username
;
QString
password
;
...
...
gamera_videos.pro
View file @
3dea4220
...
...
@@ -103,7 +103,6 @@ SOURCES += \
mainwindow
.
cpp
\
LicensePlateRecognition
.
cpp
\
MediaFaceImage
.
cpp
\
RecognizedInfo
.
cpp
\
Httpclient
.
cpp
\
HttpService
.
cpp
\
TaskRunnable
.
cpp
\
...
...
@@ -115,7 +114,8 @@ SOURCES += \
AlgorithmTaskManage
.
cpp
\
BaseAlgorithm
.
cpp
\
MqttSubscriber
.
cpp
\
NonConnectedCameraHandle
.
cpp
NonConnectedCameraHandle
.
cpp
\
RecognizedInfo
.
cpp
HEADERS
+=
\
Common
.
h
\
...
...
@@ -123,7 +123,6 @@ HEADERS += \
mainwindow
.
h
\
LicensePlateRecognition
.
h
\
MediaFaceImage
.
h
\
RecognitionInfo
.
h
\
HttpClient
.
h
\
HttpService
.
h
\
VidesData
.
h
\
...
...
mainwindow.cpp
View file @
3dea4220
...
...
@@ -93,8 +93,9 @@ MainWindow::MainWindow():isResetting(false)
return
;
}
//QString ip,QString userName,QString passWord,uint16_t port
loginNetDvr
(
config
.
nvrConfig
.
ip
,
config
.
nvrConfig
.
username
,
config
.
nvrConfig
.
password
,
config
.
nvrConfig
.
port
);
NET_DVR_Init
();
hk_Device
=-
1
;
nvr_status
=
config
.
nvrConfig
.
isOn
;
connect
(
this
,
SIGNAL
(
shutdownSignals
(
QString
,
int
)),
this
,
SLOT
(
clearHandle
(
QString
,
int
)),
Qt
::
QueuedConnection
);
...
...
@@ -145,6 +146,7 @@ void MainWindow::runOrRebootMqtt(vides_data::MqttConfig &mqtt_config,QString &ht
}
int
MainWindow
::
loginNetDvr
(
QString
ip
,
QString
userName
,
QString
passWord
,
uint16_t
port
){
if
(
hk_Device
<
0
){
NET_DVR_USER_LOGIN_INFO
loginInfo
;
NET_DVR_DEVICEINFO_V40
deviceInfo
;
loginInfo
.
wPort
=
port
;
...
...
@@ -171,9 +173,18 @@ int MainWindow::loginNetDvr(QString ip,QString userName,QString passWord,uint16_
}
this
->
hk_Device
=
lUserID
;
return
lUserID
;
}
}
bool
MainWindow
::
getDeviceStatus
(
int
UserId
)
{
if
(
UserId
<
0
)
return
false
;
bool
devStatus
=
NET_DVR_RemoteControl
(
UserId
,
NET_DVR_CHECK_USER_STATUS
,
nullptr
,
0
);
if
(
devStatus
)
{
qInfo
()
<<
"设备在线"
;
}
else
{
qInfo
()
<<
"设备不在线"
;
}
return
devStatus
;
}
void
MainWindow
::
divParameterUpdate
(
vides_data
::
responseConfig
&
cloudConfig
,
QString
&
httpUrl
,
QString
&
serialNumber
){
bool
faceAlgorithm
=
false
,
licensePlateAlgorithm
=
false
,
uniformAlgorithm
=
false
,
timeChange
=
false
;
AlgorithmTaskManage
&
algorithmTaskManage
=
AlgorithmTaskManage
::
getInstance
();
...
...
@@ -566,6 +577,13 @@ void MainWindow::startCamera(const QString &httpurl){
reStatus
.
mac
=
std
::
move
(
is_mac
);
HttpService
httpService
(
httpurl
);
vides_data
::
response
*
re
=
httpService
.
httpFindCameras
(
serialNumber
,
devices
);
if
(
config
.
nvrConfig
.
isOn
&&
!
getDeviceStatus
(
hk_Device
)
){
nvr_status
=
true
;
loginNetDvr
(
config
.
nvrConfig
.
ip
,
config
.
nvrConfig
.
username
,
config
.
nvrConfig
.
password
,
config
.
nvrConfig
.
port
);
}
else
if
(
!
config
.
nvrConfig
.
isOn
){
nvr_status
=
false
;
}
if
(
re
->
code
==
0
||
re
->
code
==
20004
){
//本次搜索到设备列表
std
::
map
<
QString
,
vides_data
::
localDeviceStatus
*>
localDevices
;
...
...
@@ -645,7 +663,7 @@ void MainWindow::startCamera(const QString &httpurl){
offlineCameraHandle
->
findFirmwareVersion
(
camera_info
.
firmware_version
);
camera_info
.
mac
=
localDevice
->
mac
;
reStatus
.
camera_info_list
.
push_front
(
camera_info
);
offlineCameraHandle
->
setHkDevice
(
nvr_status
,
hk_Device
);
HttpService
http_gb28181
(
httpurl
);
vides_data
::
response
*
res
=
http_gb28181
.
httpFindGb28181Config
(
camera_info
.
sSn
);
if
(
res
->
code
!=
0
){
...
...
@@ -1104,7 +1122,7 @@ void MainWindow::initCameras(vides_data::cameraParameters ¶meter,vides_data:
initDevConfigSyn
(
cameraHandle
,
devConfig
);
cameraHandle
->
sdkDevSetAlarmListener
(
sdk_handle
,
0
);
cameraHandle
->
setHkDevice
(
hk_Device
);
cameraHandle
->
setHkDevice
(
nvr_status
,
hk_Device
);
int
synTime
=
devConfig
.
camera
.
devSnapSynTimer
;
uint64
face_frequency
=
devConfig
.
humanConfig
.
faceFrequency
;
float
carConfidenceMax
=
devConfig
.
licensePlateConfig
.
carConfidenceMax
;
...
...
mainwindow.h
View file @
3dea4220
...
...
@@ -53,6 +53,8 @@ public:
CameraHandle
*
findHandle
(
QString
sn
);
bool
getDeviceStatus
(
int
UserId
);
void
modifySnMapIp
(
QString
&
sn
,
QString
&
ip
);
void
findSnMapIp
(
QString
&
sn
,
QString
&
ip
);
...
...
@@ -130,6 +132,8 @@ private:
std
::
atomic
<
bool
>
isResetting
;
int
hk_Device
;
bool
nvr_status
;
};
#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