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
4b67a9ac
Commit
4b67a9ac
authored
Apr 16, 2024
by
liusq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增绿牌,蓝牌长度限制和信号自动析构
parent
f5c6f1e3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
90 additions
and
43 deletions
+90
-43
CameraHandle.cpp
+0
-0
CameraHandle.h
+7
-8
Common.cpp
+13
-0
Common.h
+7
-0
FaceRecognition.h
+1
-2
FaceReconition.cpp
+5
-7
HumanDetection.cpp
+1
-0
LicensePlateRecognition.cpp
+1
-0
ScopeSemaphoreExit.cpp
+8
-0
ScopeSemaphoreExit.h
+15
-0
VidesData.h
+1
-0
gamera_videos.pro
+4
-2
mainwindow.cpp
+25
-23
mainwindow.h
+2
-1
No files found.
CameraHandle.cpp
View file @
4b67a9ac
This diff is collapsed.
Click to expand it.
CameraHandle.h
View file @
4b67a9ac
...
...
@@ -21,6 +21,7 @@
#include <QDateTime>
#include <QJsonDocument>
#include <memory>
#include <functional>
#include <QString>
#include <QObject>
#include <QTimer>
...
...
@@ -28,9 +29,7 @@
#include <QQueue>
#include <opencv2/opencv.hpp>
#include <QSemaphore>
#include <atomic>
enum
CAR_INFORMATION
{
Exit
,
//出场
Mobilization
,
//进场
...
...
@@ -54,7 +53,7 @@ public:
void
clearCameraHandle
();
// void rebindTimer(int hDevice);
void
initSdkRealTimeDevSnapSyn
(
int
hDevice
,
int
syn_timer
);
void
initSdkRealTimeDevSnapSyn
(
int
hDevice
,
int
syn_timer
,
uint64
face_frequency
);
void
updateImage
(
const
cv
::
Mat
&
frame
,
qint64
currentTime
);
...
...
@@ -79,7 +78,6 @@ public:
QString
startTimer
,
QString
endTime
);
void
setTimeoutMs
(
int
timeoutMs
);
bool
acquireAndReleaseWithTimeout
(
bool
flag
);
QString
getSSn
();
...
...
@@ -110,10 +108,11 @@ signals:
void
callbackFrameReady
(
const
cv
::
Mat
&
frame
,
const
QString
&
url
);
void
afterDownloadFile
(
int
id
,
int
recognitionType
,
QString
ossUrl
);
private
slots
:
void
sdkRealTimeDevSnapSyn
(
int
hDevice
);
void
pushRecordToCloud
(
int
id
,
int
recognitionType
,
QString
ossUrl
);
void
releaseSemaphore
();
//
void releaseSemaphore();
private
:
int
hDevice
;
...
...
@@ -143,8 +142,6 @@ private :
//2秒钟抓一次图
QTimer
*
dev_snap_syn_timer
;
QTimer
*
release_timer
;
int
offlineCount
=
0
;
TCV_HumanDetector
*
detector
;
...
...
@@ -156,7 +153,9 @@ private :
int
timeoutMs
;
int
image_save
;
std
::
atomic
<
uint64
>
faceCount
;
uint64
face_frequency
;
};
...
...
Common.cpp
View file @
4b67a9ac
...
...
@@ -63,6 +63,19 @@ void Common::setImages(QString images){
this
->
images
=
images
;
}
float
Common
::
getCarConfidenceMax
()
const
{
return
carConfidenceMax
;
}
void
Common
::
setCarConfidenceMax
(
float
carConfidenceMax
){
this
->
carConfidenceMax
=
carConfidenceMax
;
}
float
Common
::
getCarConfidenceMin
()
const
{
return
carConfidenceMin
;
}
void
Common
::
setCarConfidenceMin
(
float
carConfidenceMin
){
this
->
carConfidenceMin
=
carConfidenceMin
;
}
QString
Common
::
GetLocalIp
()
{
QString
ipAddress
;
QList
<
QHostAddress
>
list
=
QNetworkInterface
::
allAddresses
();
...
...
Common.h
View file @
4b67a9ac
...
...
@@ -44,6 +44,11 @@ public:
QString
GetLocalIp
();
float
getCarConfidenceMax
()
const
;
void
setCarConfidenceMax
(
float
carConfidenceMax
);
float
getCarConfidenceMin
()
const
;
void
setCarConfidenceMin
(
float
carConfidenceMin
);
template
<
typename
T
>
void
deleteObj
(
T
*&
obj
)
{
...
...
@@ -57,6 +62,8 @@ private:
QString
videoOut
;
QString
videoDownload
;
QString
images
;
float
carConfidenceMax
;
float
carConfidenceMin
;
Common
();
~
Common
();
...
...
FaceRecognition.h
View file @
4b67a9ac
...
...
@@ -6,14 +6,13 @@
#include "herror.h"
#include "LogHandle.h"
#include "VidesData.h"
#include <mutex>
class
FaceReconition
{
private
:
static
FaceReconition
*
instance
;
HContextHandle
ctxHandle
;
HContextHandle
ctxHandle
=
nullptr
;
float
configConfidence
;
...
...
FaceReconition.cpp
View file @
4b67a9ac
#include "FaceRecognition.h"
#include <QThread>
FaceReconition
::
FaceReconition
()
{}
...
...
@@ -23,23 +25,21 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con
QString
bPath
=
QCoreApplication
::
applicationDirPath
()
+
"/model_zip/T1_5"
;
#else
#error "不支持的架构"
#endif
QByteArray
&&
bypath
=
bPath
.
toUtf8
();
char
*
spath
=
bypath
.
data
();
HString
path
=
spath
;
HInt32
option
=
HF_ENABLE_QUALITY
|
HF_ENABLE_FACE_RECOGNITION
|
HF_ENABLE_MASK_DETECT
;
HF_DetectMode
detMode
=
HF_DETECT_MODE_IMAGE
;
// 选择图像模式 即总是检测
if
(
ctxHandle
==
nullptr
){
// 创建ctx
ret
=
HF_CreateFaceContextFromResourceFileOptional
(
path
,
option
,
detMode
,
5
,
&
ctxHandle
);
if
(
ret
!=
HSUCCEED
)
{
qInfo
()
<<
QString
(
"Create ctx error: %1"
).
arg
(
ret
);
return
;
}
// ret = HF_FaceRecognitionThresholdSetting(ctxHandle, 0.36);
// if (ret != HSUCCEED) {
// qInfo() << QString("HF_FaceRecognitionThresholdSetting error: %1").arg(ret);
// return;
// }
}
customIds
.
clear
();
int
i
=
0
;
for
(
auto
it
=
maps
.
begin
();
it
!=
maps
.
end
();
++
it
,
++
i
)
{
...
...
@@ -118,8 +118,6 @@ int FaceReconition::featureRemove(){
HResult
ret
=
HF_FeaturesGroupFeatureRemove
(
ctxHandle
,
customId
);
qDebug
()
<<
"ret:featureRemove "
<<
ret
;
}
HF_ReleaseFaceContext
(
ctxHandle
);
}
}
void
FaceReconition
::
doesItExistEmployee
(
const
cv
::
Mat
&
source
,
std
::
list
<
vides_data
::
faceRecognitionResult
>&
faces
){
...
...
HumanDetection.cpp
View file @
4b67a9ac
...
...
@@ -18,6 +18,7 @@ int HumanDetection::findHuManCar(const cv::Mat &source,int res,TCV_HumanDetector
int
num
=
(
res
==
0
)
?
TCV_HumanDetectorGetNumOfHuman
(
detector
)
:
TCV_HumanDetectorGetNumOfCar
(
detector
);
qDebug
()
<<
(
res
==
0
?
"Number of people detected:"
:
"Number of cars detected:"
)
<<
num
;
TCV_ReleaseCameraStream
(
stream
);
return
num
;
}
LicensePlateRecognition.cpp
View file @
4b67a9ac
...
...
@@ -131,6 +131,7 @@ void LicensePlateRecognition::licensePlateNumber(const cv::Mat &source, QString
newPlate
.
time
=
currentTime
;
newPlate
.
new_color
=
QString
::
fromStdString
(
type
);
newPlate
.
new_plate
=
QString
::
fromUtf8
(
results
.
plates
[
i
].
code
);
newPlate
.
text_confidence
=
results
.
plates
[
i
].
text_confidence
;
vides_data
::
ParkingArea
area
;
area
.
topLeftCornerX
=
results
.
plates
[
i
].
x1
;
area
.
topLeftCornerY
=
results
.
plates
[
i
].
y1
;
...
...
ScopeSemaphoreExit.cpp
0 → 100644
View file @
4b67a9ac
#include "ScopeSemaphoreExit.h"
ScopeSemaphoreExit
::
ScopeSemaphoreExit
(
std
::
function
<
void
()
>
onExit
)
:
onExit_
(
onExit
)
{}
ScopeSemaphoreExit
::~
ScopeSemaphoreExit
()
{
if
(
onExit_
)
onExit_
();
}
ScopeSemaphoreExit.h
0 → 100644
View file @
4b67a9ac
#ifndef SCOPESEMAPHOREEXIT_H
#define SCOPESEMAPHOREEXIT_H
#include <functional>
class
ScopeSemaphoreExit
{
public
:
explicit
ScopeSemaphoreExit
(
std
::
function
<
void
()
>
onExit
);
~
ScopeSemaphoreExit
();
private
:
std
::
function
<
void
()
>
onExit_
;
};
#endif // SCOPESEMAPHOREEXIT_H
VidesData.h
View file @
4b67a9ac
...
...
@@ -133,6 +133,7 @@ struct LicensePlate
QByteArray
img
;
qint64
time
;
ParkingArea
recognition
;
float
text_confidence
;
LicensePlate
()
{}
};
...
...
gamera_videos.pro
View file @
4b67a9ac
...
...
@@ -93,7 +93,8 @@ SOURCES += \
TaskRunnable
.
cpp
\
CameraHandle
.
cpp
\
ParkingSpaceInfo
.
cpp
\
HumanDetection
.
cpp
HumanDetection
.
cpp
\
ScopeSemaphoreExit
.
cpp
HEADERS
+=
\
Common
.
h
\
...
...
@@ -109,7 +110,8 @@ HEADERS += \
TaskRunnable
.
h
\
CameraHandle
.
h
\
ParkingSpaceInfo
.
h
\
HumanDetection
.
h
HumanDetection
.
h
\
ScopeSemaphoreExit
.
h
#FORMS += \
# mainwindow.ui
...
...
mainwindow.cpp
View file @
4b67a9ac
...
...
@@ -15,7 +15,7 @@ MainWindow::MainWindow()
modelPaths
=
qSetting
->
value
(
"licensePlateRecognition/model_paths"
).
toString
();
init
VideoOutPath
();
init
Common
();
deleteLogFileTimer
=
new
QTimer
(
this
);
connect
(
deleteLogFileTimer
,
&
QTimer
::
timeout
,
this
,
&
MainWindow
::
deleteLogFile
);
...
...
@@ -306,13 +306,23 @@ void MainWindow::startCamera(const QString &httpurl){
// QString serialNumber = QSysInfo::machineUniqueId();
QString
serialNumber
;
findLocalSerialNumber
(
serialNumber
);
vides_data
::
requestDeviceStatus
reStatus
;
reStatus
.
sSn
=
serialNumber
;
reStatus
.
status
=
1
;
reStatus
.
type
=
1
;
reStatus
.
ip_addr
=
instace
.
GetLocalIp
();
HttpService
httpService
(
httpurl
);
vides_data
::
response
*
re
=
httpService
.
httpFindCameras
(
serialNumber
,
devices
);
if
(
re
->
code
==
0
){
if
(
devices
.
list
.
size
()
<=
0
){
instace
.
deleteObj
(
re
);
return
;
vides_data
::
response
*
res
=
httpService
.
httpPostDeviceStatus
(
reStatus
);
if
(
res
->
code
!=
0
){
qInfo
()
<<
"盒子状态上报失败 code:"
<<
res
->
code
<<
"msg:"
<<
res
->
data
;
}
instace
.
deleteObj
(
res
);
httpService
.
setHttpUrl
(
httpurl
);
vides_data
::
response
*
re
=
httpService
.
httpFindCameras
(
serialNumber
,
devices
);
if
(
re
->
code
==
0
||
re
->
code
==
20004
){
QString
username
=
qSetting
->
value
(
"devices/username"
).
toString
();
QString
password
=
qSetting
->
value
(
"devices/password"
).
toString
();
std
::
map
<
QString
,
vides_data
::
localDeviceStatus
*>
localDevices
;
...
...
@@ -363,23 +373,9 @@ void MainWindow::startCamera(const QString &httpurl){
// 清空 localDevices 容器
localDevices
.
clear
();
}
vides_data
::
requestDeviceStatus
reStatus
;
reStatus
.
sSn
=
serialNumber
;
reStatus
.
status
=
1
;
reStatus
.
type
=
1
;
reStatus
.
ip_addr
=
instace
.
GetLocalIp
();
qDebug
()
<<
"local.ip_addr===>"
<<
reStatus
.
ip_addr
;
httpService
.
setHttpUrl
(
httpurl
);
qDebug
()
<<
"httpurl===>"
<<
httpurl
;
qDebug
()
<<
"serialNumber===>"
<<
serialNumber
;
vides_data
::
response
*
res
=
httpService
.
httpPostDeviceStatus
(
reStatus
);
if
(
res
->
code
!=
0
){
qInfo
()
<<
"盒子状态上报失败 code:"
<<
res
->
code
<<
"msg:"
<<
res
->
data
;
}
updateLocalFace
(
httpurl
);
instace
.
deleteObj
(
re
);
instace
.
deleteObj
(
res
);
}
...
...
@@ -718,7 +714,9 @@ void MainWindow::initCameras(vides_data::cameraParameters ¶meter,const std::
cameraHandle
->
sdkDevSetAlarmListener
(
sdk_handle
,
1
);
int
synTime
=
qSetting
->
value
(
"timer/dev_snap_syn_timer"
).
toInt
();
cameraHandle
->
initSdkRealTimeDevSnapSyn
(
sdk_handle
,
synTime
);
uint64
face_frequency
=
qSetting
->
value
(
"devices/face_frequency"
).
toULongLong
();
cameraHandle
->
initSdkRealTimeDevSnapSyn
(
sdk_handle
,
synTime
,
face_frequency
);
int
seTime
=
qSetting
->
value
(
"timer/semaphore_time"
).
toInt
();
cameraHandle
->
setTimeoutMs
(
seTime
);
cameraHandle
->
initParkingSpaceInfo
(
areas
);
...
...
@@ -777,11 +775,15 @@ void MainWindow::createDirectory(int flag,const QString& dirName, const QString&
}
}
void
MainWindow
::
init
VideoOutPath
(){
void
MainWindow
::
init
Common
(){
createDirectory
(
0x01
,
"frame_images"
,
"目录创建成功"
,
"目录创建失败"
);
createDirectory
(
0x00
,
"frame_video"
,
"创建视频目录成功"
,
"视频目录创建失败"
);
createDirectory
(
0x02
,
"images"
,
"图片目录创建成功"
,
"图片目录创建失败"
);
float
carConfidenceMax
=
qSetting
->
value
(
"devices/carConfidenceMax"
).
toFloat
();
float
carConfidenceMin
=
qSetting
->
value
(
"devices/carConfidenceMin"
).
toFloat
();
Common
&
instance
=
Common
::
getInstance
();
instance
.
setCarConfidenceMax
(
carConfidenceMax
);
instance
.
setCarConfidenceMin
(
carConfidenceMin
);
}
MainWindow
::~
MainWindow
()
...
...
mainwindow.h
View file @
4b67a9ac
...
...
@@ -34,12 +34,13 @@ class MainWindow : public QObject
public
:
explicit
MainWindow
();
void
init
VideoOutPath
();
void
init
Common
();
void
setVideoPath
(
int
flag
,
const
QString
&
path
);
void
createDirectory
(
int
flag
,
const
QString
&
dirName
,
const
QString
&
successMsg
,
const
QString
&
failureMsg
);
void
initFaceFaceRecognition
();
void
initCameras
(
vides_data
::
cameraParameters
&
parameter
,
const
std
::
list
<
vides_data
::
responseArea
>&
areas
);
...
...
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