FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CameraSensing/uplugin_face/recognition.cpp at master · folkcode/CameraSensing · GitHub
folkcode
/
CameraSensing
Public
forked from
sonnyky/CameraSensing
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
CameraSensing
/
uplugin_face
/
recognition.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (63 loc) · 1.66 KB
Breadcrumbs
CameraSensing
/
uplugin_face
/
recognition.cpp
Copy path
File metadata and controls
81 lines (63 loc) · 1.66 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#
include
"
recognition.h
"
#
include
"
detection.h
"
#
define
SAMPLE_READ_WAIT_TIMEOUT
2000
//
2000ms
#
pragma
once
const
std::string no_camera_message =
"
No camera connected, please connect 1 or more
"
;
const
std::string platform_camera_name =
"
Platform Camera
"
;
recognition::recognition
()
{
face_cascade.
load
(
"
lbpcascade_frontalface.xml
"
);
if
(face_cascade.
empty
()) {
error =
"
cascade load error
"
;
}
}
recognition::~recognition
()
{
}
void
recognition::set_error_message
(std::string error) {
error_message = error.
c_str
();
}
const
char
*
recognition::get_plugin_name
() {
return
plugin_name;
}
const
char
*
recognition::get_error_message
() {
return
error_message;
}
void
recognition::destroy_class
() {
delete
this
;
}
void
recognition::detect_faces
(
unsigned
char
* input,
unsigned
char
* processed,
int
width,
int
height)
{
Mat
image
(height, width,
CV_8UC4
);
memcpy
(image.
data
, input, height * width *
4
);
Mat frame_gray;
cvtColor
(image, frame_gray,
COLOR_RGBA2GRAY
);
equalizeHist
(frame_gray, frame_gray);
std::vector<Rect> faces;
face_cascade.
detectMultiScale
(frame_gray, faces);
for
(
size_t
i =
0
; i < faces.
size
(); i++)
{
rectangle
(image, faces[i],
Scalar
(
255.0
,
0.0
,
255.0
,
1.0
),
2
,
8
,
0
);
}
memcpy
(processed, image.
data
, height * width *
4
);
}
void
recognition::setup_camera
() {
if
(cap.
isOpened
()) {
return
;
}
else
{
cap.
open
(
0
);
}
}
void
recognition::get_color_image
(
unsigned
char
* data,
int
&width,
int
&height){
Mat frame;
cap >> frame;
Mat rgbImg;
cvtColor
(frame, rgbImg,
CV_BGR2RGBA
);
width = frame.
cols
;
height = frame.
rows
;
memcpy
(data, rgbImg.
data
, rgbImg.
total
() * rgbImg.
elemSize
());
}
void
recognition::release_camera
() {
cap.
release
();
}
Back
|
FazBrowse Home
|
New Git URL