-
Notifications
You must be signed in to change notification settings - Fork 41
/
wiki_page.txt
278 lines (228 loc) · 14.7 KB
/
wiki_page.txt
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<<PackageHeader(face_recognition)>>
<<TOC(4)>>
The ProcRob face_recognition package can be downloaded from https://github.com/procrob/procrob_functional . For usage guide, please see below. For details of the face recognition algorithm used, please see http://www.shervinemami.info/faceRecognition.html .
== Installation ==
<<Buildsystem()>>
{{{{#!wiki buildsystem rosbuild
This instalation process is for '''rosbuild''' (ROS Fuerte or earlier version)
Assuming that your rosbuild workspace (rosws) is under '''~/rosbuild_ws''', if not replace '''~/rosbuild_ws''' with appropriate location. It also assumes you're running Bash shell, if you're running Zsh, source appropriate '''setup.zsh''' file.
Execute:
{{{
$ cd ~/rosbuild_ws
$ rosws set face_recognition --git git://github.com/procrob/procrob_functional.git
$ rosws update
}}}
In new terminal
{{{
$ rosmake face_recognition
}}}
== How the face recognition works: ==
Training images are stored in the '''data''' directory. <<BR>>
Training images are listed in the '''train.text''' file. <<BR>>
The '''train.txt''' follows a specific format which is best understood by looking at the example '''train.txt''' file provided in the package. Note that person numbers start from 1, and spaces or special characters are not allowed in persons' names).<<BR>>
The program trains from the training examples listed in the '''train.txt''' and create an Eigenfaces database which is stored in the '''facedata.xml''' file.<<BR>>
Face detection is performed using a haarcascade classifier (haarcascade_frontalface_alt.xml).<<BR>>
The '''data''' folder, and '''train.txt''', '''facedata.xml''' and '''haarcascade_frontalface_alt.xml'''
files should be placed in the program's working directory (i.e. the directory from which you execute the program). <<BR>>
When the face_recognition program starts:<<BR>>
If '''facedata.xml''' exists, the Eigenfaces database is loaded from '''facedata.xml'''.<<BR>>
If '''facedata.xml''' does not exist, the program tries to train and create Eigenfaces database from the training images listed in '''train.txt''', if any.<<BR>>
Regardless of if the Eigenfaces database is loaded/created at start up or not, you can always add training images directly from the video stream and then update the Eigenfaces database by (re)training.<<BR>>
Note: when the program (re)trains, the content of '''facedata.xml''' is disregarded and the program trains only based on the training images listed in '''train.txt'''.
== Fserver ==
Fserver is a ROS node that provides a simple actionlib server interface for performing different face recognition functionalities in video stream.
To start the Fserver node
{{{
$ roscd face_recognition
$ rosrun face_recognition Fserver
}}}
=== FaceRecognitionGoal message ===
This message includes 2 fields:
* ''int'' '''order_id'''
* ''string'' '''order_argument'''
The FaceRecognitionGoal message has 2 fields: an '''order_id''' which is an integer specifying a goal and an '''order_argument''' which is a string used to specify an argument for the goal if necessary. The face recognition actionlib server (i.e. '''Fserver''') accepts 5 different goals:
* '''order_id''' = 0
recognise_once: Goal is to acknowledge the first face recognized in the video stream. When the first face is recognized with a confidence value higher than the desirable confidence value threshold, the name of the recognized person and its confidence value are sent back to the client as result.
* '''order_id''' = 1
recognise_continuous: Goal is to continuously recognise faces in the video stream. For every face recognized with a confidence value higher than the desirable confidence value threshold, the name of the recognized person and its confidence value are sent back to the client as feedback. This goal is persuaded for infinite time until it is cancelled or preempted by another goal.
* '''order_id''' = 2 and '''order_argument''' = 'person_name'
add_face_images: Goal is to acquire training images for a NEW person. The video stream is processed for detecting a face which is saved and used as a training image for the new person. This process is continued until the desired number of training images for the new person is acquired. The name of the new person is provided as '''order_argument'''. The acquired images are stored in the 'data' folder and are added to the list of training images in '''train.txt'''
* '''order_id''' = 3
train: Goal is to (re)train the Eigenfaces database from the training images listed in the 'train.txt'.
* '''order_id''' = 4
exit: Goal is to exit the program.
=== Subscribed Topic: ===
* '''/camera/image_raw''' (standard ROS image transport)
A video stream
=== Parameters: ===
* '''confidence_value''' (''double'', default = 0.88)
A face recognized with confidence value higher than the "confidence_value" threshold is accepted as valid.
* '''show_screen_flag''' (''boolean'', default = true)
If output screen is shown.
* '''add_face_number''' (''int'', default = 25)
A parameter for the 'add_face_images' goal (order_id = 2) which determines the number of training images for a new person to be acquired from the video stream
== Fclient ==
'''Fclient''' is a ROS node that implements an actionlib client example for the face_recognition simple actionlib server (i.e. 'Fserver'). 'Fclient' is provided for demonstration and testing purposes.
=== Subscribed topics ===
* '''fr_order''' (face_recognition/FRClientGoal)
Each '''FRClientGoal''' message has an '''order_id''' and an '''order_argument''' which specify a goal to be executed by the '''Fserver'''. After receiving a message, '''Fclient''' sends the corresponding goal to the '''Fserver'''. By registering relevant call back functions, '''Fclient''' receives feedback and result information from the execution of goals in the '''Fserver''' and prints such information on its terminal.
== Tutorial ==
(You have to install gscam to do this tutorial)
An exercise of using Fserver and Fclient: <<BR>>
* Run roscore
{{{
$ roscore
}}}
* In a separate terminal publish a video stream on topic '''/camera/image_raw'''. If you have the gscam package installed and configured, you can use it to publish images from your web cam as follows:
{{{
$ roscd gscam/bin
$ rosrun gscam gscam /gscam/image_raw:=/camera/image_raw
}}}
* In separate terminals run the face recognition server and client as follows:
{{{
$ rosrun face_recognition Fserver
$ rosrun face_recognition Fclient
}}}
* In another terminal publish following messages on topic /fr_order to test different face recognition functionalities.
* After each command notice the output of Fserver and Fclient.
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 2 "your_name"
}}}
* To acquire training images for your face: you should try to appear in the video stream!
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 3 "none"
}}}
* To retrain and update the database, so that you can be recognized
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 1 "none"
}}}
* To recognise faces continuously. This would not stop until you preempt or cancel the goal. So lets preempt it by sending the next goal.
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 2 "your_friend's_name"
}}}
* To add training images for a new person
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 0 "none"
}}}
* To recognize once a face.
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 1 "none"
}}}
* To recognize continuously
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 4 "none"
}}}
* To exit
}}}}
{{{{#!wiki buildsystem catkin
This instalation process is for '''catkin''' (ROS Groovy or newer version)
Assuming that your catkin workspace is under '''~/catkin_ws''', if not replace '''~/catkin_ws''' with appropriate location. It also assumes you're running Bash shell, if you're running Zsh, source appropriate setup.zsh file.
Execute:
{{{
$ cd ~/catkin_ws/src
$ git clone https://github.com/procrob/procrob_functional.git --branch catkin
$ cd ~/catkin_ws
$ catkin_make
$ source ~/catkin_ws/devel/setup.bash
}}}
== How the face recognition works: ==
Training images are stored in the '''data''' directory. <<BR>>
Training images are listed in the '''train.text''' file. <<BR>>
The 'train.txt' follows a specific format which is best understood by looking at the example '''train.txt''' file provided in the package. Note that person numbers start from 1, and spaces or special characters are not allowed in persons' names).<<BR>>
The program trains from the training examples listed in the '''train.txt''' and create an Eigenfaces database which is stored in the '''facedata.xml''' file.<<BR>>
Face detection is performed using a haarcascade classifier (haarcascade_frontalface_alt.xml).<<BR>>
The '''data''' folder, and '''train.txt''', '''facedata.xml''' and '''haarcascade_frontalface_alt.xml'''
files should be placed in the program's working directory (i.e. the directory from which you execute the program). <<BR>>
When the face_recognition program starts:<<BR>>
If '''facedata.xml''' exists, the Eigenfaces database is loaded from '''facedata.xml'''.<<BR>>
If '''facedata.xml''' does not exist, the program tries to train and create Eigenfaces database from the training images listed in '''train.txt''', if any.<<BR>>
Regardless of if the Eigenfaces database is loaded/created at start up or not, you can always add training images directly from the video stream and then update the Eigenfaces database by (re)training.<<BR>>
Note: when the program (re)trains, the content of '''facedata.xml''' is disregarded and the program trains only based on the training images listed in '''train.txt'''.
== Fserver ==
Fserver is a ROS node that provides a simple actionlib server interface for performing different face recognition functionalities in video stream.
To start the Fserver node
{{{
$ roscd face_recognition
$ rosrun face_recognition Fserver
}}}
=== FaceRecognitionGoal message ===
This message includes 2 fields:
* ''int'' '''order_id'''
* ''string'' '''order_argument'''
The FaceRecognitionGoal message has 2 fields: an '''order_id''' which is an integer specifying a goal and an '''order_argument''' which is a string used to specify an argument for the goal if necessary. The face recognition actionlib server (i.e. '''Fserver''') accepts 5 different goals:
* '''order_id''' = 0
recognise_once: Goal is to acknowledge the first face recognized in the video stream. When the first face is recognized with a confidence value higher than the desirable confidence value threshold, the name of the recognized person and its confidence value are sent back to the client as result.
* '''order_id''' = 1
recognise_continuous: Goal is to continuously recognise faces in the video stream. For every face recognized with a confidence value higher than the desirable confidence value threshold, the name of the recognized person and its confidence value are sent back to the client as feedback. This goal is persuaded for infinite time until it is cancelled or preempted by another goal.
* '''order_id''' = 2 and '''order_argument''' = 'person_name'
add_face_images: Goal is to acquire training images for a NEW person. The video stream is processed for detecting a face which is saved and used as a training image for the new person. This process is continued until the desired number of training images for the new person is acquired. The name of the new person is provided as '''order_argument'''. The acquired images are stored in the 'data' folder and are added to the list of training images in '''train.txt'''
* '''order_id''' = 3
train: Goal is to (re)train the Eigenfaces database from the training images listed in the 'train.txt'.
* '''order_id''' = 4
exit: Goal is to exit the program.
=== Subscribed Topic: ===
* '''/camera/image_raw''' (standard ROS image transport)
A video stream
=== Parameters: ===
* '''confidence_value''' (''double'', default = 0.88)
A face recognized with confidence value higher than the "confidence_value" threshold is accepted as valid.
* '''show_screen_flag''' (''boolean'', default = true)
If output screen is shown.
* '''add_face_number''' (''int'', default = 25)
A parameter for the 'add_face_images' goal (order_id = 2) which determines the number of training images for a new person to be acquired from the video stream
== Fclient ==
'''Fclient''' is a ROS node that implements an actionlib client example for the face_recognition simple actionlib server (i.e. 'Fserver'). 'Fclient' is provided for demonstration and testing purposes.
=== Subscribed topics ===
* '''fr_order''' (face_recognition/FRClientGoal)
Each '''FRClientGoal''' message has an '''order_id''' and an '''order_argument''' which specify a goal to be executed by the '''Fserver'''. After receiving a message, '''Fclient''' sends the corresponding goal to the '''Fserver'''. By registering relevant call back functions, '''Fclient''' receives feedback and result information from the execution of goals in the '''Fserver''' and prints such information on its terminal.
== Tutorial ==
An exercise of using Fserver and Fclient: <<BR>>
* Run roscore
{{{
$ roscore
}}}
* In separate terminal publish a video stream on topic '''/camera/image_raw'''.
* For example you can use '''usb_cam''' to publish images from your web cam as follows:
* Install [[usb_cam|http://wiki.ros.org/usb_cam]] package
* Run
{{{
$ rosrun usb_cam usb_cam_node usb_cam_node/image_raw:=camera/image_raw _image_height:=<usb_cam_height> _image_width:=<usb_cam_width>
}}}
* In separate terminals run the face recognition server and client as follows:
{{{
$ rosrun face_recognition Fserver
$ rosrun face_recognition Fclient
}}}
* In another terminal publish following messages on topic /fr_order to test different face recognition functionalities.
* After each command notice the output of Fserver and Fclient.
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 2 "your_name"
}}}
* To acquire training images for your face: you should try to appear in the video stream!
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 3 "none"
}}}
* To retrain and update the database, so that you can be recognized
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 1 "none"
}}}
* To recognise faces continuously. This would not stop until you preempt or cancel the goal. So lets preempt it by sending the next goal.
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 2 "your_friend's_name"
}}}
* To add training images for a new person
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 0 "none"
}}}
* To recognize once a face.
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 1 "none"
}}}
* To recognize continuously
{{{
$ rostopic pub -1 /fr_order face_recognition/FRClientGoal -- 4 "none"
}}}
* To exit
}}}}
## AUTOGENERATED DON'T DELETE
## CategoryPackage