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
0
Merge Requests
0
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
5fe7062a
Commit
5fe7062a
authored
Jun 17, 2024
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加算法过滤和mark区域
parent
476b9ed9
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
825 additions
and
355 deletions
+825
-355
CameraHandle.cpp
+428
-227
CameraHandle.h
+37
-18
Common.h
+2
-2
FaceReconition.cpp
+1
-0
HttpService.cpp
+38
-28
HttpService.h
+3
-2
HumanDetection.cpp
+203
-25
HumanDetection.h
+7
-2
LicensePlateRecognition.cpp
+27
-2
LicensePlateRecognition.h
+5
-3
MediaFaceImage.cpp
+1
-1
ParkingSpaceInfo.h
+3
-0
VidesData.h
+6
-1
gamera_videos.pro
+41
-40
mainwindow.cpp
+22
-3
mainwindow.h
+1
-1
No files found.
CameraHandle.cpp
View file @
5fe7062a
...
...
@@ -6,7 +6,8 @@
CameraHandle
::
CameraHandle
(){
}
CameraHandle
::
CameraHandle
(
QString
&
url
,
QString
&
httpUrl
,
QString
&
sSn
,
int
&
channel
,
const
QString
&
modelPaths
,
float
carConfidence
,
int
imageSave
)
CameraHandle
::
CameraHandle
(
QString
&
url
,
QString
&
httpUrl
,
QString
&
sSn
,
int
&
channel
,
const
QString
&
modelPaths
,
float
carConfidence
,
float
carShapeConfidence
,
int
imageSave
)
:
hDevice
(
-
1
),
url
(
url
),
loginParam
(
new
SXSDKLoginParam
()),
...
...
@@ -16,13 +17,16 @@ CameraHandle::CameraHandle(QString &url, QString &httpUrl, QString &sSn, int &ch
httpUrl
(
httpUrl
),
dev_snap_syn_timer
(
new
QTimer
()),
image_save
(
imageSave
),
faceCount
(
0
),
semaphore
(
1
)
{
connect
(
this
,
SIGNAL
(
afterDownloadFile
(
int
,
int
,
QString
)),
this
,
SLOT
(
pushRecordToCloud
(
int
,
int
,
QString
)),
Qt
::
QueuedConnection
);
detector
=
TCV_CreateHumanDetector
(
1
);
faceMapWorker
.
setX
(
0
);
faceMapWorker
.
setY
(
0
);
TCV_HumanDetectorSetHumanThreshold
(
detector
,
0.5
f
);
TCV_HumanDetectorSetCarThreshold
(
detector
,
0.2
f
);
TCV_HumanDetectorSetCarThreshold
(
detector
,
carShapeConfidence
);
HLPR_ContextConfiguration
configuration
=
{
0
};
QByteArray
&&
by_mpath
=
modelPaths
.
toUtf8
();
char
*
m_path
=
by_mpath
.
data
();
...
...
@@ -54,7 +58,7 @@ CameraHandle::~CameraHandle() {
instace
.
deleteObj
(
iter
->
second
);
}
parkMap
.
clear
();
}
...
...
@@ -86,6 +90,11 @@ int CameraHandle::sdkDevLoginSyn(QString sDevId, int nDevPort, QString sUserName
this
->
hDevice
=
loginResult
;
return
loginResult
;
}
void
CameraHandle
::
initAlgorithmParameter
(
float
&
height_reference
){
HumanDetection
&
humanDetection
=
HumanDetection
::
getInstance
();
humanDetection
.
setHeightReference
(
height_reference
);
}
int
XNetSDK_MediaCallBack
(
XSDK_HANDLE
hMedia
,
int
nDataType
,
int
nDataLen
,
int
nParam2
,
int
nParam3
,
const
char
*
szString
,
void
*
pData
,
int64
pDataInfo
,
int
nSeq
,
void
*
pUserData
,
void
*
pMsg
){
CameraHandle
*
cameraHandle
=
static_cast
<
CameraHandle
*>
(
pUserData
);
std
::
map
<
QString
,
QString
>
&
data
=
cameraHandle
->
getCurrentData
();
...
...
@@ -250,16 +259,15 @@ void CameraHandle::initSdkRealTimeDevSnapSyn(int hDevice,int syn_timer,uint64 fa
}
void
CameraHandle
::
sdkRealTimeDevSnapSyn
(
int
hDevice
)
{
QThreadPool
*
threadPool
=
QThreadPool
::
globalInstance
();
threadPool
->
setMaxThreadCount
(
8
);
auto
taskSyn
=
std
::
bind
(
&
CameraHandle
::
sdkDevSnapSyn
,
this
,
hDevice
,
this
->
channel
);
threadPool
->
setMaxThreadCount
(
12
);
//auto taskSyn = std::bind(&CameraHandle::sdkDevSnapSyn, this, hDevice, this->channel);
auto
taskSyn
=
[
this
,
hDevice
]()
{
sdkDevSnapSyn
(
hDevice
,
this
->
channel
);
};
auto
taskRunnable
=
new
TaskRunnable
(
taskSyn
,
hDevice
,
this
->
channel
,
RunFunction
::
SdkDevSnapSyn
);
threadPool
->
start
(
taskRunnable
);
}
QString
CameraHandle
::
getSSn
(){
return
sSn
;
...
...
@@ -271,10 +279,6 @@ void CameraHandle::setMediaHandle(int mediaHandle){
this
->
mediaHandle
=
mediaHandle
;
}
void
CameraHandle
::
setCurrentFace
(
int
currentFace
){
std
::
lock_guard
<
std
::
mutex
>
guard
(
faceMutex
);
this
->
currentFace
=
currentFace
;
}
std
::
map
<
QString
,
QString
>&
CameraHandle
::
getCurrentData
(){
return
currentData
;
}
...
...
@@ -327,6 +331,7 @@ void CameraHandle::sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id,
}
int
CameraHandle
::
callbackFunction
(
XSDK_HANDLE
hObject
,
QString
&
szString
)
{
if
(
stopRequested_
)
return
-
1
;
if
(
!
semaphore
.
tryAcquire
())
{
qInfo
()
<<
"sdkDevSnapSyn:正在执行线程"
;
return
-
1
;
...
...
@@ -366,6 +371,7 @@ int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
qInfo
()
<<
"图像尺寸或通道数不正确,需排查原因"
;
return
-
1
;
}
qDebug
()
<<
"callbackFunction request to: "
<<
sSn
;
updateImage
(
image
,
currentTime
);
}
...
...
@@ -424,7 +430,7 @@ void CameraHandle::matToBase64(const cv::Mat &image, QByteArray &base64Data) {
base64Data
=
QByteArray
(
reinterpret_cast
<
const
char
*>
(
buffer
.
data
()),
buffer
.
size
()).
toBase64
();
}
void
CameraHandle
::
checkAndUpdateCurrentPlate
(
ParkingSpaceInfo
*
park
,
const
cv
::
Mat
&
frame
,
RecognizedInfo
&
newInfo
,
int
&
result
,
std
::
map
<
int
,
RecognizedInfo
>&
exitAndMoMap
){
int
&
result
){
if
(
newInfo
.
getLicensePlate
()
!=
park
->
getCurrentPlate
().
getLicensePlate
())
{
int
count
=
0
;
for
(
auto
&
info
:
park
->
getQueue
())
{
...
...
@@ -432,35 +438,41 @@ void CameraHandle::checkAndUpdateCurrentPlate(ParkingSpaceInfo*park,const cv::Ma
count
++
;
}
}
qDebug
()
<<
"最新车牌"
<<
newInfo
.
getLicensePlate
()
<<
"区域当前车牌"
<<
park
->
getCurrentPlate
().
getLicensePlate
();
qDebug
()
<<
"不同的区域:"
<<
park
->
getSpaceIndex
()
<<
",数量:"
<<
count
;
if
(
count
>=
3
)
{
if
(
count
>=
3
)
{
//第一次进场 当前车牌就是进来这个,老车牌就是空
if
(
park
->
getCurrentPlate
().
getLicensePlate
().
length
()
<=
0
){
//进场
park
->
setCurrentPlate
(
newInfo
);
result
=
Mobilization
;
}
else
{
//当前为空,
立
场
//当前为空,
离
场
if
(
newInfo
.
getLicensePlate
().
length
()
<=
0
){
HumanDetection
&
humanDetection
=
HumanDetection
::
getInstance
();
int
car_size
=
humanDetection
.
findHuManCar
(
frame
,
0x01
,
detector
);
std
::
vector
<
vides_data
::
ParkingArea
>
currentPlates
;
int
car_size
=
humanDetection
.
findHuManCar
(
frame
,
0x01
,
detector
,
currentPlates
);
qDebug
()
<<
sSn
<<
":"
<<
"当前车形数量:"
<<
car_size
;
if
(
car_size
<=
0
){
//出场
if
(
car_size
<=
0
)
{
qDebug
()
<<
sSn
<<
"区域:"
<<
park
->
getSpaceIndex
()
<<
": 出场:"
;
//如果有车辆检测到并且不在停车区域内部,视为出场
park
->
setCurrentPlate
(
newInfo
);
result
=
Exit
;
}
else
{
park
->
removeNoQueue
();
qDebug
()
<<
sSn
<<
":"
<<
"no出场:"
<<
car_size
;
result
=
Exit
;
}
else
{
// 没有车辆或车辆在停车区域内部,移除队列
park
->
removeNoQueue
();
qDebug
()
<<
sSn
<<
": no出场:"
<<
car_size
;
}
}
else
{
qDebug
()
<<
sSn
<<
":"
<<
"出场:"
<<
2
;
qDebug
()
<<
sSn
<<
":"
<<
"老车出场:"
<<
park
->
getCurrentPlate
().
getLicensePlate
();
qDebug
()
<<
sSn
<<
":"
<<
"老车出场:"
<<
park
->
getCurrentPlate
().
getLicensePlate
();
qDebug
()
<<
sSn
<<
":"
<<
"新车入场:"
<<
newInfo
.
getLicensePlate
();
//当前不为空,新车,新车入场,老车出场
exitAndMoMap
[
Exit
]
=
park
->
getCurrentPlate
();
exitAndMoMap
[
Mobilization
]
=
newInfo
;
//
exitAndMoMap[Exit]=park->getCurrentPlate();
//
exitAndMoMap[Mobilization]=newInfo;
park
->
setCurrentPlate
(
newInfo
);
result
=
ExitAndMobilization
;
}
...
...
@@ -470,17 +482,58 @@ void CameraHandle::checkAndUpdateCurrentPlate(ParkingSpaceInfo*park,const cv::Ma
}
void
CameraHandle
::
batchRegionalPushLicensePlate
(
QByteArray
&
imgs
,
qint64
currentTime
,
vides_data
::
requestLicensePlate
&
newPlate
){
for
(
auto
it
=
parkMap
.
begin
();
it
!=
parkMap
.
end
();
++
it
)
{
ParkingSpaceInfo
*
value
=
it
->
second
;
// 获取对应的值(ParkingSpaceInfo指针)
vides_data
::
LicensePlate
plates
;
plates
.
time
=
currentTime
;
plates
.
img
=
imgs
;
plates
.
areaLocation
=
value
->
getArea
();
newPlate
.
plates
.
push_back
(
plates
);
}
}
void
CameraHandle
::
matToAreaMask
(
const
cv
::
Mat
&
source
,
std
::
map
<
int
,
cv
::
Mat
>
&
maskFrame
)
{
for
(
auto
iter
=
parkMap
.
begin
();
iter
!=
parkMap
.
end
();
++
iter
)
{
int
id
=
iter
->
first
;
ParkingSpaceInfo
*
parkArea
=
iter
->
second
;
// 转换浮点坐标为整型坐标
std
::
vector
<
cv
::
Point
>
parkAreaPoints
=
{
cv
::
Point
(
static_cast
<
int
>
(
parkArea
->
getArea
().
topLeftCornerX
),
static_cast
<
int
>
(
parkArea
->
getArea
().
topLeftCornerY
)),
cv
::
Point
(
static_cast
<
int
>
(
parkArea
->
getArea
().
topRightCornerX
),
static_cast
<
int
>
(
parkArea
->
getArea
().
topRightCornerY
)),
cv
::
Point
(
static_cast
<
int
>
(
parkArea
->
getArea
().
bottomRightCornerX
),
static_cast
<
int
>
(
parkArea
->
getArea
().
bottomRightCornerY
)),
cv
::
Point
(
static_cast
<
int
>
(
parkArea
->
getArea
().
bottomLeftCornerX
),
static_cast
<
int
>
(
parkArea
->
getArea
().
bottomLeftCornerY
))
};
// 创建与source相同大小的掩码图像,并用黑色填充
cv
::
Mat
mask
=
cv
::
Mat
::
zeros
(
source
.
size
(),
CV_8UC1
);
// 使用fillPoly填充多边形到mask
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
parkAreas
=
{
parkAreaPoints
};
cv
::
fillPoly
(
mask
,
parkAreas
,
cv
::
Scalar
(
255
));
// 使用白色(255)填充指定的多边形区域
// 使用掩码从source中提取区域,同时保持原始大小
cv
::
Mat
maskedSource
=
cv
::
Mat
::
zeros
(
source
.
size
(),
source
.
type
());
source
.
copyTo
(
maskedSource
,
mask
);
// 将带有掩码的图像存入maskFrame
maskFrame
[
id
]
=
maskedSource
;
}
}
bool
CameraHandle
::
isChanged
(
const
QPoint
&
newInfo
,
const
QPoint
&
current
)
{
const
double
epsilon
=
1e-6
;
// 定义一个非常小的阈值
double
distance
=
std
::
sqrt
(
std
::
pow
(
newInfo
.
x
()
-
current
.
x
(),
2
)
+
std
::
pow
(
newInfo
.
y
()
-
current
.
y
(),
2
));
return
distance
>
epsilon
;
// 如果距离大于阈值,则认为发生了变化
}
void
CameraHandle
::
updateImage
(
const
cv
::
Mat
&
frame
,
qint64
currentTime
){
Common
&
instace
=
Common
::
getInstance
();
qDebug
()
<<
"=============================>"
;
static
int
i
=
0
;
printf
(
"updateImage%d次
\n
"
,
++
i
);
faceCount
.
fetch_add
(
1
,
std
::
memory_order_relaxed
);
qDebug
()
<<
"faceCount==>"
<<
faceCount
.
load
(
std
::
memory_order_relaxed
);
int
width
=
frame
.
cols
;
// 获取图像宽度
int
height
=
frame
.
rows
;
// 获取图像高度
qDebug
()
<<
"frame 宽度:"
<<
width
<<
"frame 高度:"
<<
height
;
...
...
@@ -488,43 +541,42 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
HumanDetection
&
humanDetection
=
HumanDetection
::
getInstance
();
LicensePlateRecognition
&
licensePlateRecogn
=
LicensePlateRecognition
::
getInstance
();
static
int
ii
=
0
;
printf
(
"updateImage retryCount: %d
\n
"
,
++
ii
)
;
//faceRecognition.search(frame,imageHandleList,names);
std
::
map
<
QString
,
vides_data
::
requestFaceReconition
>
mapFaces
;
QByteArray
imgs
;
this
->
matToBase64
(
frame
,
imgs
);
HttpService
httpService
(
httpUrl
);
int
faSize
=
0
;
std
::
vector
<
vides_data
::
ParkingArea
>
currentPlates
;
int
uniforms
=
0x00
;
if
((
algorithmPermissions
&
0x01
<<
2
)
!=
0
)
{
uniforms
=
humanDetection
.
findHuManCar
(
frame
,
0x02
,
detector
,
currentPlates
);
}
if
((
algorithmPermissions
&
0x01
<<
1
)
!=
0
)
{
faSize
=
humanDetection
.
findHuManCar
(
frame
,
0x00
,
detector
);
if
(
currentFace
!=
faSize
){
faSize
=
humanDetection
.
findHuManCar
(
frame
,
0x00
,
detector
,
currentPlates
);
QPoint
point_info
(
faSize
,
uniforms
);
if
(
isChanged
(
point_info
,
faceMapWorker
)
){
if
(
faceCount
.
load
(
std
::
memory_order_relaxed
)
%
face_frequency
==
0
){
vides_data
::
response
*
resp
=
httpService
.
httpPostFacePopulation
(
imgs
,
faSize
,
sSn
,
currentTime
)
;
if
(
resp
->
code
!=
0
)
{
qInfo
()
<<
"人数变化推送信息推送失败"
;
int
worker
=
0x00
;
if
(
(
algorithmPermissions
&
0x01
<<
2
)
!=
0
)
{
worker
=
(
faSize
-
uniforms
>
0
)
?
(
faSize
-
uniforms
)
:
0
;
}
instace
.
deleteObj
(
resp
);
currentFace
=
faSize
;
}
}
}
if
((
algorithmPermissions
&
0x01
<<
2
)
!=
0
)
{
int
uniforms
=
humanDetection
.
findHuManCar
(
frame
,
0x02
,
detector
);
if
(
uniforms
>
0
){
if
(
faceCount
.
load
(
std
::
memory_order_relaxed
)
%
face_frequency
==
0
){
httpService
.
setHttpUrl
(
httpUrl
);
vides_data
::
response
*
resp
=
httpService
.
httpPostUniforms
(
imgs
,
uniforms
,
sSn
,
currentTime
);
vides_data
::
response
*
resp
=
httpService
.
httpPostFacePopulation
(
imgs
,
faSize
,
worker
,
sSn
,
currentTime
);
if
(
resp
->
code
!=
0
)
{
qInfo
()
<<
"
推送未穿工服人数
失败"
;
qInfo
()
<<
"
人数变化推送信息推送
失败"
;
}
instace
.
deleteObj
(
resp
);
faceMapWorker
.
setX
(
faSize
);
faceMapWorker
.
setY
(
uniforms
);
}
}
}
if
(
faSize
>
0
){
qDebug
()
<<
"faceRecognition.doesItExistEmployee Current thread ID: "
<<
QThread
::
currentThreadId
();
qDebug
()
<<
"faceRecognition.doesItExistEmployee Current thread ID: "
<<
QThread
::
currentThreadId
()
<<
sSn
;
std
::
list
<
vides_data
::
faceRecognitionResult
>
faces
;
faceRecognition
.
doesItExistEmployee
(
frame
,
faces
);
if
(
faces
.
size
()
>
0
)
{
...
...
@@ -546,6 +598,7 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
httpService
.
setHttpUrl
(
httpUrl
);
vides_data
::
response
*
resp
=
httpService
.
httpPostFaceReconition
(
faceReconition
);
mapFaces
.
insert
(
std
::
make_pair
(
face
.
id
,
faceReconition
));
if
(
resp
->
code
!=
0
)
{
qInfo
()
<<
"识别人code"
<<
resp
->
code
;
qInfo
()
<<
"识别人msg"
<<
resp
->
msg
;
...
...
@@ -555,13 +608,27 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
}
}
}
if
((
algorithmPermissions
&
0x01
<<
2
)
!=
0
)
{
if
(
uniforms
>
0
){
//未穿工服的人数
std
::
list
<
QString
>
outUniforms
;
faceUniformOverlap
(
mapFaces
,
currentPlates
,
outUniforms
);
for
(
auto
strUniform
:
outUniforms
){
httpService
.
setHttpUrl
(
httpUrl
);
vides_data
::
response
*
resp
=
httpService
.
httpPostUniforms
(
imgs
,
strUniform
,
sSn
,
currentTime
);
if
(
resp
->
code
!=
0
)
{
qInfo
()
<<
"推送未穿工服人数失败"
;
}
instace
.
deleteObj
(
resp
);
}
}
}
//关闭车牌识别
if
((
algorithmPermissions
&
0x01
)
==
0
)
{
return
;
}
QString
lpNumber
;
vides_data
::
requestLicensePlate
plate
;
plate
.
sn
=
sSn
;
// return ;
if
(
image_save
==
1
){
...
...
@@ -575,24 +642,77 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
}
}
std
::
map
<
int
,
cv
::
Mat
>
areaMat
;
matToAreaMask
(
frame
,
areaMat
);
if
(
image_save
==
2
){
for
(
auto
it
=
areaMat
.
begin
();
it
!=
areaMat
.
end
();
++
it
)
{
int
key
=
it
->
first
;
cv
::
Mat
areaMat
=
it
->
second
;
QString
fileName
=
instace
.
getVideoDownload
().
append
(
QString
::
number
(
key
)
+
".jpg"
);
bool
success
=
cv
::
imwrite
(
fileName
.
toStdString
(),
areaMat
);
if
(
success
)
{
qDebug
()
<<
"图片已成功保存至:"
<<
fileName
;
}
else
{
qDebug
()
<<
"图片保存失败!"
;
}
}
}
licensePlateRecogn
.
licensePlateNumber
(
frame
,
lpNumber
,
plate
,
currentTime
,
ctx
);
std
::
map
<
int
,
RecognizedInfo
>
exitMoMap
;
vides_data
::
requestLicensePlate
newPlate
;
newPlate
.
sn
=
sSn
;
qDebug
()
<<
QString
(
"sn==>%1,识别的车牌信息是:%2"
).
arg
(
sSn
).
arg
(
lpNumber
);
std
::
list
<
vides_data
::
LicensePlate
>
ps
=
plate
.
plates
;
int
res
=-
1
;
this
->
matToBase64
(
frame
,
imgs
);
if
(
ps
.
size
()
==
0
){
for
(
auto
it
=
parkMap
.
begin
();
it
!=
parkMap
.
end
();
++
it
)
{
ParkingSpaceInfo
*
value
=
it
->
second
;
// 获取值
uint64_t
countValue
=
faceCount
.
load
(
std
::
memory_order_relaxed
);
if
(
countValue
==
0
){
vides_data
::
requestLicensePlate
initPlate
;
initPlate
.
sn
=
sSn
;
licensePlateRecogn
.
licensePlateNumber
(
frame
,
lpNumber
,
initPlate
,
currentTime
,
ctx
);
if
(
initPlate
.
plates
.
size
()
==
0
){
batchRegionalPushLicensePlate
(
imgs
,
currentTime
,
initPlate
);
if
(
initPlate
.
plates
.
size
()
>
0
){
licensePlateRecognitionResults
(
initPlate
);
}
}
}
faceCount
.
fetch_add
(
1
,
std
::
memory_order_relaxed
);
qDebug
()
<<
"faceCount==>"
<<
faceCount
.
load
(
std
::
memory_order_relaxed
);
for
(
auto
it
=
areaMat
.
begin
();
it
!=
areaMat
.
end
();
++
it
)
{
int
key
=
it
->
first
;
cv
::
Mat
areaMat
=
it
->
second
;
std
::
map
<
int
,
ParkingSpaceInfo
*>::
iterator
parkAreaMap
=
parkMap
.
find
(
key
);
ParkingSpaceInfo
*
value
=
nullptr
;
if
(
parkAreaMap
!=
parkMap
.
end
())
{
value
=
parkAreaMap
->
second
;
// 成功找到,获取
}
else
{
qDebug
()
<<
sSn
<<
"==>区域不存在:"
<<
key
;
continue
;
}
vides_data
::
requestLicensePlate
resultPlate
;
resultPlate
.
sn
=
sSn
;
licensePlateRecogn
.
licensePlateNumber
(
areaMat
,
lpNumber
,
resultPlate
,
currentTime
,
ctx
);
std
::
list
<
vides_data
::
LicensePlate
>
ps
=
resultPlate
.
plates
;
qDebug
()
<<
QString
(
"sn==>%1,区域:%2识别的车牌信息是:%3"
).
arg
(
sSn
).
arg
(
key
).
arg
(
lpNumber
);
if
(
ps
.
size
()
==
0
){
int
res
=-
1
;
if
(
value
==
nullptr
){
continue
;
}
if
(
value
->
getQueue
().
size
()
>=
10
)
{
value
->
removeQueue
();
}
RecognizedInfo
recognizedInfo
(
lpNumber
,
QDateTime
::
currentSecsSinceEpoch
(),
"未知"
);
RecognizedInfo
recognizedInfo
(
""
,
QDateTime
::
currentSecsSinceEpoch
(),
"未知"
);
value
->
addQueue
(
recognizedInfo
);
this
->
checkAndUpdateCurrentPlate
(
value
,
frame
,
recognizedInfo
,
res
,
exitMoMap
);
// 使用value指向的ParkingSpaceInfo对象
this
->
checkAndUpdateCurrentPlate
(
value
,
areaMat
,
recognizedInfo
,
res
);
if
(
res
==
Exit
||
res
==
Mobilization
)
{
vides_data
::
LicensePlate
current
;
current
.
areaLocation
=
value
->
getArea
();
...
...
@@ -601,134 +721,93 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
current
.
new_plate
=
recognizedInfo
.
getLicensePlate
();
current
.
time
=
recognizedInfo
.
getRecognizeTime
();
newPlate
.
plates
.
push_back
(
std
::
move
(
current
));
qDebug
()
<<
QString
(
"当前进入ps.size()==0是当前校验返回结果是:%1"
).
arg
(
res
);
}
}
}
else
{
std
::
unordered_map
<
int
,
vides_data
::
LicensePlate
>
indexToLicensePlate
;
for
(
auto
it_ps
=
ps
.
begin
();
it_ps
!=
ps
.
end
();
++
it_ps
)
{
vides_data
::
LicensePlate
&
currentPlate
=
*
it_ps
;
ParkingSpaceInfo
newcurrentPlate
;
newcurrentPlate
.
setArea
(
currentPlate
.
recognition
);
int
index
=
this
->
findPointRegion
(
newcurrentPlate
);
qDebug
()
<<
sSn
<<
"==>识别的区域:"
<<
index
;
indexToLicensePlate
[
index
]
=
currentPlate
;
}
for
(
auto
it
=
parkMap
.
begin
();
it
!=
parkMap
.
end
();
++
it
)
{
int
key
=
it
->
first
;
ParkingSpaceInfo
*
value
=
it
->
second
;
// 获取值
if
(
indexToLicensePlate
.
count
(
key
)
>
0
)
{
vides_data
::
LicensePlate
recognition
=
indexToLicensePlate
.
at
(
key
);
RecognizedInfo
recognizedInfo
;
if
(
recognition
.
new_color
==
"蓝牌"
&&
recognition
.
new_plate
.
length
()
!=
7
)
{
qDebug
()
<<
sSn
<<
"==>蓝牌车牌号:"
<<
recognition
.
new_plate
<<
"===>recognition.new_plate.length():"
<<
recognition
.
new_plate
.
length
();
continue
;
}
else
if
(
recognition
.
new_color
==
"绿牌新能源"
&&
recognition
.
new_plate
.
length
()
!=
8
)
{
qDebug
()
<<
sSn
<<
"==>绿牌车牌号:"
<<
recognition
.
new_plate
<<
"===>recognition.new_plate.length():"
<<
recognition
.
new_plate
.
length
();
continue
;
}
else
if
(
recognition
.
new_plate
.
length
()
<
7
)
{
qDebug
()
<<
sSn
<<
"==>非绿牌蓝牌车牌号:"
<<
recognition
.
new_plate
<<
"===>recognition.new_plate.length():"
<<
recognition
.
new_plate
.
length
();
continue
;
}
if
(
recognition
.
text_confidence
>=
instace
.
getCarConfidenceMax
()){
if
(
value
->
getQueue
().
size
()
>=
7
&&
value
->
getQueue
().
size
()
<=
10
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
value
->
removeQueue
();
}
}
for
(
int
var
=
0
;
var
<
3
;
++
var
)
{
RecognizedInfo
info
(
recognition
.
new_plate
,
recognition
.
time
,
recognition
.
new_color
);
value
->
addQueue
(
info
);
recognizedInfo
=
std
::
move
(
info
);
}
this
->
checkAndUpdateCurrentPlate
(
value
,
frame
,
recognizedInfo
,
res
,
exitMoMap
);
}
if
(
recognition
.
text_confidence
<=
instace
.
getCarConfidenceMin
()){
qDebug
()
<<
sSn
<<
"==>recognition.text_confidence<=instace.getCarConfidenceMin"
<<
instace
.
getCarConfidenceMin
();
continue
;
}
if
(
recognition
.
text_confidence
>
instace
.
getCarConfidenceMin
()
&&
recognition
.
text_confidence
<
instace
.
getCarConfidenceMax
())
{
if
(
value
->
getQueue
().
size
()
>=
10
)
{
}
else
{
int
res
=-
1
;
if
(
value
==
nullptr
){
continue
;
}
vides_data
::
LicensePlate
maxPlate
;
licensePlateRecogn
.
filterLicensePlateConfidenceMax
(
resultPlate
,
maxPlate
);
RecognizedInfo
recognizedInfo
;
if
(
maxPlate
.
new_color
==
"蓝牌"
&&
maxPlate
.
new_plate
.
length
()
!=
7
)
{
qDebug
()
<<
sSn
<<
"==>蓝牌车牌号:"
<<
maxPlate
.
new_plate
<<
"===>recognition.new_plate.length():"
<<
maxPlate
.
new_plate
.
length
();
continue
;
}
else
if
(
maxPlate
.
new_color
==
"绿牌新能源"
&&
maxPlate
.
new_plate
.
length
()
!=
8
)
{
qDebug
()
<<
sSn
<<
"==>绿牌车牌号:"
<<
maxPlate
.
new_plate
<<
"===>recognition.new_plate.length():"
<<
maxPlate
.
new_plate
.
length
();
continue
;
}
else
if
(
maxPlate
.
new_plate
.
length
()
<
7
)
{
qDebug
()
<<
sSn
<<
"==>非绿牌蓝牌车牌号:"
<<
maxPlate
.
new_plate
<<
"===>recognition.new_plate.length():"
<<
maxPlate
.
new_plate
.
length
();
continue
;
}
if
(
maxPlate
.
text_confidence
>=
instace
.
getCarConfidenceMax
()){
if
(
value
->
getQueue
().
size
()
>=
7
&&
value
->
getQueue
().
size
()
<=
10
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
value
->
removeQueue
();
}
RecognizedInfo
info
(
recognition
.
new_plate
,
recognition
.
time
,
recognition
.
new_color
);
}
for
(
int
var
=
0
;
var
<
3
;
++
var
)
{
RecognizedInfo
info
(
maxPlate
.
new_plate
,
maxPlate
.
time
,
maxPlate
.
new_color
);
value
->
addQueue
(
info
);
recognizedInfo
=
std
::
move
(
info
);
this
->
checkAndUpdateCurrentPlate
(
value
,
frame
,
recognizedInfo
,
res
,
exitMoMap
);
}
qDebug
()
<<
sSn
<<
"==>checkAndUpdateCurrentPlate结果是"
<<
res
;
if
(
res
==
Exit
||
res
==
Mobilization
)
{
recognition
.
areaLocation
=
value
->
getArea
();
recognition
.
img
=
imgs
;
recognition
.
new_color
=
recognizedInfo
.
getColor
();
newPlate
.
plates
.
push_back
(
std
::
move
(
recognition
));
}
if
(
res
==
ExitAndMobilization
){
if
(
exitMoMap
.
size
()
>
0
){
recognition
.
areaLocation
=
value
->
getArea
();
recognition
.
img
=
imgs
;
recognition
.
new_color
=
recognizedInfo
.
getColor
();
newPlate
.
plates
.
push_back
(
std
::
move
(
recognition
));
RecognizedInfo
exitInfo
=
exitMoMap
[
Exit
];
vides_data
::
LicensePlate
oldInfo
;
oldInfo
.
areaLocation
=
value
->
getArea
();
oldInfo
.
img
=
imgs
;
oldInfo
.
new_color
=
exitInfo
.
getColor
();
oldInfo
.
new_plate
=
exitInfo
.
getLicensePlate
();
oldInfo
.
time
=
exitInfo
.
getRecognizeTime
();
newPlate
.
plates
.
push_back
(
std
::
move
(
oldInfo
));
}
}
}
else
{
this
->
checkAndUpdateCurrentPlate
(
value
,
areaMat
,
recognizedInfo
,
res
);
}
if
(
maxPlate
.
text_confidence
<=
instace
.
getCarConfidenceMin
()){
qDebug
()
<<
sSn
<<
"==>recognition.text_confidence<=instace.getCarConfidenceMin"
<<
instace
.
getCarConfidenceMin
();
continue
;
}
if
(
maxPlate
.
text_confidence
>
instace
.
getCarConfidenceMin
()
&&
maxPlate
.
text_confidence
<
instace
.
getCarConfidenceMax
())
{
if
(
value
->
getQueue
().
size
()
>=
10
)
{
value
->
removeQueue
();
}
RecognizedInfo
recognizedInfo
(
""
,
QDateTime
::
currentSecsSinceEpoch
(),
"未知"
);
value
->
addQueue
(
recognizedInfo
);
int
res
;
this
->
checkAndUpdateCurrentPlate
(
value
,
frame
,
recognizedInfo
,
res
,
exitMoMap
);
RecognizedInfo
info
(
maxPlate
.
new_plate
,
maxPlate
.
time
,
maxPlate
.
new_color
);
value
->
addQueue
(
info
);
recognizedInfo
=
std
::
move
(
info
);
this
->
checkAndUpdateCurrentPlate
(
value
,
areaMat
,
recognizedInfo
,
res
);
}
qDebug
()
<<
sSn
<<
"==>checkAndUpdateCurrentPlate结果是"
<<
res
;
if
(
res
==
Exit
||
res
==
Mobilization
)
{
maxPlate
.
areaLocation
=
value
->
getArea
();
maxPlate
.
img
=
imgs
;
maxPlate
.
new_color
=
recognizedInfo
.
getColor
();
newPlate
.
plates
.
push_back
(
std
::
move
(
maxPlate
));
qDebug
()
<<
QString
(
"当前进入ps.size()>0 --> res == Exit || res == Mobilization 是当前校验返回结果是:%1"
).
arg
(
res
);
}
if
(
res
==
ExitAndMobilization
){
maxPlate
.
areaLocation
=
value
->
getArea
();
maxPlate
.
img
=
imgs
;
maxPlate
.
new_color
=
recognizedInfo
.
getColor
();
newPlate
.
plates
.
push_back
(
std
::
move
(
maxPlate
));
if
(
res
==
Exit
||
res
==
Mobilization
)
{
vides_data
::
LicensePlate
current
;
current
.
areaLocation
=
value
->
getArea
();
current
.
img
=
imgs
;
current
.
new_color
=
recognizedInfo
.
getColor
();
current
.
new_plate
=
recognizedInfo
.
getLicensePlate
();
current
.
time
=
recognizedInfo
.
getRecognizeTime
();
current
.
recognition
=
value
->
getArea
();
newPlate
.
plates
.
push_back
(
std
::
move
(
current
));
}
if
(
res
==
ExitAndMobilization
){
vides_data
::
LicensePlate
current
;
current
.
areaLocation
=
value
->
getArea
();
current
.
img
=
imgs
;
current
.
new_color
=
recognizedInfo
.
getColor
();
current
.
new_plate
=
recognizedInfo
.
getLicensePlate
();
current
.
time
=
recognizedInfo
.
getRecognizeTime
();
newPlate
.
plates
.
push_back
(
std
::
move
(
current
));
RecognizedInfo
exitInfo
=
exitMoMap
[
Exit
];
vides_data
::
LicensePlate
oldInfo
;
oldInfo
.
areaLocation
=
value
->
getArea
();
oldInfo
.
img
=
imgs
;
oldInfo
.
new_color
=
exitInfo
.
getColor
();
oldInfo
.
new_plate
=
exitInfo
.
getLicensePlate
();
oldInfo
.
time
=
exitInfo
.
getRecognizeTime
();
newPlate
.
plates
.
push_back
(
std
::
move
(
oldInfo
));
}
// RecognizedInfo exitInfo=exitMoMap[Exit];
// vides_data::LicensePlate oldInfo;
// oldInfo.areaLocation=value->getArea();
// //oldInfo.img=imgs;
// oldInfo.new_color=exitInfo.getColor();
// oldInfo.new_plate=exitInfo.getLicensePlate();
// oldInfo.time=exitInfo.getRecognizeTime();
// newPlate.plates.push_back(std::move(oldInfo));
}
}
}
qDebug
()
<<
QString
(
"%1==>当前车牌数量:%2"
).
arg
(
sSn
).
arg
(
ps
.
size
());
qDebug
()
<<
QString
(
"%1==>当前车牌数量:%2"
).
arg
(
sSn
).
arg
(
newPlate
.
plates
.
size
());
if
(
newPlate
.
plates
.
size
()
>
0
){
licensePlateRecognitionResults
(
newPlate
);
foreach
(
auto
var
,
plate
.
plates
)
{
foreach
(
auto
var
,
newPlate
.
plates
)
{
qDebug
()
<<
QString
(
"sn:%1 =>识别的车牌号是:%2"
).
arg
(
sSn
).
arg
(
var
.
new_plate
);
}
licensePlateRecognitionResults
(
newPlate
);
}
}
void
CameraHandle
::
findIp
(
QString
&
ip
){
ip
=
QString
::
fromStdString
(
loginParam
->
sDevId
);
...
...
@@ -772,50 +851,58 @@ void CameraHandle::pushRecordToCloud(int id, int recognitionType, QString ossUrl
void
CameraHandle
::
licensePlateRecognitionResults
(
vides_data
::
requestLicensePlate
&
location
){
Common
&
instace
=
Common
::
getInstance
();
QByteArray
imgs
;
int
maxRetryCount
=
2
;
// 最大重试次数
int
retryCount
=
0
;
// 当前重试次数
bool
requestSuccess
=
false
;
// 标记请求是否成功
while
(
retryCount
<
maxRetryCount
&&
!
requestSuccess
)
{
HttpService
httpService
(
httpUrl
);
std
::
list
<
vides_data
::
responseRecognitionData
>
result
;
vides_data
::
response
*
resp
=
httpService
.
httpLicensePlateRecognition
(
location
,
result
);
if
(
resp
->
code
==
0
)
{
if
(
result
.
size
()
==
0
){
return
;
}
vides_data
::
responseStsCredentials
sts_credentials
=
HttpService
::
stsCredentials
;
QString
oUrl
=
"http://"
+
sts_credentials
.
bucket
+
"."
+
sts_credentials
.
endpoint
;
currentData
[
"ossUrl"
]
=
oUrl
;
currentData
[
"bucket"
]
=
sts_credentials
.
bucket
;
currentData
[
"access_key_id"
]
=
sts_credentials
.
access_key_id
;
currentData
[
"access_key_secret"
]
=
sts_credentials
.
access_key_secret
;
currentData
[
"security_token"
]
=
sts_credentials
.
security_token
;
// foreach (auto var, result) {
// vides_data::responseRecognitionData data;
// data.id=var.id;
// data.inTime=var.inTime;
// data.outTime=var.outTime;
// data.recognitionType=var.recognitionType;
// data.sn=var.sn;
// videoCurrentData[var.id]=data;
// sdkDownloadFileByTime(this->hDevice,var.id,
// instace.timestampToDateString(var.inTime),instace.timestampToDateString(var.outTime));
// }
requestSuccess
=
true
;
}
else
{
++
retryCount
;
}
instace
.
deleteObj
(
resp
);
}
if
(
!
requestSuccess
)
{
HttpService
httpService
(
httpUrl
);
std
::
list
<
vides_data
::
responseRecognitionData
>
result
;
vides_data
::
response
*
resp
=
httpService
.
httpLicensePlateRecognition
(
location
,
result
);
if
(
resp
->
code
!=
0
)
{
qInfo
()
<<
"licensePlateRecognitionResults:车牌识别结果失败"
;
// 在达到最大重试次数且仍然没有成功的情况下执行相应的处理逻辑
}
instace
.
deleteObj
(
resp
);
}
void
CameraHandle
::
printWifi
(
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
,
4000
,
EXCMD_CONFIG_GET
);
qDebug
()
<<
szOutBuffer
;
if
(
nResult
>=
0
)
{
cfg
.
Parse
(
szOutBuffer
);
}
else
{
printf
(
"Failed to get Wi-Fi configuration. Error code: %d
\n
"
,
nResult
);
}
}
void
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
);
QByteArray
&&
byJson
=
ssid
.
toUtf8
();
const
char
*
cssid
=
byJson
.
data
();
wif
.
SSID
.
SetValue
(
cssid
);
wif
.
Enable
.
SetValue
(
true
);
wif
.
KeyType
.
SetValue
(
1
);
const
char
*
wipCfg
=
wif
.
ToString
();
char
szOutBuffer
[
512
]
=
{
0
};
int
nLen
=
sizeof
(
szOutBuffer
);
int
res
=
XSDK_DevSetSysConfigSyn
(
hDevice
,
JK_NetWork_Wifi
,
wipCfg
,
strlen
(
wipCfg
),
szOutBuffer
,
&
nLen
,
5000
,
EXCMD_CONFIG_SET
);
if
(
res
<
0
){
qInfo
()
<<
"修改wifi失败"
;
}
}
void
CameraHandle
::
sdkDevSystemTimeZoneSyn
(
QString
&
time
){
QByteArray
bTime
=
time
.
toUtf8
();
const
char
*
cTime
=
bTime
.
data
();
...
...
@@ -929,9 +1016,111 @@ double CameraHandle::calculateIntersectionArea(const QPolygonF &polygon1, const
double
CameraHandle
::
ccw
(
const
QPointF
&
a
,
const
QPointF
&
b
,
const
QPointF
&
c
)
{
return
(
b
.
x
()
-
a
.
x
())
*
(
c
.
y
()
-
a
.
y
())
-
(
c
.
x
()
-
a
.
x
())
*
(
b
.
y
()
-
a
.
y
());
}
int
CameraHandle
::
findPointRegion
(
ParkingSpaceInfo
&
prakArea
){
//左下、右下、右上、左上。
double
maxIntersectionArea
=
0.0
;
//顺时针
bool
CameraHandle
::
isClockwise
(
const
std
::
vector
<
cv
::
Point2f
>&
polygon
)
{
float
sum
=
0.0
;
for
(
size_t
i
=
0
;
i
<
polygon
.
size
();
++
i
)
{
cv
::
Point2f
current
=
polygon
[
i
];
cv
::
Point2f
next
=
polygon
[(
i
+
1
)
%
polygon
.
size
()];
sum
+=
(
next
.
x
-
current
.
x
)
*
(
next
.
y
+
current
.
y
);
}
return
sum
>
0
;
}
void
CameraHandle
::
faceUniformOverlap
(
std
::
map
<
QString
,
vides_data
::
requestFaceReconition
>&
mapFaces
,
std
::
vector
<
vides_data
::
ParkingArea
>&
uniforms
,
std
::
list
<
QString
>&
outUniforms
)
{
const
float
epsilon
=
1e-5
;
for
(
auto
iter
=
mapFaces
.
begin
();
iter
!=
mapFaces
.
end
();
++
iter
)
{
QString
id
=
iter
->
first
;
// 人员id
vides_data
::
requestFaceReconition
value
=
iter
->
second
;
std
::
vector
<
cv
::
Point2f
>
faceAreaPoints
=
{
cv
::
Point2f
(
value
.
area
.
top_left_corner_x
,
value
.
area
.
top_left_corner_y
),
cv
::
Point2f
(
value
.
area
.
top_right_corner_x
,
value
.
area
.
top_right_corner_y
),
cv
::
Point2f
(
value
.
area
.
bottom_right_corner_x
,
value
.
area
.
bottom_right_corner_y
),
cv
::
Point2f
(
value
.
area
.
bottom_left_corner_x
,
value
.
area
.
bottom_left_corner_y
)
};
if
(
!
isClockwise
(
faceAreaPoints
))
{
std
::
reverse
(
faceAreaPoints
.
begin
(),
faceAreaPoints
.
end
());
}
float
maxIntersectionArea
=
0.0
;
int
maxUniformIndex
=
-
1
;
for
(
size_t
i
=
0
;
i
<
uniforms
.
size
();
++
i
)
{
std
::
vector
<
cv
::
Point2f
>
uniformAreaPoints
=
{
cv
::
Point2f
(
uniforms
[
i
].
topLeftCornerX
,
uniforms
[
i
].
topLeftCornerY
),
cv
::
Point2f
(
uniforms
[
i
].
topRightCornerX
,
uniforms
[
i
].
topRightCornerY
),
cv
::
Point2f
(
uniforms
[
i
].
bottomRightCornerX
,
uniforms
[
i
].
bottomRightCornerY
),
cv
::
Point2f
(
uniforms
[
i
].
bottomLeftCornerX
,
uniforms
[
i
].
bottomLeftCornerY
)
};
if
(
!
isClockwise
(
uniformAreaPoints
))
{
std
::
reverse
(
uniformAreaPoints
.
begin
(),
uniformAreaPoints
.
end
());
}
std
::
vector
<
cv
::
Point2f
>
intersection
;
float
intersectionArea
=
cv
::
intersectConvexConvex
(
faceAreaPoints
,
uniformAreaPoints
,
intersection
,
true
);
if
(
intersectionArea
>
maxIntersectionArea
)
{
maxIntersectionArea
=
intersectionArea
;
maxUniformIndex
=
static_cast
<
int
>
(
i
);
}
}
if
(
maxUniformIndex
!=
-
1
&&
maxIntersectionArea
>
epsilon
)
{
outUniforms
.
push_back
(
id
);
}
}
}
bool
CameraHandle
::
isAnyOverlap
(
ParkingSpaceInfo
*
parkArea
,
std
::
vector
<
vides_data
::
ParkingArea
>
&
currentPlates
)
{
// 将parkArea转换为cv::Point2f的顶点列表
std
::
vector
<
cv
::
Point2f
>
parkAreaPoints
=
{
cv
::
Point2f
(
parkArea
->
getArea
().
topLeftCornerX
,
parkArea
->
getArea
().
topLeftCornerY
),
cv
::
Point2f
(
parkArea
->
getArea
().
topRightCornerX
,
parkArea
->
getArea
().
topRightCornerY
),
cv
::
Point2f
(
parkArea
->
getArea
().
bottomRightCornerX
,
parkArea
->
getArea
().
bottomRightCornerY
),
cv
::
Point2f
(
parkArea
->
getArea
().
bottomLeftCornerX
,
parkArea
->
getArea
().
bottomLeftCornerY
)
};
if
(
!
isClockwise
(
parkAreaPoints
))
{
std
::
reverse
(
parkAreaPoints
.
begin
(),
parkAreaPoints
.
end
());
}
// 遍历currentPlates中的每一个区域,检查是否存在重合
for
(
const
auto
&
plateArea
:
currentPlates
)
{
// 构建当前plateArea的顶点列表
std
::
vector
<
cv
::
Point2f
>
plateAreaPoints
=
{
cv
::
Point2f
(
plateArea
.
topLeftCornerX
,
plateArea
.
topLeftCornerY
),
cv
::
Point2f
(
plateArea
.
topRightCornerX
,
plateArea
.
topRightCornerY
),
cv
::
Point2f
(
plateArea
.
bottomRightCornerX
,
plateArea
.
bottomRightCornerY
),
cv
::
Point2f
(
plateArea
.
bottomLeftCornerX
,
plateArea
.
bottomLeftCornerY
)
};
if
(
!
isClockwise
(
plateAreaPoints
))
{
std
::
reverse
(
plateAreaPoints
.
begin
(),
plateAreaPoints
.
end
());
}
std
::
vector
<
cv
::
Point2f
>
intersection
;
// 使用cv::intersectConvexConvex计算交集
float
intersectionArea
=
cv
::
intersectConvexConvex
(
parkAreaPoints
,
plateAreaPoints
,
intersection
,
true
);
const
float
epsilon
=
1e-5
;
// 如果交集不为空,说明有重合
if
(
intersectionArea
>
epsilon
&&
!
intersection
.
empty
())
{
return
true
;
}
}
// 所有车牌区域均与parkArea无重合
return
false
;
}
int
CameraHandle
::
findPointRegion
(
ParkingSpaceInfo
&
prakArea
)
{
float
maxIntersectionArea
=
0.0
;
int
areaOfMaxIntersection
=
-
1
;
std
::
vector
<
cv
::
Point2f
>
currentPolygonPoints
=
{
cv
::
Point2f
(
prakArea
.
getArea
().
topLeftCornerX
,
prakArea
.
getArea
().
topLeftCornerY
),
...
...
@@ -939,10 +1128,16 @@ int CameraHandle::findPointRegion(ParkingSpaceInfo &prakArea){
cv
::
Point2f
(
prakArea
.
getArea
().
bottomRightCornerX
,
prakArea
.
getArea
().
bottomRightCornerY
),
cv
::
Point2f
(
prakArea
.
getArea
().
bottomLeftCornerX
,
prakArea
.
getArea
().
bottomLeftCornerY
)
};
if
(
!
isClockwise
(
currentPolygonPoints
))
{
std
::
reverse
(
currentPolygonPoints
.
begin
(),
currentPolygonPoints
.
end
());
}
qDebug
()
<<
"Current Polygon Points:"
;
for
(
const
auto
&
point
:
currentPolygonPoints
)
{
qDebug
()
<<
"("
<<
point
.
x
<<
", "
<<
point
.
y
<<
")"
;
}
for
(
ParkingSpaceInfo
*
info
:
parkingSpaceInfos
)
{
std
::
vector
<
cv
::
Point2f
>
polygonInfoPoints
=
{
cv
::
Point2f
(
info
->
getArea
().
topLeftCornerX
,
info
->
getArea
().
topLeftCornerY
),
...
...
@@ -950,20 +1145,26 @@ int CameraHandle::findPointRegion(ParkingSpaceInfo &prakArea){
cv
::
Point2f
(
info
->
getArea
().
bottomRightCornerX
,
info
->
getArea
().
bottomRightCornerY
),
cv
::
Point2f
(
info
->
getArea
().
bottomLeftCornerX
,
info
->
getArea
().
bottomLeftCornerY
)
};
// 打印 polygonInfoPoints 的值
// Ensure polygonInfoPoints are in clockwise order
if
(
!
isClockwise
(
polygonInfoPoints
))
{
std
::
reverse
(
polygonInfoPoints
.
begin
(),
polygonInfoPoints
.
end
());
}
qDebug
()
<<
"Polygon Info Points for Space "
<<
info
->
getSpaceIndex
()
<<
":"
;
for
(
const
auto
&
point
:
polygonInfoPoints
)
{
qDebug
()
<<
"("
<<
point
.
x
<<
", "
<<
point
.
y
<<
")"
;
}
std
::
vector
<
cv
::
Point2f
>
intersection
;
double
intersectionArea
=
cv
::
intersectConvexConvex
(
polygonInfoPoints
,
currentPolygonPoints
,
intersection
,
true
);
if
(
intersectionArea
>
0.0
&&
intersectionArea
>
maxIntersectionArea
)
{
float
intersectionArea
=
cv
::
intersectConvexConvex
(
polygonInfoPoints
,
currentPolygonPoints
,
intersection
,
true
);
const
float
epsilon
=
1e-5
;
if
(
intersectionArea
>
epsilon
&&
intersectionArea
>
maxIntersectionArea
)
{
maxIntersectionArea
=
intersectionArea
;
areaOfMaxIntersection
=
info
->
getSpaceIndex
();
}
}
return
areaOfMaxIntersection
;
}
...
...
CameraHandle.h
View file @
5fe7062a
...
...
@@ -11,6 +11,7 @@
#include "Json_Header/System_TimeZone.h"
#include "Json_Header/RecordCfg.h"
#include "Json_Header/NetWork_SPVMN.h"
#include "Json_Header/NetWork_Wifi.h"
#include "Json_Header/SystemInfo.h"
#include "Json_Header/OPMachine.h"
#include "mainwindow.h"
...
...
@@ -40,8 +41,9 @@ enum CAR_INFORMATION {
class
CameraHandle
:
public
QObject
{
Q_OBJECT
public
:
CameraHandle
(
QString
&
url
,
QString
&
httpUrl
,
QString
&
sSn
,
int
&
channel
,
const
QString
&
modelPaths
,
float
carConfidence
,
int
imageSave
);
CameraHandle
(
QString
&
url
,
QString
&
httpUrl
,
QString
&
sSn
,
int
&
channel
,
const
QString
&
modelPaths
,
float
carConfidence
,
float
carShapeConfidence
,
int
imageSave
);
CameraHandle
();
~
CameraHandle
();
int
sdkDevLoginSyn
(
QString
sDevId
,
int
nDevPort
,
QString
sUserName
,
QString
sPassword
,
int
nTimeout
);
...
...
@@ -54,19 +56,30 @@ public:
void
clearCameraHandle
();
void
initAlgorithmParameter
(
float
&
height_reference
);
// void rebindTimer(int hDevice);
void
initSdkRealTimeDevSnapSyn
(
int
hDevice
,
int
syn_timer
,
uint64
face_frequency
);
void
updateImage
(
const
cv
::
Mat
&
frame
,
qint64
currentTime
);
void
matToBase64
(
const
cv
::
Mat
&
image
,
QByteArray
&
base64Data
);
//把原始图片转换成不同区域的掩码
void
matToAreaMask
(
const
cv
::
Mat
&
source
,
std
::
map
<
int
,
cv
::
Mat
>
&
maskFrame
);
int
callbackFunction
(
XSDK_HANDLE
hObject
,
QString
&
szString
);
void
checkAndUpdateCurrentPlate
(
ParkingSpaceInfo
*
park
,
const
cv
::
Mat
&
frame
,
RecognizedInfo
&
newInfo
,
int
&
result
,
std
::
map
<
int
,
RecognizedInfo
>&
exitAndMoMap
);
void
checkAndUpdateCurrentPlate
(
ParkingSpaceInfo
*
park
,
const
cv
::
Mat
&
frame
,
RecognizedInfo
&
newInfo
,
int
&
result
);
void
licensePlateRecognitionResults
(
vides_data
::
requestLicensePlate
&
location
);
void
sdkDevSnapSyn
(
XSDK_HANDLE
hDevice
,
int
nChannel
);
void
printWifi
(
XSDK_HANDLE
hDevice
,
XSDK_CFG
::
NetWork_Wifi
&
cfg
);
//设置相机连接的wifi
void
sdkWifi
(
QString
&
pwd
,
QString
&
ssid
);
//时间设置
void
sdkDevSystemTimeZoneSyn
(
QString
&
time
);
//录像设置
...
...
@@ -79,19 +92,24 @@ public:
void
deviceReboot
();
//获取固件版本
void
findFirmwareVersion
(
QString
&
firmwareVersion
);
//获取ip
void
findIp
(
QString
&
ip
);
void
sdkDownloadFileByTime
(
XSDK_HANDLE
hDevice
,
int
id
,
QString
startTimer
,
QString
endTime
);
void
batchRegionalPushLicensePlate
(
QByteArray
&
imgs
,
qint64
currentTime
,
vides_data
::
requestLicensePlate
&
newPlate
);
void
faceUniformOverlap
(
std
::
map
<
QString
,
vides_data
::
requestFaceReconition
>&
mapFaces
,
std
::
vector
<
vides_data
::
ParkingArea
>
&
uniforms
,
std
::
list
<
QString
>&
outUniforms
);
bool
isClockwise
(
const
std
::
vector
<
cv
::
Point2f
>&
polygon
);
QString
getSSn
();
int
getMediaHandle
();
void
setMediaHandle
(
int
mediaHandle
);
void
setCurrentFace
(
int
currentFace
);
void
initAlgorithmPermissions
(
__uint8_t
algorithm
);
void
initParkingSpaceInfo
(
const
std
::
list
<
vides_data
::
responseArea
>&
areas
);
...
...
@@ -103,13 +121,16 @@ public:
std
::
map
<
QString
,
QString
>&
getCurrentData
();
bool
isChanged
(
const
QPoint
&
newInfo
,
const
QPoint
&
current
);
// 检查点是否在多边形内
bool
polygonsOverlap
(
ParkingSpaceInfo
&
poly1
,
ParkingSpaceInfo
&
poly2
);
// 计算两个多边形的交集面积
double
calculateIntersectionArea
(
const
QPolygonF
&
polygon1
,
const
QPolygonF
&
polygon2
);
double
ccw
(
const
QPointF
&
a
,
const
QPointF
&
b
,
const
QPointF
&
c
);
void
getCurrentFrame
(
std
::
vector
<
uchar
>
&
buffer
);
bool
isAnyOverlap
(
ParkingSpaceInfo
*
parkArea
,
std
::
vector
<
vides_data
::
ParkingArea
>
&
currentPlates
);
int
findPointRegion
(
ParkingSpaceInfo
&
prakArea
);
int
determineArea
(
ParkingSpaceInfo
&
prakArea
);
signals
:
...
...
@@ -130,10 +151,7 @@ private :
SXSDKLoginParam
*
loginParam
;
SXMediaFaceImageReq
*
sxMediaFaceImageReq
;
std
::
mutex
plateMutex
;
std
::
mutex
faceMutex
;
QString
sSn
;
QString
url
;
std
::
map
<
int
,
vides_data
::
responseRecognitionData
>
videoCurrentData
;
...
...
@@ -144,8 +162,9 @@ private :
std
::
map
<
int
,
ParkingSpaceInfo
*>
parkMap
;
//当前相机监视所以车位区域
std
::
vector
<
ParkingSpaceInfo
*>
parkingSpaceInfos
;
//当前人脸数
int
currentFace
;
//当前人脸数和工作人数
QPoint
faceMapWorker
;
int
mediaHandle
;
//2秒钟抓一次图
...
...
@@ -158,14 +177,14 @@ private :
P_HLPR_Context
ctx
;
QSemaphore
semaphore
;
int
image_save
;
std
::
atomic
<
uint64
>
faceCount
;
uint64
face_frequency
;
__uint8_t
algorithmPermissions
;
};
#endif // CAMERAHANDLE_H
Common.h
View file @
5fe7062a
...
...
@@ -62,8 +62,8 @@ private:
QString
videoOut
;
QString
videoDownload
;
QString
images
;
double
carConfidenceMax
;
double
carConfidenceMin
;
float
carConfidenceMax
;
float
carConfidenceMin
;
Common
();
~
Common
();
...
...
FaceReconition.cpp
View file @
5fe7062a
...
...
@@ -209,6 +209,7 @@ void FaceReconition::doesItExistEmployee(const cv::Mat &source,std::list<vides_d
HInt32
featureNum
;
HF_GetFeatureLength
(
ctxHandle
,
&
featureNum
);
for
(
int
j
=
0
;
j
<
multipleFaceData
.
detectedNum
;
++
j
){
qDebug
()
<<
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
)
{
...
...
HttpService.cpp
View file @
5fe7062a
...
...
@@ -15,7 +15,7 @@ HttpService::~HttpService() {
vides_data
::
response
*
HttpService
::
httpPostDeviceStatus
(
vides_data
::
requestDeviceStatus
&
deviceStatus
)
{
httpUrl
.
append
(
"/api/v1.0/device/ping"
);
// 创建主 JSON 对象
QJsonObject
json
;
json
.
insert
(
"sn"
,
deviceStatus
.
sSn
);
...
...
@@ -23,7 +23,7 @@ vides_data::response* HttpService::httpPostDeviceStatus(vides_data::requestDevic
json
.
insert
(
"state"
,
deviceStatus
.
status
);
json
.
insert
(
"ip_addr"
,
deviceStatus
.
ip_addr
);
json
.
insert
(
"firmware_version"
,
deviceStatus
.
firmware_version
);
// 将固件版本添加到主 JSON 对象中
// 创建摄像头信息列表 JSON 数组
QJsonArray
cameraArray
;
for
(
const
auto
&
cameraInfo
:
deviceStatus
.
camera_info_list
)
{
...
...
@@ -35,11 +35,11 @@ vides_data::response* HttpService::httpPostDeviceStatus(vides_data::requestDevic
}
// 将摄像头信息列表添加到主 JSON 对象中
json
.
insert
(
"camera_info_list"
,
cameraArray
);
// 将 JSON 对象转换为 JSON 文档
QJsonDocument
jsonDoc
(
json
);
QByteArray
bytearr
=
jsonDoc
.
toJson
(
QJsonDocument
::
Compact
);
vides_data
::
response
*
resp
=
new
vides_data
::
response
();
QNetworkRequest
request
;
request
.
setUrl
(
QUrl
(
httpUrl
));
...
...
@@ -116,7 +116,7 @@ vides_data::response *HttpService::httpFindCameras(QString &serialNumber,vides_d
resp
->
code
=
map
[
"code"
].
toInt
();
QJsonObject
dataObj
=
maps
[
"data"
].
toObject
();
// 处理"sts_credentials"字段
QJsonObject
stsCredentialsObj
=
dataObj
[
"sts_credentials"
].
toObject
();
HttpService
::
stsCredentials
.
access_key_id
=
responseData
.
sts_credentials
.
access_key_id
=
stsCredentialsObj
[
"access_key_id"
].
toString
();
...
...
@@ -146,12 +146,12 @@ vides_data::response *HttpService::httpFindCameras(QString &serialNumber,vides_d
area
.
bottom_right_corner_y
=
areaObject
[
"bottom_right_corner_y"
].
toDouble
();
area
.
top_left_corner_x
=
areaObject
[
"top_left_corner_x"
].
toDouble
();
area
.
top_left_corner_y
=
areaObject
[
"top_left_corner_y"
].
toDouble
();
area
.
bottom_left_corner_x
=
areaObject
[
"bottom_left_corner_x"
].
toDouble
();
area
.
bottom_left_corner_y
=
areaObject
[
"bottom_left_corner_y"
].
toDouble
();
area
.
top_right_corner_x
=
areaObject
[
"top_right_corner_x"
].
toDouble
();
area
.
top_right_corner_y
=
areaObject
[
"top_right_corner_y"
].
toDouble
();
status
.
areas
.
push_back
(
area
);
}
...
...
@@ -182,28 +182,27 @@ vides_data::response *HttpService::httpLicensePlateRecognition(vides_data::reque
{
"bottom_right_corner_y"
,
plate
.
areaLocation
.
bottomRightCornerY
},
{
"top_left_corner_x"
,
plate
.
areaLocation
.
topLeftCornerX
},
{
"top_left_corner_y"
,
plate
.
areaLocation
.
topLeftCornerY
},
{
"bottom_left_corner_x"
,
plate
.
areaLocation
.
bottomLeftCornerX
},
{
"bottom_left_corner_y"
,
plate
.
areaLocation
.
bottomLeftCornerY
},
{
"top_right_corner_x"
,
plate
.
areaLocation
.
topRightCornerX
},
{
"top_right_corner_y"
,
plate
.
areaLocation
.
topRightCornerY
}
};
item
.
insert
(
"camera_location"
,
cameraObject
);
item
.
insert
(
"img"
,
QJsonValue
::
fromVariant
(
plate
.
img
));
// 替换为真实的图像数据
QJsonObject
locationObject
{
{
"bottom_right_corner_x"
,
plate
.
recognition
.
bottomRightCornerX
},
{
"bottom_right_corner_y"
,
plate
.
recognition
.
bottomRightCornerY
},
{
"top_left_corner_x"
,
plate
.
recognition
.
topLeftCornerX
},
{
"top_left_corner_y"
,
plate
.
recognition
.
topLeftCornerY
},
{
"bottom_left_corner_x"
,
plate
.
recognition
.
bottomLeftCornerX
},
{
"bottom_left_corner_y"
,
plate
.
recognition
.
bottomLeftCornerY
},
{
"top_right_corner_x"
,
plate
.
recognition
.
topRightCornerX
},
{
"top_right_corner_y"
,
plate
.
recognition
.
topRightCornerY
}
};
item
.
insert
(
"location"
,
locationObject
);
item
.
insert
(
"new_color"
,
plate
.
new_color
);
// 替换为真实的颜色数据
item
.
insert
(
"new_plate"
,
plate
.
new_plate
);
// 使用LicensePlate结构中的车牌号字段
...
...
@@ -230,7 +229,7 @@ vides_data::response *HttpService::httpLicensePlateRecognition(vides_data::reque
QVariantMap
map
=
std
::
move
(
maps
.
toVariantMap
());
resp
->
code
=
map
[
"code"
].
toInt
();
resp
->
msg
=
map
[
"message"
].
toString
();
QJsonObject
data
=
map
[
"data"
].
toJsonObject
();
QJsonArray
dataList
=
data
[
"list"
].
toArray
();
// 获取 "list" 数组
for
(
const
auto
&
item
:
dataList
)
{
...
...
@@ -245,9 +244,11 @@ vides_data::response *HttpService::httpLicensePlateRecognition(vides_data::reque
// 将 res 添加到结果列表或进行其他操作
}
}
else
{
qDebug
()
<<
m_httpClient
.
errorCode
();
qDebug
()
<<
"httpLicensePlateRecognition"
<<
m_httpClient
.
errorCode
();
qDebug
()
<<
"httpLicensePlateRecognition msg"
<<
m_httpClient
.
errorString
();
resp
->
code
=
2
;
resp
->
msg
=
OPERATION_FAILED
;
resp
->
msg
=
m_httpClient
.
errorString
()
;
}
return
resp
;
}
...
...
@@ -288,17 +289,17 @@ vides_data::response* HttpService::httpFindFaceReconition(QString &serialNumber,
return
resp
;
}
vides_data
::
response
*
HttpService
::
httpPostUniforms
(
QByteArray
&
img
,
int
&
number
,
QString
sn
,
qint64
time
){
vides_data
::
response
*
HttpService
::
httpPostUniforms
(
QByteArray
&
img
,
QString
&
id
,
QString
sn
,
qint64
time
){
httpUrl
.
append
(
"/api/v1.0/recongnition/uniform"
);
QJsonObject
json
;
json
.
insert
(
"img"
,
QJsonValue
::
fromVariant
(
img
));
json
.
insert
(
"sn"
,
sn
);
json
.
insert
(
"
number"
,
number
);
json
.
insert
(
"
id"
,
id
);
json
.
insert
(
"time"
,
QJsonValue
::
fromVariant
(
time
));
QJsonDocument
jsonDoc
;
jsonDoc
.
setObject
(
json
);
QByteArray
bytearr
=
jsonDoc
.
toJson
(
QJsonDocument
::
Compact
);
vides_data
::
response
*
resp
=
new
vides_data
::
response
();
QNetworkRequest
request
;
request
.
setUrl
(
QUrl
(
httpUrl
));
...
...
@@ -320,17 +321,26 @@ vides_data::response *HttpService::httpPostUniforms(QByteArray &img,int &number,
return
resp
;
}
vides_data
::
response
*
HttpService
::
httpPostFacePopulation
(
QByteArray
&
img
,
int
&
numb
er
,
QString
sn
,
qint64
time
){
vides_data
::
response
*
HttpService
::
httpPostFacePopulation
(
QByteArray
&
img
,
int
&
human
,
int
&
work
er
,
QString
sn
,
qint64
time
){
httpUrl
.
append
(
"/api/v1.0/recongnition/population"
);
QJsonObject
json
;
json
.
insert
(
"img"
,
QJsonValue
::
fromVariant
(
img
));
json
.
insert
(
"sn"
,
sn
);
json
.
insert
(
"number"
,
number
);
QJsonObject
jsonObject
;
jsonObject
.
insert
(
"human"
,
human
);
jsonObject
.
insert
(
"worker"
,
worker
);
// 使用QJsonDocument来转换为字符串
QJsonDocument
humanData
(
jsonObject
);
QString
jsonString
=
QString
::
fromUtf8
(
humanData
.
toJson
(
QJsonDocument
::
Compact
));
json
.
insert
(
"desc"
,
jsonString
);
json
.
insert
(
"time"
,
QJsonValue
::
fromVariant
(
time
));
QJsonDocument
jsonDoc
;
jsonDoc
.
setObject
(
json
);
QByteArray
bytearr
=
jsonDoc
.
toJson
(
QJsonDocument
::
Compact
);
vides_data
::
response
*
resp
=
new
vides_data
::
response
();
QNetworkRequest
request
;
request
.
setUrl
(
QUrl
(
httpUrl
));
...
...
@@ -359,23 +369,23 @@ vides_data::response *HttpService::httpPostFaceReconition(vides_data::requestFac
json
.
insert
(
"img"
,
QJsonValue
::
fromVariant
(
faceReconition
.
img
));
json
.
insert
(
"sn"
,
faceReconition
.
sn
);
json
.
insert
(
"time"
,
QJsonValue
::
fromVariant
(
faceReconition
.
time
));
// 创建 location 对象
QJsonObject
location
;
location
.
insert
(
"bottom_right_corner_x"
,
faceReconition
.
area
.
bottom_right_corner_x
);
location
.
insert
(
"bottom_right_corner_y"
,
faceReconition
.
area
.
bottom_right_corner_y
);
location
.
insert
(
"top_left_corner_x"
,
faceReconition
.
area
.
top_left_corner_x
);
location
.
insert
(
"top_left_corner_y"
,
faceReconition
.
area
.
top_left_corner_y
);
location
.
insert
(
"bottom_left_corner_x"
,
faceReconition
.
area
.
bottom_left_corner_x
);
location
.
insert
(
"bottom_left_corner_y"
,
faceReconition
.
area
.
bottom_left_corner_y
);
location
.
insert
(
"top_right_corner_x"
,
faceReconition
.
area
.
top_right_corner_x
);
location
.
insert
(
"top_right_corner_y"
,
faceReconition
.
area
.
top_right_corner_y
);
// 将 location 对象插入到主 json 对象中
json
.
insert
(
"location"
,
location
);
QJsonDocument
jsonDoc
;
jsonDoc
.
setObject
(
json
);
QByteArray
bytearr
=
jsonDoc
.
toJson
(
QJsonDocument
::
Compact
);
...
...
@@ -384,7 +394,7 @@ vides_data::response *HttpService::httpPostFaceReconition(vides_data::requestFac
QNetworkRequest
request
;
request
.
setUrl
(
QUrl
(
httpUrl
));
request
.
setRawHeader
(
vides_data
::
HEADER_TYPE_KAY
,
vides_data
::
HEADER_TYPE_VALUE
);
if
(
m_httpClient
.
post
(
request
,
bytearr
)){
QByteArray
&&
byte
=
m_httpClient
.
text
().
toUtf8
();
QJsonDocument
docujson
=
QJsonDocument
::
fromJson
(
byte
.
data
());
...
...
@@ -480,7 +490,7 @@ vides_data::response *HttpService::httpDownload( const QString &filePath,QString
QNetworkRequest
request
;
request
.
setUrl
(
url
);
QString
fileName
=
url
.
fileName
();
QMutexLocker
locker
(
&
m_httpClientMutex
);
if
(
m_httpClient
.
downloadFile
(
request
,
filePath
,
fullPathName
,
fileName
)){
...
...
HttpService.h
View file @
5fe7062a
...
...
@@ -34,10 +34,10 @@ public:
//人脸识别推送
vides_data
::
response
*
httpPostFaceReconition
(
vides_data
::
requestFaceReconition
&
faceReconition
);
//人数变化推送
vides_data
::
response
*
httpPostFacePopulation
(
QByteArray
&
img
,
int
&
numb
er
,
QString
sn
,
qint64
time
);
vides_data
::
response
*
httpPostFacePopulation
(
QByteArray
&
img
,
int
&
human
,
int
&
work
er
,
QString
sn
,
qint64
time
);
//工服推送
vides_data
::
response
*
httpPostUniforms
(
QByteArray
&
img
,
int
&
number
,
QString
sn
,
qint64
time
);
vides_data
::
response
*
httpPostUniforms
(
QByteArray
&
img
,
QString
&
id
,
QString
sn
,
qint64
time
);
//客户端组列表
vides_data
::
response
*
httpFindStream
(
QString
&
serialNumber
);
...
...
@@ -57,6 +57,7 @@ private:
QString
httpUrl
;
HttpClient
m_httpClient
;
QMutex
m_httpClientMutex
;
};
...
...
HumanDetection.cpp
View file @
5fe7062a
#include "Common.h"
#include "HumanDetection.h"
HumanDetection
*
HumanDetection
::
instance
=
nullptr
;
HumanDetection
::
HumanDetection
(){
HumanDetection
::
HumanDetection
()
:
height_reference
(
250.0
f
)
{
}
HumanDetection
::~
HumanDetection
(){
}
int
HumanDetection
::
findHuManCar
(
const
cv
::
Mat
&
source
,
int
res
,
TCV_HumanDetector
*
detector
){
void
HumanDetection
::
draw_human_on_image
(
const
cv
::
Mat
&
image
,
const
TCV_ObjectLocation
*
boxes
,
int
size
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
const
auto
&
box
=
boxes
[
i
];
cv
::
Scalar
color
=
cv
::
Scalar
(
0
,
255
,
0
);
// Green color for boxes
cv
::
Point
topLeft
(
box
.
x1
,
box
.
y1
);
cv
::
Point
bottomRight
(
box
.
x2
,
box
.
y2
);
cv
::
rectangle
(
image
,
topLeft
,
bottomRight
,
color
,
2
);
// Draw rectangle on image
// Determine text to display based on the uniform value
std
::
string
text
;
switch
(
box
.
uniform
)
{
case
0
:
text
=
"Other"
;
break
;
case
1
:
text
=
"Uniform 1"
;
break
;
case
2
:
text
=
"Uniform 2"
;
break
;
default
:
text
=
"Unknown"
;
break
;
}
// Set text color and size
int
fontFace
=
cv
::
FONT_HERSHEY_SIMPLEX
;
double
fontScale
=
1.5
;
int
thickness
=
2
;
cv
::
Scalar
textColor
(
0
,
0
,
255
);
// Red color for text
// Calculate text size to position it correctly
int
baseline
;
cv
::
Size
textSize
=
cv
::
getTextSize
(
text
,
fontFace
,
fontScale
,
thickness
,
&
baseline
);
// Position text at the top center of the rectangle
cv
::
Point
textOrigin
(
topLeft
.
x
+
(
bottomRight
.
x
-
topLeft
.
x
)
/
2
-
textSize
.
width
/
2
,
topLeft
.
y
-
baseline
-
2
);
// Ensure the text is within the image
if
(
textOrigin
.
y
<
0
)
textOrigin
.
y
=
bottomRight
.
y
+
textSize
.
height
+
2
;
cv
::
putText
(
image
,
text
,
textOrigin
,
fontFace
,
fontScale
,
textColor
,
thickness
);
}
Common
&
instace
=
Common
::
getInstance
();
//cv::imwrite("res.jpg", image); // Save the modified image
QString
fileName
=
instace
.
getVideoOut
().
append
(
instace
.
getTimeString
()
+
"置信度:"
+
QString
::
number
(
boxes
->
score
)
+
".jpg"
);
bool
success
=
cv
::
imwrite
(
fileName
.
toStdString
(),
image
);
if
(
success
)
{
qDebug
()
<<
"车型图片已成功保存至:"
<<
fileName
;
}
else
{
qDebug
()
<<
"图片保存失败!"
;
}
}
void
HumanDetection
::
setHeightReference
(
float
&
height_reference
){
this
->
height_reference
=
height_reference
;
}
//int HumanDetection::findHuManCar(const cv::Mat &source,int res,TCV_HumanDetector *detector,
// std::vector<vides_data::ParkingArea> ¤tPlate){
// TCV_CameraStream *stream = TCV_CreateCameraStream();
// TCV_CameraStreamSetData(stream, source.data, source.cols, source.rows);
// TCV_CameraStreamSetRotationMode(stream, TCV_CAMERA_ROTATION_0);
// TCV_CameraStreamSetStreamFormat(stream, TCV_STREAM_BGR);
// //0是人 1是车
// // 执行一帧目标检测
// TCV_HumanDetectorProcessFrame(detector, stream);
// int num=0;
// if(res==0x00 || res==0x02){
// num= TCV_HumanDetectorGetNumOfHuman(detector);
// if (num > 0 && res==0x02) {
// // 创建一个接收检测结果的对象数组
// TCV_ObjectLocation result[num];
// // 提取行人检测结果
// TCV_HumanDetectorGetHumanLocation(detector, result, num);
// int num_uniforms = 0;
// //工服
// for (int i = 0; i < num; ++i) {
// if (result[i].uniform == 0 && std::abs(result[i].y2 - result[i].y1)>=height_reference) {
// vides_data::ParkingArea area;
// area.topLeftCornerX=result[i].x1;
// area.topLeftCornerY=result[i].y1;
// area.bottomLeftCornerX=result[i].x1;
// area.bottomLeftCornerY=result[i].y2;
// area.topRightCornerX=result[i].x2;
// area.topRightCornerY=result[i].y1;
// area.bottomRightCornerX=result[i].x2;
// area.bottomRightCornerY=result[i].y2;
// currentPlate.push_back(area);
// ++num_uniforms;
// }
// }
// num=num_uniforms;
// }
// if( num > 0 && res==0x00){
// // 创建一个接收检测结果的对象数组
// TCV_ObjectLocation result[num];
// // 提取行人检测结果
// TCV_HumanDetectorGetHumanLocation(detector, result, num);
// int human_size = 0;
// //工服
// for (int i = 0; i < num; ++i) {
// if (std::abs(result[i].y2 - result[i].y1)>=height_reference) {
// vides_data::ParkingArea area;
// area.topLeftCornerX=result[i].x1;
// area.topLeftCornerY=result[i].y1;
// area.bottomLeftCornerX=result[i].x1;
// area.bottomLeftCornerY=result[i].y2;
// area.topRightCornerX=result[i].x2;
// area.topRightCornerY=result[i].y1;
// area.bottomRightCornerX=result[i].x2;
// area.bottomRightCornerY=result[i].y2;
// currentPlate.push_back(area);
// ++human_size;
// }
// }
// num=human_size;
// }
// qDebug() << (res == 0 ? "findHuManCar 检测到的人数:" : "findHuManCar 未穿工服的人数:") << num;
// }else if (res==0x01) {
// num=TCV_HumanDetectorGetNumOfCar(detector);
// TCV_ObjectLocation resultCar[num];
// TCV_HumanDetectorGetCarLocation(detector,resultCar,num);
// for (int i = 0; i < num; ++i) {
// vides_data::ParkingArea area;
// area.topLeftCornerX=resultCar[i].x1;
// area.topLeftCornerY=resultCar[i].y1;
// area.bottomLeftCornerX=resultCar[i].x1;
// area.bottomLeftCornerY=resultCar[i].y2;
// area.topRightCornerX=resultCar[i].x2;
// area.topRightCornerY=resultCar[i].y1;
// area.bottomRightCornerX=resultCar[i].x2;
// area.bottomRightCornerY=resultCar[i].y2;
// currentPlate.push_back(area);
// qDebug() << "score 检测到的汽车数量匹配度:" << resultCar[i].score;
// }
// qDebug() << "findHuManCar 检测到的汽车数量:" << num;
// }else {
// qDebug() << "参数错误";
// }
// TCV_ReleaseCameraStream(stream);
// return num;
//}
int
HumanDetection
::
findHuManCar
(
const
cv
::
Mat
&
source
,
int
res
,
TCV_HumanDetector
*
detector
,
std
::
vector
<
vides_data
::
ParkingArea
>
&
currentPlate
)
{
TCV_CameraStream
*
stream
=
TCV_CreateCameraStream
();
TCV_CameraStreamSetData
(
stream
,
source
.
data
,
source
.
cols
,
source
.
rows
);
TCV_CameraStreamSetRotationMode
(
stream
,
TCV_CAMERA_ROTATION_0
);
TCV_CameraStreamSetStreamFormat
(
stream
,
TCV_STREAM_BGR
);
//0是人 1是车
// 执行一帧目标检测
TCV_HumanDetectorProcessFrame
(
detector
,
stream
);
int
num
=
0
;
if
(
res
==
0x00
||
res
==
0x02
){
num
=
TCV_HumanDetectorGetNumOfHuman
(
detector
);
if
(
num
>
0
&&
res
==
0x02
)
{
// 创建一个接收检测结果的对象数组
TCV_ObjectLocation
result
[
num
];
// 提取行人检测结果
TCV_HumanDetectorGetHumanLocation
(
detector
,
result
,
num
);
int
num_uniforms
=
0
;
//工服
for
(
int
i
=
0
;
i
<
num
;
++
i
)
{
if
(
result
[
i
].
uniform
==
0
)
{
++
num_uniforms
;
int
num
=
0
;
if
(
res
==
0x00
||
res
==
0x02
)
{
num
=
TCV_HumanDetectorGetNumOfHuman
(
detector
);
if
(
num
==
0
)
return
num
;
// 无行人检测结果,提前返回
std
::
vector
<
TCV_ObjectLocation
>
results
(
num
);
TCV_HumanDetectorGetHumanLocation
(
detector
,
results
.
data
(),
num
);
int
count
=
0
;
for
(
const
auto
&
person
:
results
)
{
if
((
res
==
0x02
&&
person
.
uniform
==
0
)
||
res
==
0x00
)
{
if
(
std
::
abs
(
person
.
y2
-
person
.
y1
)
>=
height_reference
)
{
vides_data
::
ParkingArea
area
;
area
.
topLeftCornerX
=
person
.
x1
;
area
.
topLeftCornerY
=
person
.
y1
;
area
.
bottomLeftCornerX
=
person
.
x1
;
area
.
bottomLeftCornerY
=
person
.
y2
;
area
.
topRightCornerX
=
person
.
x2
;
area
.
topRightCornerY
=
person
.
y1
;
area
.
bottomRightCornerX
=
person
.
x2
;
area
.
bottomRightCornerY
=
person
.
y2
;
currentPlate
.
push_back
(
area
);
++
count
;
}
}
num
=
num_uniforms
;
}
num
=
count
;
// 更新num为实际计数
qDebug
()
<<
(
res
==
0
?
"findHuManCar 检测到的人数:"
:
"findHuManCar 未穿工服的人数:"
)
<<
num
;
}
else
if
(
res
==
0x01
)
{
num
=
TCV_HumanDetectorGetNumOfCar
(
detector
);
if
(
num
==
0
)
return
num
;
// 无车辆检测结果,提前返回
}
else
if
(
res
==
0x01
)
{
num
=
TCV_HumanDetectorGetNumOfCar
(
detector
);
qDebug
()
<<
"findHuManCar 检测到的汽车数量:"
<<
num
;
std
::
vector
<
TCV_ObjectLocation
>
resultCars
(
num
);
TCV_HumanDetectorGetCarLocation
(
detector
,
resultCars
.
data
(),
num
);
}
else
{
for
(
const
auto
&
car
:
resultCars
)
{
vides_data
::
ParkingArea
area
;
area
.
topLeftCornerX
=
car
.
x1
;
area
.
topLeftCornerY
=
car
.
y1
;
area
.
bottomLeftCornerX
=
car
.
x1
;
area
.
bottomLeftCornerY
=
car
.
y2
;
area
.
topRightCornerX
=
car
.
x2
;
area
.
topRightCornerY
=
car
.
y1
;
area
.
bottomRightCornerX
=
car
.
x2
;
area
.
bottomRightCornerY
=
car
.
y2
;
currentPlate
.
push_back
(
area
);
qDebug
()
<<
"score 检测到的汽车数量匹配度:"
<<
car
.
score
;
}
qDebug
()
<<
"findHuManCar 检测到的汽车数量:"
<<
num
;
}
else
{
qDebug
()
<<
"参数错误"
;
}
TCV_ReleaseCameraStream
(
stream
);
return
num
;
return
num
;
}
HumanDetection.h
View file @
5fe7062a
#ifndef HUMANDETECTION_H
#define HUMANDETECTION_H
#include "VidesData.h"
#include "so_human_sdk.h"
#include <opencv2/opencv.hpp>
#include <QDebug>
...
...
@@ -9,17 +10,21 @@ public:
HumanDetection
();
~
HumanDetection
();
void
initDetector
();
int
findHuManCar
(
const
cv
::
Mat
&
source
,
int
res
,
TCV_HumanDetector
*
detector
);
int
findHuManCar
(
const
cv
::
Mat
&
source
,
int
res
,
TCV_HumanDetector
*
detector
,
std
::
vector
<
vides_data
::
ParkingArea
>
&
currentPlate
);
static
HumanDetection
&
getInstance
()
{
static
HumanDetection
instance
;
return
instance
;
}
void
setHeightReference
(
float
&
height_reference
);
void
draw_human_on_image
(
const
cv
::
Mat
&
image
,
const
TCV_ObjectLocation
*
boxes
,
int
size
);
private
:
static
HumanDetection
*
instance
;
//高度基准
float
height_reference
;
};
...
...
LicensePlateRecognition.cpp
View file @
5fe7062a
...
...
@@ -46,7 +46,7 @@ void LicensePlateRecognition::oldLicensePlateNumber(const cv::Mat &source,const
char
*
m_path
=
by_mpath
.
data
();
configuration
.
models_path
=
m_path
;
configuration
.
max_num
=
5
;
configuration
.
det_level
=
DETECT_LEVEL_
LOW
;
configuration
.
det_level
=
DETECT_LEVEL_
HIGH
;
configuration
.
use_half
=
false
;
configuration
.
nms_threshold
=
0.5
f
;
configuration
.
rec_confidence_threshold
=
0.8
f
;
...
...
@@ -89,7 +89,29 @@ void LicensePlateRecognition::oldLicensePlateNumber(const cv::Mat &source,const
HLPR_ReleaseContext
(
ctx1
);
}
void
LicensePlateRecognition
::
replaceWith1And0
(
QString
&
code
)
{
code
.
replace
(
QRegularExpression
(
"[Ii]"
),
"1"
);
code
.
replace
(
QRegularExpression
(
"[Oo]"
),
"0"
);
}
void
LicensePlateRecognition
::
filterLicensePlateConfidenceMax
(
vides_data
::
requestLicensePlate
&
plate
,
vides_data
::
LicensePlate
&
max
)
{
std
::
list
<
vides_data
::
LicensePlate
>
&
plates
=
plate
.
plates
;
// 使用引用避免复制列表
if
(
plates
.
empty
())
{
// 检查列表是否为空
// 如果列表为空,可能需要设定一个默认值或者抛出异常,这里简单地不改变max
return
;
}
max
=
plates
.
front
();
// 初始化max为第一个元素
float
maxConfidence
=
max
.
text_confidence
;
for
(
auto
it
=
plates
.
begin
();
it
!=
plates
.
end
();
++
it
)
{
if
(
it
->
text_confidence
>
maxConfidence
)
{
max
=
*
it
;
// 发现更高信心值的LicensePlate,更新max
maxConfidence
=
it
->
text_confidence
;
}
}
}
void
LicensePlateRecognition
::
licensePlateNumber
(
const
cv
::
Mat
&
source
,
QString
&
lpNumber
,
vides_data
::
requestLicensePlate
&
plate
,
qint64
currentTime
,
P_HLPR_Context
ctx
)
{
...
...
@@ -130,7 +152,10 @@ void LicensePlateRecognition::licensePlateNumber(const cv::Mat &source, QString
vides_data
::
LicensePlate
newPlate
;
newPlate
.
time
=
currentTime
;
newPlate
.
new_color
=
QString
::
fromStdString
(
type
);
newPlate
.
new_plate
=
QString
::
fromUtf8
(
results
.
plates
[
i
].
code
);
QString
car_nuber
=
QString
::
fromUtf8
(
results
.
plates
[
i
].
code
);
replaceWith1And0
(
car_nuber
);
qDebug
()
<<
"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
;
area
.
topLeftCornerX
=
results
.
plates
[
i
].
x1
;
...
...
LicensePlateRecognition.h
View file @
5fe7062a
...
...
@@ -9,6 +9,7 @@
#include <QFile>
#include <QImage>
#include <mutex>
#include <QRegularExpression>
const
std
::
vector
<
std
::
string
>
types
=
{
"蓝牌"
,
"黄牌单层"
,
"白牌单层"
,
"绿牌新能源"
,
"黑牌港澳"
,
...
...
@@ -24,16 +25,17 @@ public:
void
licensePlateNumber
(
const
cv
::
Mat
&
source
,
QString
&
lpNumber
,
vides_data
::
requestLicensePlate
&
plate
,
qint64
currentTime
,
P_HLPR_Context
ctx
);
void
filterLicensePlateConfidenceMax
(
vides_data
::
requestLicensePlate
&
plate
,
vides_data
::
LicensePlate
&
max
);
void
oldLicensePlateNumber
(
const
cv
::
Mat
&
source
,
const
QString
&
modelPaths
,
QString
&
lpNumber
);
// void initHlprContext(const QString &modelPaths,const QString &carCascade,float carConfidence);
// void initHlprContext(const QString &modelPaths,const QString &carCascade,float carConfidence);
void
replaceWith1And0
(
QString
&
code
);
private
:
static
LicensePlateRecognition
*
instance
;
//P_HLPR_Context ctx ;
float
carConfidence
;
std
::
mutex
carMutex
;
...
...
MediaFaceImage.cpp
View file @
5fe7062a
...
...
@@ -58,7 +58,7 @@ static int sdkInitCallback(XSDK_HANDLE hObject, int nMsgId, int nParam1,
QString
qString
(
szString
);
CameraHandle
*
cameraHandle
=
mediaFaceImage
->
getCurrentDevice
().
at
(
hObject
);
QThreadPool
*
threadPool
=
QThreadPool
::
globalInstance
();
threadPool
->
setMaxThreadCount
(
12
);
auto
taskCallBack
=
std
::
bind
(
&
CameraHandle
::
callbackFunction
,
cameraHandle
,
hObject
,
qString
);
auto
taskRunnable
=
new
TaskRunnable
(
taskCallBack
,
hObject
,
cameraHandle
->
getChannel
(),
RunFunction
::
SdkCallbackFunction
);
// task->setAutoDelete(false); // 确保task不会在执行后被自动删除
...
...
ParkingSpaceInfo.h
View file @
5fe7062a
...
...
@@ -9,12 +9,15 @@ public:
ParkingSpaceInfo
(
RecognizedInfo
&
currentPlate
);
ParkingSpaceInfo
();
~
ParkingSpaceInfo
();
RecognizedInfo
&
getCurrentPlate
();
void
setCurrentPlate
(
RecognizedInfo
&
current
);
void
addQueue
(
RecognizedInfo
&
info
);
void
removeQueue
();
void
removeNoQueue
();
QQueue
<
RecognizedInfo
>
&
getQueue
();
void
setArea
(
vides_data
::
ParkingArea
&
a
);
vides_data
::
ParkingArea
&
getArea
();
...
...
VidesData.h
View file @
5fe7062a
...
...
@@ -11,6 +11,10 @@
#include <QTextStream>
#include <QByteArray>
#include <QNetworkInterface>
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <list>
namespace
vides_data
{
constexpr
const
char
*
HEADER_TYPE_KAY
=
"Content-Type"
;
...
...
@@ -147,7 +151,7 @@ struct LicensePlate
QString
new_color
;
QByteArray
img
;
qint64
time
;
ParkingArea
recognition
;
ParkingArea
recognition
;
//识别区域
float
text_confidence
;
LicensePlate
()
{}
};
...
...
@@ -258,6 +262,7 @@ inline QString getDefaultGateway() {
#endif
return
gateway
;
}
inline
bool
pingAddress
(
const
QString
&
address
)
{
QProcess
process
;
QString
program
=
"ping"
;
...
...
gamera_videos.pro
View file @
5fe7062a
QT
+=
core
gui
network
multimedia
sql
concurrent
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
CONFIG
+=
c
++
11
...
...
@@ -11,46 +12,46 @@ TEMPLATE = app
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES
+=
QT_DEPRECATED_WARNINGS
DEFINES
+=
APP_VERSION
=
\\\
"1.0.
1
\\\"
QMAKE_LIBDIR
+=
/
usr
/
local
/
lib
INCLUDEPATH
+=/
usr
/
local
/
include
/
opencv4
INCLUDEPATH
+=/
usr
/
local
/
include
/
hyperface
INCLUDEPATH
+=/
usr
/
local
/
include
/
hyper
INCLUDEPATH
+=/
usr
/
local
/
include
/
XNetSDK
INCLUDEPATH
+=/
usr
/
local
/
include
/
human
INCLUDEPATH
+=/
usr
/
local
/
include
/
CImg
#
unix:contains(QMAKE_HOST.arch, x86_64) {
#
QMAKE_LIBDIR += /home/mark/Public/x86_opencv/lib
#
}
#
unix:contains(QMAKE_HOST.arch, arm) {
#
QMAKE_LIBDIR += /usr/local/lib
#
}
#
#
根据编译器类型选择库路径和头文件路径
#
unix: {
#
# x86 架构
#
contains(QMAKE_HOST.arch, x86_64) {
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/opencv4
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/hyperface
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/hyper
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/XNetSDK
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/human
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/CImg
#
}
#
# ARM 架构
#
contains(QMAKE_HOST.arch, arm) {
#
INCLUDEPATH+=/usr/local/include/opencv4
#
INCLUDEPATH+=/usr/local/include/hyperface
#
INCLUDEPATH+=/usr/local/include/hyper
#
INCLUDEPATH+=/usr/local/include/XNetSDK
#
INCLUDEPATH+=/usr/local/include/human
#
}
#
}
DEFINES
+=
APP_VERSION
=
\\\
"1.0.
2
\\\"
#
QMAKE_LIBDIR += /usr/local/lib
#
INCLUDEPATH+=/usr/local/include/opencv4
#
INCLUDEPATH+=/usr/local/include/hyperface
#
INCLUDEPATH+=/usr/local/include/hyper
#
INCLUDEPATH+=/usr/local/include/XNetSDK
#
INCLUDEPATH+=/usr/local/include/human
#
INCLUDEPATH+=/usr/local/include/CImg
unix
:
contains
(
QMAKE_HOST
.
arch
,
x86_64
)
{
QMAKE_LIBDIR
+=
/
home
/
mark
/
Public
/
x86_opencv
/
lib
}
unix
:
contains
(
QMAKE_HOST
.
arch
,
arm
)
{
QMAKE_LIBDIR
+=
/
usr
/
local
/
lib
}
# 根据编译器类型选择库路径和头文件路径
unix
:
{
#
x86
架构
contains
(
QMAKE_HOST
.
arch
,
x86_64
)
{
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
opencv4
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
hyperface
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
hyper
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
XNetSDK
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
human
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
CImg
}
#
ARM
架构
contains
(
QMAKE_HOST
.
arch
,
arm
)
{
INCLUDEPATH
+=/
usr
/
local
/
include
/
opencv4
INCLUDEPATH
+=/
usr
/
local
/
include
/
hyperface
INCLUDEPATH
+=/
usr
/
local
/
include
/
hyper
INCLUDEPATH
+=/
usr
/
local
/
include
/
XNetSDK
INCLUDEPATH
+=/
usr
/
local
/
include
/
human
}
}
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
...
...
mainwindow.cpp
View file @
5fe7062a
...
...
@@ -63,7 +63,17 @@ MainWindow::MainWindow()
connect
(
dePermissionSynTimer
,
&
QTimer
::
timeout
,
this
,
[
this
,
httpurl
](){
this
->
startCamera
(
httpurl
);
},
Qt
::
QueuedConnection
);
dePermissionSynTimer
->
start
(
dePermissionTimer
);
this
->
startCamera
(
httpurl
);
// 设置定时器间隔
dePermissionSynTimer
->
setInterval
(
dePermissionTimer
);
// 启动定时器
dePermissionSynTimer
->
start
();
//dePermissionSynTimer->start(dePermissionTimer);
//vides_data::scanWiFiNetworks();
connect
(
&
server
,
&
QTcpServer
::
newConnection
,
this
,
&
MainWindow
::
handleMatNewConnection
);
...
...
@@ -76,6 +86,7 @@ MainWindow::MainWindow()
}
}
CameraHandle
*
MainWindow
::
findHandle
(
QString
sn
){
for
(
auto
it
=
faceDetectionParkingPushs
.
begin
();
it
!=
faceDetectionParkingPushs
.
end
();
++
it
)
{
QString
currentSn
=
it
->
second
->
getSSn
();
...
...
@@ -751,8 +762,11 @@ void MainWindow::initCameras(vides_data::cameraParameters ¶meter,const std::
MediaFaceImage
*
mediaFaceImage
=
MediaFaceImage
::
getInstance
();
float
carConfidence
=
qSetting
->
value
(
"devices/carConfidence"
).
toFloat
();
int
image_save
=
qSetting
->
value
(
"devices/image_save"
).
toInt
();
float
heightReference
=
qSetting
->
value
(
"devices/height_reference"
).
toFloat
();
float
carShapeConfidence
=
qSetting
->
value
(
"devices/carShapeConfidence"
).
toFloat
();
CameraHandle
*
cameraHandle
=
new
CameraHandle
(
parameter
.
sDevId
,
parameter
.
httpUrl
,
parameter
.
sSn
,
parameter
.
channel
,
modelPaths
,
carConfidence
,
image_save
);
CameraHandle
*
cameraHandle
=
new
CameraHandle
(
parameter
.
sDevId
,
parameter
.
httpUrl
,
parameter
.
sSn
,
parameter
.
channel
,
modelPaths
,
carConfidence
,
carShapeConfidence
,
image_save
);
int
sdk_handle
=
cameraHandle
->
sdkDevLoginSyn
(
parameter
.
sDevId
,
parameter
.
nDevPort
,
parameter
.
sUserName
,
parameter
.
sPassword
,
10000
);
qDebug
()
<<
"句柄为2:"
<<
sdk_handle
;
...
...
@@ -763,11 +777,16 @@ void MainWindow::initCameras(vides_data::cameraParameters ¶meter,const std::
initDevConfigSyn
(
cameraHandle
);
mediaFaceImage
->
setMap
(
sdk_handle
,
cameraHandle
);
cameraHandle
->
sdkDevSetAlarmListener
(
sdk_handle
,
1
);
cameraHandle
->
sdkDevSetAlarmListener
(
sdk_handle
,
0
);
int
synTime
=
qSetting
->
value
(
"timer/dev_snap_syn_timer"
).
toInt
();
uint64
face_frequency
=
qSetting
->
value
(
"devices/face_frequency"
).
toULongLong
();
cameraHandle
->
initSdkRealTimeDevSnapSyn
(
sdk_handle
,
synTime
,
face_frequency
);
cameraHandle
->
initAlgorithmParameter
(
heightReference
);
QString
pwd
=
"admin2024"
;
QString
sid
=
"MERCURY_8C4F"
;
cameraHandle
->
sdkWifi
(
pwd
,
sid
);
vides_data
::
requestCameraInfo
camera_info
;
camera_info
.
sSn
=
parameter
.
sSn
;
camera_info
.
ip_addr
=
parameter
.
sDevId
;
...
...
mainwindow.h
View file @
5fe7062a
...
...
@@ -50,7 +50,7 @@ public:
static
MainWindow
*
sp_this
;
CameraHandle
*
findHandle
(
QString
sn
);
void
sendJsonResponse
(
QTcpSocket
*
socket
,
int
code
,
const
QString
&
data
,
const
QString
&
msg
);
void
sendEmptyResponse
(
QTcpSocket
*
socket
);
...
...
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