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
264b6d6a
Commit
264b6d6a
authored
Apr 19, 2024
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决opencv arm imread
parent
af92429f
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
49 deletions
+86
-49
CameraHandle.cpp
+4
-2
FaceRecognition.h
+4
-0
FaceReconition.cpp
+35
-5
HttpService.cpp
+1
-0
Httpclient.cpp
+1
-1
HumanDetection.cpp
+1
-1
gamera_videos.pro
+37
-37
mainwindow.cpp
+3
-3
No files found.
CameraHandle.cpp
View file @
264b6d6a
...
@@ -20,8 +20,8 @@ CameraHandle::CameraHandle(QString &url, QString &httpUrl, QString &sSn, int &ch
...
@@ -20,8 +20,8 @@ CameraHandle::CameraHandle(QString &url, QString &httpUrl, QString &sSn, int &ch
connect
(
this
,
SIGNAL
(
afterDownloadFile
(
int
,
int
,
QString
)),
this
,
SLOT
(
pushRecordToCloud
(
int
,
int
,
QString
)),
Qt
::
QueuedConnection
);
connect
(
this
,
SIGNAL
(
afterDownloadFile
(
int
,
int
,
QString
)),
this
,
SLOT
(
pushRecordToCloud
(
int
,
int
,
QString
)),
Qt
::
QueuedConnection
);
detector
=
TCV_CreateHumanDetector
();
detector
=
TCV_CreateHumanDetector
();
// 设置检测得分阈值 默认0.5
// 设置检测得分阈值 默认0.5
//
TCV_HumanDetectorSetHumanThreshold(detector,0.5f);
TCV_HumanDetectorSetHumanThreshold
(
detector
,
0.5
f
);
//
TCV_HumanDetectorSetCarThreshold(detector,0.2f);
TCV_HumanDetectorSetCarThreshold
(
detector
,
0.2
f
);
HLPR_ContextConfiguration
configuration
=
{
0
};
HLPR_ContextConfiguration
configuration
=
{
0
};
QByteArray
&&
by_mpath
=
modelPaths
.
toUtf8
();
QByteArray
&&
by_mpath
=
modelPaths
.
toUtf8
();
...
@@ -531,6 +531,8 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
...
@@ -531,6 +531,8 @@ void CameraHandle::updateImage(const cv::Mat & frame,qint64 currentTime){
vides_data
::
response
*
resp
=
httpService
.
httpPostFaceReconition
(
faceReconition
);
vides_data
::
response
*
resp
=
httpService
.
httpPostFaceReconition
(
faceReconition
);
if
(
resp
->
code
!=
0
)
{
if
(
resp
->
code
!=
0
)
{
qInfo
()
<<
"识别人code"
<<
resp
->
code
;
qInfo
()
<<
"识别人msg"
<<
resp
->
msg
;
qInfo
()
<<
"识别人脸信息推送失败"
<<
face
.
id
;
qInfo
()
<<
"识别人脸信息推送失败"
<<
face
.
id
;
}
}
instace
.
deleteObj
(
resp
);
instace
.
deleteObj
(
resp
);
...
...
FaceRecognition.h
View file @
264b6d6a
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "herror.h"
#include "herror.h"
#include "LogHandle.h"
#include "LogHandle.h"
#include "VidesData.h"
#include "VidesData.h"
#include <QReadWriteLock>
class
FaceReconition
class
FaceReconition
{
{
...
@@ -18,6 +19,8 @@ private:
...
@@ -18,6 +19,8 @@ private:
std
::
vector
<
int32_t
>
customIds
;
std
::
vector
<
int32_t
>
customIds
;
QReadWriteLock
rwLock
;
FaceReconition
();
FaceReconition
();
~
FaceReconition
();
~
FaceReconition
();
...
@@ -28,6 +31,7 @@ public:
...
@@ -28,6 +31,7 @@ public:
static
FaceReconition
instance
;
static
FaceReconition
instance
;
return
instance
;
return
instance
;
}
}
cv
::
Mat
loadImage
(
const
QString
&
path
);
void
doesItExistEmployee
(
const
cv
::
Mat
&
source
,
std
::
list
<
vides_data
::
faceRecognitionResult
>&
face
);
void
doesItExistEmployee
(
const
cv
::
Mat
&
source
,
std
::
list
<
vides_data
::
faceRecognitionResult
>&
face
);
...
...
FaceReconition.cpp
View file @
264b6d6a
#include "FaceRecognition.h"
#include "FaceRecognition.h"
#include <QImage>
#include <QThread>
#include <QThread>
...
@@ -14,7 +15,34 @@ FaceReconition::~FaceReconition(){
...
@@ -14,7 +15,34 @@ FaceReconition::~FaceReconition(){
FaceReconition
*
FaceReconition
::
instance
=
nullptr
;
FaceReconition
*
FaceReconition
::
instance
=
nullptr
;
cv
::
Mat
FaceReconition
::
loadImage
(
const
QString
&
path
)
{
// 尝试使用OpenCV直接加载图像
std
::
string
stdPath
=
path
.
toStdString
();
// 将路径转换为std::string
cv
::
Mat
image
=
cv
::
imread
(
stdPath
,
cv
::
IMREAD_COLOR
);
// 尝试加载图像
if
(
!
image
.
empty
())
{
qDebug
()
<<
"图像以OpenCV成功加载。"
;
return
image
;
}
// 使用OpenCV加载失败,尝试使用QImage
qDebug
()
<<
"使用OpenCV加载图像失败,尝试QImage转换。"
;
QImage
qimg
(
path
);
if
(
qimg
.
isNull
())
{
qDebug
()
<<
"QImage也无法加载图像,检查文件路径或文件损坏。"
;
return
cv
::
Mat
();
// 返回空的cv::Mat对象
}
// 转换QImage格式为RGB888
QImage
converted
=
qimg
.
convertToFormat
(
QImage
::
Format_RGB888
);
cv
::
Mat
mat
(
converted
.
height
(),
converted
.
width
(),
CV_8UC3
,
const_cast
<
uchar
*>
(
converted
.
bits
()),
converted
.
bytesPerLine
());
// 将RGB转换为BGR,以便OpenCV处理
cv
::
cvtColor
(
mat
,
mat
,
cv
::
COLOR_RGB2BGR
);
return
mat
;
}
void
FaceReconition
::
initSourceImageMap
(
std
::
map
<
QString
,
QString
>&
maps
,
float
confidence
){
void
FaceReconition
::
initSourceImageMap
(
std
::
map
<
QString
,
QString
>&
maps
,
float
confidence
){
//QWriteLocker locker(&rwLock);
featureRemove
();
featureRemove
();
HResult
ret
;
HResult
ret
;
// 初始化context
// 初始化context
...
@@ -42,15 +70,16 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con
...
@@ -42,15 +70,16 @@ void FaceReconition::initSourceImageMap(std::map<QString,QString>&maps,float con
}
}
customIds
.
clear
();
customIds
.
clear
();
int
i
=
0
;
int
i
=
0
;
qInfo
()
<<
"加载图像size: "
<<
maps
.
size
();
for
(
auto
it
=
maps
.
begin
();
it
!=
maps
.
end
();
++
it
,
++
i
)
{
for
(
auto
it
=
maps
.
begin
();
it
!=
maps
.
end
();
++
it
,
++
i
)
{
const
QString
&
key
=
it
->
first
;
const
QString
&
key
=
it
->
first
;
const
QString
&
value
=
it
->
second
;
QString
&
value
=
it
->
second
;
cv
::
Mat
image
=
cv
::
imread
(
value
.
toStdString
()
);
cv
::
Mat
image
=
loadImage
(
value
);
if
(
image
.
empty
())
{
if
(
image
.
empty
())
{
qInfo
()
<<
"错误:图像为空或路径不正确,无法加载图像 "
;
qInfo
()
<<
"错误:使用QImage预处理无法加载图像 "
<<
value
;
return
;
continue
;
}
}
HF_ImageData
imageData
=
{
0
};
HF_ImageData
imageData
=
{
0
};
imageData
.
data
=
image
.
data
;
imageData
.
data
=
image
.
data
;
imageData
.
height
=
image
.
rows
;
imageData
.
height
=
image
.
rows
;
...
@@ -121,6 +150,7 @@ int FaceReconition::featureRemove(){
...
@@ -121,6 +150,7 @@ int FaceReconition::featureRemove(){
}
}
}
}
void
FaceReconition
::
doesItExistEmployee
(
const
cv
::
Mat
&
source
,
std
::
list
<
vides_data
::
faceRecognitionResult
>&
faces
){
void
FaceReconition
::
doesItExistEmployee
(
const
cv
::
Mat
&
source
,
std
::
list
<
vides_data
::
faceRecognitionResult
>&
faces
){
//QReadLocker locker(&rwLock);
HResult
ret
;
HResult
ret
;
HF_ContextCustomParameter
parameter
=
{
0
};
HF_ContextCustomParameter
parameter
=
{
0
};
HF_ImageData
imageData
=
{
0
};
HF_ImageData
imageData
=
{
0
};
...
...
HttpService.cpp
View file @
264b6d6a
...
@@ -301,6 +301,7 @@ vides_data::response *HttpService::httpPostFacePopulation(QByteArray &img,int &n
...
@@ -301,6 +301,7 @@ vides_data::response *HttpService::httpPostFacePopulation(QByteArray &img,int &n
vides_data
::
response
*
HttpService
::
httpPostFaceReconition
(
vides_data
::
requestFaceReconition
&
faceReconition
){
vides_data
::
response
*
HttpService
::
httpPostFaceReconition
(
vides_data
::
requestFaceReconition
&
faceReconition
){
httpUrl
.
append
(
"/api/v1.0/recongnition/face"
);
httpUrl
.
append
(
"/api/v1.0/recongnition/face"
);
qDebug
()
<<
"httpPostFaceReconition"
<<
httpUrl
;
QJsonObject
json
;
QJsonObject
json
;
json
.
insert
(
"id"
,
QJsonValue
::
fromVariant
(
faceReconition
.
id
.
toInt
()));
json
.
insert
(
"id"
,
QJsonValue
::
fromVariant
(
faceReconition
.
id
.
toInt
()));
json
.
insert
(
"img"
,
QJsonValue
::
fromVariant
(
faceReconition
.
img
));
json
.
insert
(
"img"
,
QJsonValue
::
fromVariant
(
faceReconition
.
img
));
...
...
Httpclient.cpp
View file @
264b6d6a
...
@@ -7,7 +7,7 @@ HttpClient::HttpClient(QObject *parent)
...
@@ -7,7 +7,7 @@ HttpClient::HttpClient(QObject *parent)
{
{
m_networkAccessManager
=
new
QNetworkAccessManager
(
this
);
m_networkAccessManager
=
new
QNetworkAccessManager
(
this
);
m_timer
=
new
QTimer
(
this
);
m_timer
=
new
QTimer
(
this
);
m_timer
->
setInterval
(
4
000
);
m_timer
->
setInterval
(
6
000
);
m_timer
->
setSingleShot
(
true
);
m_timer
->
setSingleShot
(
true
);
connect
(
m_timer
,
SIGNAL
(
timeout
()),
&
m_eventLoop
,
SLOT
(
quit
()));
connect
(
m_timer
,
SIGNAL
(
timeout
()),
&
m_eventLoop
,
SLOT
(
quit
()));
}
}
...
...
HumanDetection.cpp
View file @
264b6d6a
...
@@ -15,7 +15,7 @@ int HumanDetection::findHuManCar(const cv::Mat &source,int res,TCV_HumanDetector
...
@@ -15,7 +15,7 @@ int HumanDetection::findHuManCar(const cv::Mat &source,int res,TCV_HumanDetector
// 执行一帧目标检测
// 执行一帧目标检测
TCV_HumanDetectorProcessFrame
(
detector
,
stream
);
TCV_HumanDetectorProcessFrame
(
detector
,
stream
);
int
num
=
(
res
==
0
)
?
TCV_HumanDetectorGetNumOfHuman
(
detector
)
:
0
;
//
TCV_HumanDetectorGetNumOfCar(detector);
int
num
=
(
res
==
0
)
?
TCV_HumanDetectorGetNumOfHuman
(
detector
)
:
TCV_HumanDetectorGetNumOfCar
(
detector
);
qDebug
()
<<
(
res
==
0
?
"Number of people detected:"
:
"Number of cars detected:"
)
<<
num
;
qDebug
()
<<
(
res
==
0
?
"Number of people detected:"
:
"Number of cars detected:"
)
<<
num
;
TCV_ReleaseCameraStream
(
stream
);
TCV_ReleaseCameraStream
(
stream
);
...
...
gamera_videos.pro
View file @
264b6d6a
...
@@ -13,43 +13,43 @@ TEMPLATE = app
...
@@ -13,43 +13,43 @@ TEMPLATE = app
DEFINES
+=
QT_DEPRECATED_WARNINGS
DEFINES
+=
QT_DEPRECATED_WARNINGS
#
QMAKE_LIBDIR += /usr/local/lib
QMAKE_LIBDIR
+=
/
usr
/
local
/
lib
#
INCLUDEPATH+=/usr/local/include/opencv4
INCLUDEPATH
+=/
usr
/
local
/
include
/
opencv4
#
INCLUDEPATH+=/usr/local/include/hyperface
INCLUDEPATH
+=/
usr
/
local
/
include
/
hyperface
#
INCLUDEPATH+=/usr/local/include/hyper
INCLUDEPATH
+=/
usr
/
local
/
include
/
hyper
#
INCLUDEPATH+=/usr/local/include/XNetSDK
INCLUDEPATH
+=/
usr
/
local
/
include
/
XNetSDK
#
INCLUDEPATH+=/usr/local/include/human
INCLUDEPATH
+=/
usr
/
local
/
include
/
human
unix
:
contains
(
QMAKE_HOST
.
arch
,
x86_64
)
{
#
unix:contains(QMAKE_HOST.arch, x86_64) {
QMAKE_LIBDIR
+=
/
home
/
mark
/
Public
/
x86_opencv
/
lib
#
QMAKE_LIBDIR += /home/mark/Public/x86_opencv/lib
}
#
}
unix
:
contains
(
QMAKE_HOST
.
arch
,
arm
)
{
#
unix:contains(QMAKE_HOST.arch, arm) {
QMAKE_LIBDIR
+=
/
usr
/
local
/
lib
#
QMAKE_LIBDIR += /usr/local/lib
}
#
}
# 根据编译器类型选择库路径和头文件路径
#
#
根据编译器类型选择库路径和头文件路径
unix
:
{
#
unix: {
#
x86
架构
#
# x86 架构
contains
(
QMAKE_HOST
.
arch
,
x86_64
)
{
#
contains(QMAKE_HOST.arch, x86_64) {
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
opencv4
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/opencv4
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
hyperface
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/hyperface
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
hyper
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/hyper
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
XNetSDK
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/XNetSDK
INCLUDEPATH
+=/
home
/
mark
/
Public
/
x86_opencv
/
include
/
human
#
INCLUDEPATH+=/home/mark/Public/x86_opencv/include/human
}
#
}
#
ARM
架构
#
# ARM 架构
contains
(
QMAKE_HOST
.
arch
,
arm
)
{
#
contains(QMAKE_HOST.arch, arm) {
INCLUDEPATH
+=/
usr
/
local
/
include
/
opencv4
#
INCLUDEPATH+=/usr/local/include/opencv4
INCLUDEPATH
+=/
usr
/
local
/
include
/
hyperface
#
INCLUDEPATH+=/usr/local/include/hyperface
INCLUDEPATH
+=/
usr
/
local
/
include
/
hyper
#
INCLUDEPATH+=/usr/local/include/hyper
INCLUDEPATH
+=/
usr
/
local
/
include
/
XNetSDK
#
INCLUDEPATH+=/usr/local/include/XNetSDK
INCLUDEPATH
+=/
usr
/
local
/
include
/
human
#
INCLUDEPATH+=/usr/local/include/human
}
#
}
}
#
}
# You can also make your code fail to compile if it uses deprecated APIs.
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# In order to do so, uncomment the following line.
...
...
mainwindow.cpp
View file @
264b6d6a
...
@@ -827,8 +827,8 @@ void MainWindow::deleteMkvFileTimer(){
...
@@ -827,8 +827,8 @@ void MainWindow::deleteMkvFileTimer(){
void
MainWindow
::
deleteLogFile
(){
void
MainWindow
::
deleteLogFile
(){
QDateTime
now
=
QDateTime
::
currentDateTime
();
QDateTime
now
=
QDateTime
::
currentDateTime
();
QDir
logDir
(
"log"
);
QDir
logDir
(
"log"
);
// 前
3
天
// 前
7
天
QDateTime
dateTime1
=
now
.
addDays
(
-
3
);
QDateTime
dateTime1
=
now
.
addDays
(
-
7
);
QDateTime
dateTime2
;
QDateTime
dateTime2
;
QString
logPath
=
logDir
.
absoluteFilePath
(
""
);
// 日志的路径
QString
logPath
=
logDir
.
absoluteFilePath
(
""
);
// 日志的路径
...
@@ -845,7 +845,7 @@ void MainWindow::deleteLogFile(){
...
@@ -845,7 +845,7 @@ void MainWindow::deleteLogFile(){
continue
;
continue
;
dateTime2
=
QDateTime
::
fromString
(
f
.
baseName
(),
"yyyy-MM-dd"
);
dateTime2
=
QDateTime
::
fromString
(
f
.
baseName
(),
"yyyy-MM-dd"
);
if
(
dateTime2
<
dateTime1
)
{
// 只要日志时间小于前
3
天的时间就删除
if
(
dateTime2
<
dateTime1
)
{
// 只要日志时间小于前
7
天的时间就删除
dir
.
remove
(
f
.
absoluteFilePath
());
dir
.
remove
(
f
.
absoluteFilePath
());
}
}
}
}
...
...
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