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
22f4b088
Commit
22f4b088
authored
Sep 03, 2024
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复ping命令进程生命周期问题01
parent
6c388318
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
30 deletions
+37
-30
CameraHandle.cpp
+8
-8
FaceReconitionHandle.cpp
+10
-10
VidesData.h
+12
-5
mainwindow.cpp
+7
-7
No files found.
CameraHandle.cpp
View file @
22f4b088
...
...
@@ -143,7 +143,7 @@ int XNetSDK_MediaCallBack(XSDK_HANDLE hMedia, int nDataType, int nDataLen, int n
if
(
EXCMD_DOWNLOAD_DATA
==
nDataType
)
{
q
Debug
()
<<
"EXCMD_DOWNLOAD_DATA"
<<
nDataType
;
q
Info
()
<<
"EXCMD_DOWNLOAD_DATA"
<<
nDataType
;
/*if (g_hRecordDownload > 0 && g_hRecordDownload == hMedia)
{
...
...
@@ -197,9 +197,9 @@ int XNetSDK_MediaCallBack(XSDK_HANDLE hMedia, int nDataType, int nDataLen, int n
// 等待 ffmpeg 进程结束
if
(
ffmpegProcess
.
waitForFinished
(
20000
))
{
//QFile::remove(dName);
q
Debug
()
<<
"ffmpeg process finished successfully."
;
q
Info
()
<<
"ffmpeg process finished successfully."
;
}
else
{
q
Debug
()
<<
"Error: ffmpeg process did not finish."
;
q
Info
()
<<
"Error: ffmpeg process did not finish."
;
}
// 销毁 QProcess 对象
...
...
@@ -354,7 +354,7 @@ void CameraHandle::sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id,
//param.result = sdkInitCallback; // 结果回调(必填)
SMsgReceiver
sms
(
nullptr
,
XNetSDK_MediaCallBack
,
this
);
param
.
result
=
sms
;
q
Debug
()
<<
"XSDK_MediaRecordDownload hDevice:"
<<
this
->
hDevice
;
q
Info
()
<<
"XSDK_MediaRecordDownload hDevice:"
<<
this
->
hDevice
;
this
->
mediaHandle
=
XSDK_MediaRecordDownload
(
this
->
hDevice
,
&
param
,
0
,
4000
);
if
(
this
->
mediaHandle
<
0
)
...
...
@@ -390,7 +390,7 @@ int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
}
else
{
q
Debug
()
<<
"OnDevAlarmCallback[Dev:"
<<
hObject
<<
"][Event:"
<<
szString
<<
"]"
;
q
Info
()
<<
"OnDevAlarmCallback[Dev:"
<<
hObject
<<
"][Event:"
<<
szString
<<
"]"
;
}
cv
::
Mat
image
;
MediaFaceImage
*
mediaFaceImage
=
MediaFaceImage
::
getInstance
();
...
...
@@ -429,7 +429,7 @@ void CameraHandle::sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel){
int
ret
=
mediaFaceImage
->
FaceImageCallBack
(
hDevice
,
nChannel
,
image
);
if
(
ret
<
0
)
{
offlineCount
++
;
// 累加计数器
q
Debug
()
<<
"offlineCount: "
<<
loginParam
->
sDevId
<<
offlineCount
;
q
Info
()
<<
"offlineCount: "
<<
loginParam
->
sDevId
<<
offlineCount
;
if
(
offlineCount
>=
3
)
{
// 判断是否连续3次返回0
qInfo
()
<<
"设备离线"
;
...
...
@@ -954,7 +954,7 @@ void CameraHandle::printWifi(XSDK_HANDLE hDevice,XSDK_CFG::NetWork_Wifi &cfg){
// 获取并解析配置
int
nResult
=
XSDK_DevGetSysConfigSyn
(
hDevice
,
JK_NetWork_Wifi
,
szOutBuffer
,
&
nInOutSize
,
3000
,
EXCMD_CONFIG_GET
);
q
Debug
()
<<
szOutBuffer
;
q
Info
()
<<
szOutBuffer
;
if
(
nResult
>=
0
)
{
cfg
.
Parse
(
szOutBuffer
);
...
...
@@ -1009,7 +1009,7 @@ void CameraHandle::sdkDevSystemTimeZoneSyn(QString &time){
//录像设置
void
CameraHandle
::
sdkRecordCfg
(
const
char
*
recordJson
){
q
Debug
()
<<
recordJson
;
q
Info
()
<<
recordJson
;
char
szOutBuffer
[
512
]
=
{
0
};
int
nLen
=
sizeof
(
szOutBuffer
);;
int
res
=
XSDK_DevSetSysConfigSyn
(
hDevice
,
JK_Record
,
recordJson
,
strlen
(
recordJson
),
szOutBuffer
,
&
nLen
,
3000
,
EXCMD_CONFIG_SET
);
...
...
FaceReconitionHandle.cpp
View file @
22f4b088
...
...
@@ -37,7 +37,7 @@ cv::Mat FaceReconitionHandle::loadImage(const QString &path) {
std
::
string
stdPath
=
path
.
toStdString
();
cv
::
Mat
image
=
cv
::
imread
(
stdPath
,
cv
::
IMREAD_COLOR
);
if
(
!
image
.
empty
())
{
q
Debug
()
<<
"图像以OpenCV成功加载。"
;
q
Info
()
<<
"图像以OpenCV成功加载。"
;
return
image
;
}
...
...
@@ -151,7 +151,7 @@ void FaceReconitionHandle::featureRemove(){
if
(
customIds
.
size
()
>
0
){
for
(
auto
customId
:
customIds
){
HResult
ret
=
HF_FeaturesGroupFeatureRemove
(
ctxHandle
,
customId
);
q
Debug
()
<<
"ret:featureRemove "
<<
ret
;
q
Info
()
<<
"ret:featureRemove "
<<
ret
;
}
setImageChanged
(
false
);
}
...
...
@@ -180,10 +180,10 @@ cv::Mat FaceReconitionHandle::loadImageFromByteStream(const QString& filePath) {
}
return
mat
;
}
catch
(
const
CImgException
&
e
)
{
q
Debug
()
<<
"CImg Error: "
<<
e
.
what
();
q
Info
()
<<
"CImg Error: "
<<
e
.
what
();
return
cv
::
Mat
();;
}
catch
(
const
cv
::
Exception
&
e
)
{
q
Debug
()
<<
"OpenCV Error: "
<<
e
.
what
();
q
Info
()
<<
"OpenCV Error: "
<<
e
.
what
();
return
cv
::
Mat
();
;
}
...
...
@@ -218,7 +218,7 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v
HF_FaceContextRunFaceTrack
(
ctxHandle
,
imageSteamHandle
,
&
multipleFaceData
);
if
(
multipleFaceData
.
detectedNum
<=
0
)
{
q
Debug
()
<<
QString
(
"search 未检测到人脸"
);
q
Info
()
<<
QString
(
"search 未检测到人脸"
);
return
;
}
...
...
@@ -227,11 +227,11 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v
HInt32
featureNum
;
HF_GetFeatureLength
(
ctxHandle
,
&
featureNum
);
for
(
int
j
=
0
;
j
<
multipleFaceData
.
detectedNum
;
++
j
){
q
Debug
()
<<
QString
(
"doesItExistEmployee==>面部索引: %1"
).
arg
(
j
);
q
Info
()
<<
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
)
{
q
Debug
()
<<
QString
(
"特征提取出错: %1"
).
arg
(
ret
);
q
Info
()
<<
QString
(
"特征提取出错: %1"
).
arg
(
ret
);
HF_ReleaseImageStream
(
imageSteamHandle
);
return
;
}
...
...
@@ -252,9 +252,9 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v
return
;
}
q
Debug
()
<<
QString
(
"搜索置信度: %1"
).
arg
(
confidence
);
q
Debug
()
<<
QString
(
"匹配到的tag: %1"
).
arg
(
searchIdentity
.
tag
);
q
Debug
()
<<
QString
(
"匹配到的customId: %1"
).
arg
(
searchIdentity
.
customId
);
q
Info
()
<<
QString
(
"搜索置信度: %1"
).
arg
(
confidence
);
q
Info
()
<<
QString
(
"匹配到的tag: %1"
).
arg
(
searchIdentity
.
tag
);
q
Info
()
<<
QString
(
"匹配到的customId: %1"
).
arg
(
searchIdentity
.
customId
);
// Face Pipeline
//printf("人脸特征数量: %d", faceNum);
if
(
confidence
>
configConfidence
)
{
...
...
VidesData.h
View file @
22f4b088
...
...
@@ -391,7 +391,7 @@ inline QString getDefaultGateway() {
return
gateway
;
}
inline
bool
pingAddress
(
const
QString
&
address
)
{
bool
pingAddress
(
const
QString
&
address
)
{
QProcess
process
;
QString
program
=
"ping"
;
QStringList
arguments
;
...
...
@@ -407,21 +407,28 @@ inline bool pingAddress(const QString &address) {
return
false
;
}
if
(
!
process
.
waitForFinished
(
1000
))
{
// 使用较长的超时值,确保进程有足够时间完成
if
(
!
process
.
waitForFinished
(
3000
))
{
process
.
kill
();
// 如果超时,强制终止进程
return
false
;
}
QString
output
(
process
.
readAllStandardOutput
());
// 此处可以使用更复杂的逻辑来解析 Ping 输出
// 简单的 Ping 成功检查逻辑
#ifdef Q_OS_WIN
return
output
.
contains
(
"TTL="
);
#else
return
output
.
contains
(
"1 packets transmitted, 1 received"
);
#endif
}
inline
int
GetCpuIdByAsm_arm
(
char
*
cpu_id
)
{
FILE
*
fp
=
fopen
(
"/proc/cpuinfo"
,
"r"
);
if
(
nullptr
==
fp
)
{
q
Debug
()
<<
"failed to open cpuinfo"
;
q
Info
()
<<
"failed to open cpuinfo"
;
return
-
1
;
}
...
...
@@ -457,7 +464,7 @@ inline int GetCpuIdByAsm_arm(char* cpu_id)
inline
QString
getCpuSerialNumber
()
{
QFile
file
(
"/proc/cpuinfo"
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
q
Debug
()
<<
"无法打开 /proc/cpuinfo 文件"
;
q
Info
()
<<
"无法打开 /proc/cpuinfo 文件"
;
return
QString
();
}
QTextStream
in
(
&
file
);
...
...
mainwindow.cpp
View file @
22f4b088
...
...
@@ -124,7 +124,7 @@ MainWindow::MainWindow()
if
(
!
server
.
listen
(
QHostAddress
::
Any
,
port
))
{
qInfo
()
<<
"Error: Unable to start the server on port 12345"
;
}
else
{
q
Debug
()
<<
"Server started, listening on port 12345"
;
q
Info
()
<<
"Server started, listening on port 12345"
;
}
config
.
mqttConfig
.
clientId
=
serialNumber
;
...
...
@@ -253,7 +253,7 @@ void MainWindow::handleMatNewConnection(){
QRegExp
urlRegEx
(
"GET /cameras/([^/]+)/current_image HTTP"
);
if
(
urlRegEx
.
indexIn
(
request
)
!=
-
1
)
{
QString
sn
=
urlRegEx
.
cap
(
1
);
q
Debug
()
<<
"Requested Camera SN: "
<<
sn
;
q
Info
()
<<
"Requested Camera SN: "
<<
sn
;
bool
foundCamera
=
false
;
for
(
auto
it
=
faceDetectionParkingPushs
.
begin
();
it
!=
faceDetectionParkingPushs
.
end
();
++
it
)
{
QString
currentSn
=
it
->
second
->
getSSn
();
...
...
@@ -307,7 +307,7 @@ void MainWindow::removeImageFiles(QString id){
QString
value
=
localIt
->
second
;
QFile
file
(
value
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
q
Debug
()
<<
"removeImageFiles open fail"
<<
value
;
q
Info
()
<<
"removeImageFiles open fail"
<<
value
;
}
else
{
file
.
remove
();
}
...
...
@@ -370,7 +370,7 @@ void MainWindow::updateLocalFace(const QString &httpurl) {
if
(
localIt
!=
localImageMap
.
end
())
{
QFile
file
(
localIt
->
second
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
q
Debug
()
<<
"open fail"
<<
localIt
->
second
;
q
Info
()
<<
"open fail"
<<
localIt
->
second
;
}
else
{
file
.
remove
();
qSetting
->
beginGroup
(
"localImageMap"
);
...
...
@@ -716,14 +716,14 @@ void MainWindow::initEncodeToString(QString &enCodeJson) {
}
bool
MainWindow
::
iniWorkSpVMn
(
vides_data
::
responseGb28181
*
gb28181
,
QString
&
workSpWMn
,
QString
&
sn
){
q
Debug
()
<<
"iniWorkSpVMn=="
<<
sn
;
q
Info
()
<<
"iniWorkSpVMn=="
<<
sn
;
QString
jsonfile
=
QCoreApplication
::
applicationDirPath
()
+
"/camera_config.json"
;
bool
isEqual
=
true
;
// 读取 JSON 配置文件
QFile
file
(
jsonfile
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
q
Debug
()
<<
"Failed to open the camera_config.json"
;
q
Info
()
<<
"Failed to open the camera_config.json"
;
return
isEqual
;
}
QJsonObject
toJsonObject
;
...
...
@@ -975,7 +975,7 @@ void MainWindow::initCameras(vides_data::cameraParameters ¶meter,vides_data:
CameraHandle
*
cameraHandle
=
new
CameraHandle
(
parameter
.
sDevId
,
parameter
.
httpUrl
,
parameter
.
sSn
,
parameter
.
channel
,
image_save
,
heightReference
,
devConfig
);
int
sdk_handle
=
cameraHandle
->
sdkDevLoginSyn
(
parameter
.
sDevId
,
parameter
.
nDevPort
,
parameter
.
sUserName
,
parameter
.
sPassword
,
3000
);
q
Debug
()
<<
"句柄为2:"
<<
sdk_handle
;
q
Info
()
<<
"句柄为2:"
<<
sdk_handle
;
if
(
sdk_handle
<=
0
){
qInfo
()
<<
"登录失败"
;
return
;
...
...
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