mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-21 06:11:09 +08:00
fixing facerecognizer tutorials and interface
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
set(the_description "Face recognition etc")
|
||||
ocv_define_module(face opencv_core opencv_imgproc WRAP python)
|
||||
ocv_define_module(face opencv_core opencv_imgproc opencv_objdetect WRAP python)
|
||||
# NOTE: objdetect module is needed for one of the samples
|
||||
|
@@ -1,400 +0,0 @@
|
||||
/home/philipp/facerec/data/at/s13/2.pgm;12
|
||||
/home/philipp/facerec/data/at/s13/7.pgm;12
|
||||
/home/philipp/facerec/data/at/s13/6.pgm;12
|
||||
/home/philipp/facerec/data/at/s13/9.pgm;12
|
||||
/home/philipp/facerec/data/at/s13/5.pgm;12
|
||||
/home/philipp/facerec/data/at/s13/3.pgm;12
|
||||
/home/philipp/facerec/data/at/s13/4.pgm;12
|
||||
/home/philipp/facerec/data/at/s13/10.pgm;12
|
||||
/home/philipp/facerec/data/at/s13/8.pgm;12
|
||||
/home/philipp/facerec/data/at/s13/1.pgm;12
|
||||
/home/philipp/facerec/data/at/s17/2.pgm;16
|
||||
/home/philipp/facerec/data/at/s17/7.pgm;16
|
||||
/home/philipp/facerec/data/at/s17/6.pgm;16
|
||||
/home/philipp/facerec/data/at/s17/9.pgm;16
|
||||
/home/philipp/facerec/data/at/s17/5.pgm;16
|
||||
/home/philipp/facerec/data/at/s17/3.pgm;16
|
||||
/home/philipp/facerec/data/at/s17/4.pgm;16
|
||||
/home/philipp/facerec/data/at/s17/10.pgm;16
|
||||
/home/philipp/facerec/data/at/s17/8.pgm;16
|
||||
/home/philipp/facerec/data/at/s17/1.pgm;16
|
||||
/home/philipp/facerec/data/at/s32/2.pgm;31
|
||||
/home/philipp/facerec/data/at/s32/7.pgm;31
|
||||
/home/philipp/facerec/data/at/s32/6.pgm;31
|
||||
/home/philipp/facerec/data/at/s32/9.pgm;31
|
||||
/home/philipp/facerec/data/at/s32/5.pgm;31
|
||||
/home/philipp/facerec/data/at/s32/3.pgm;31
|
||||
/home/philipp/facerec/data/at/s32/4.pgm;31
|
||||
/home/philipp/facerec/data/at/s32/10.pgm;31
|
||||
/home/philipp/facerec/data/at/s32/8.pgm;31
|
||||
/home/philipp/facerec/data/at/s32/1.pgm;31
|
||||
/home/philipp/facerec/data/at/s10/2.pgm;9
|
||||
/home/philipp/facerec/data/at/s10/7.pgm;9
|
||||
/home/philipp/facerec/data/at/s10/6.pgm;9
|
||||
/home/philipp/facerec/data/at/s10/9.pgm;9
|
||||
/home/philipp/facerec/data/at/s10/5.pgm;9
|
||||
/home/philipp/facerec/data/at/s10/3.pgm;9
|
||||
/home/philipp/facerec/data/at/s10/4.pgm;9
|
||||
/home/philipp/facerec/data/at/s10/10.pgm;9
|
||||
/home/philipp/facerec/data/at/s10/8.pgm;9
|
||||
/home/philipp/facerec/data/at/s10/1.pgm;9
|
||||
/home/philipp/facerec/data/at/s27/2.pgm;26
|
||||
/home/philipp/facerec/data/at/s27/7.pgm;26
|
||||
/home/philipp/facerec/data/at/s27/6.pgm;26
|
||||
/home/philipp/facerec/data/at/s27/9.pgm;26
|
||||
/home/philipp/facerec/data/at/s27/5.pgm;26
|
||||
/home/philipp/facerec/data/at/s27/3.pgm;26
|
||||
/home/philipp/facerec/data/at/s27/4.pgm;26
|
||||
/home/philipp/facerec/data/at/s27/10.pgm;26
|
||||
/home/philipp/facerec/data/at/s27/8.pgm;26
|
||||
/home/philipp/facerec/data/at/s27/1.pgm;26
|
||||
/home/philipp/facerec/data/at/s5/2.pgm;4
|
||||
/home/philipp/facerec/data/at/s5/7.pgm;4
|
||||
/home/philipp/facerec/data/at/s5/6.pgm;4
|
||||
/home/philipp/facerec/data/at/s5/9.pgm;4
|
||||
/home/philipp/facerec/data/at/s5/5.pgm;4
|
||||
/home/philipp/facerec/data/at/s5/3.pgm;4
|
||||
/home/philipp/facerec/data/at/s5/4.pgm;4
|
||||
/home/philipp/facerec/data/at/s5/10.pgm;4
|
||||
/home/philipp/facerec/data/at/s5/8.pgm;4
|
||||
/home/philipp/facerec/data/at/s5/1.pgm;4
|
||||
/home/philipp/facerec/data/at/s20/2.pgm;19
|
||||
/home/philipp/facerec/data/at/s20/7.pgm;19
|
||||
/home/philipp/facerec/data/at/s20/6.pgm;19
|
||||
/home/philipp/facerec/data/at/s20/9.pgm;19
|
||||
/home/philipp/facerec/data/at/s20/5.pgm;19
|
||||
/home/philipp/facerec/data/at/s20/3.pgm;19
|
||||
/home/philipp/facerec/data/at/s20/4.pgm;19
|
||||
/home/philipp/facerec/data/at/s20/10.pgm;19
|
||||
/home/philipp/facerec/data/at/s20/8.pgm;19
|
||||
/home/philipp/facerec/data/at/s20/1.pgm;19
|
||||
/home/philipp/facerec/data/at/s30/2.pgm;29
|
||||
/home/philipp/facerec/data/at/s30/7.pgm;29
|
||||
/home/philipp/facerec/data/at/s30/6.pgm;29
|
||||
/home/philipp/facerec/data/at/s30/9.pgm;29
|
||||
/home/philipp/facerec/data/at/s30/5.pgm;29
|
||||
/home/philipp/facerec/data/at/s30/3.pgm;29
|
||||
/home/philipp/facerec/data/at/s30/4.pgm;29
|
||||
/home/philipp/facerec/data/at/s30/10.pgm;29
|
||||
/home/philipp/facerec/data/at/s30/8.pgm;29
|
||||
/home/philipp/facerec/data/at/s30/1.pgm;29
|
||||
/home/philipp/facerec/data/at/s39/2.pgm;38
|
||||
/home/philipp/facerec/data/at/s39/7.pgm;38
|
||||
/home/philipp/facerec/data/at/s39/6.pgm;38
|
||||
/home/philipp/facerec/data/at/s39/9.pgm;38
|
||||
/home/philipp/facerec/data/at/s39/5.pgm;38
|
||||
/home/philipp/facerec/data/at/s39/3.pgm;38
|
||||
/home/philipp/facerec/data/at/s39/4.pgm;38
|
||||
/home/philipp/facerec/data/at/s39/10.pgm;38
|
||||
/home/philipp/facerec/data/at/s39/8.pgm;38
|
||||
/home/philipp/facerec/data/at/s39/1.pgm;38
|
||||
/home/philipp/facerec/data/at/s35/2.pgm;34
|
||||
/home/philipp/facerec/data/at/s35/7.pgm;34
|
||||
/home/philipp/facerec/data/at/s35/6.pgm;34
|
||||
/home/philipp/facerec/data/at/s35/9.pgm;34
|
||||
/home/philipp/facerec/data/at/s35/5.pgm;34
|
||||
/home/philipp/facerec/data/at/s35/3.pgm;34
|
||||
/home/philipp/facerec/data/at/s35/4.pgm;34
|
||||
/home/philipp/facerec/data/at/s35/10.pgm;34
|
||||
/home/philipp/facerec/data/at/s35/8.pgm;34
|
||||
/home/philipp/facerec/data/at/s35/1.pgm;34
|
||||
/home/philipp/facerec/data/at/s23/2.pgm;22
|
||||
/home/philipp/facerec/data/at/s23/7.pgm;22
|
||||
/home/philipp/facerec/data/at/s23/6.pgm;22
|
||||
/home/philipp/facerec/data/at/s23/9.pgm;22
|
||||
/home/philipp/facerec/data/at/s23/5.pgm;22
|
||||
/home/philipp/facerec/data/at/s23/3.pgm;22
|
||||
/home/philipp/facerec/data/at/s23/4.pgm;22
|
||||
/home/philipp/facerec/data/at/s23/10.pgm;22
|
||||
/home/philipp/facerec/data/at/s23/8.pgm;22
|
||||
/home/philipp/facerec/data/at/s23/1.pgm;22
|
||||
/home/philipp/facerec/data/at/s4/2.pgm;3
|
||||
/home/philipp/facerec/data/at/s4/7.pgm;3
|
||||
/home/philipp/facerec/data/at/s4/6.pgm;3
|
||||
/home/philipp/facerec/data/at/s4/9.pgm;3
|
||||
/home/philipp/facerec/data/at/s4/5.pgm;3
|
||||
/home/philipp/facerec/data/at/s4/3.pgm;3
|
||||
/home/philipp/facerec/data/at/s4/4.pgm;3
|
||||
/home/philipp/facerec/data/at/s4/10.pgm;3
|
||||
/home/philipp/facerec/data/at/s4/8.pgm;3
|
||||
/home/philipp/facerec/data/at/s4/1.pgm;3
|
||||
/home/philipp/facerec/data/at/s9/2.pgm;8
|
||||
/home/philipp/facerec/data/at/s9/7.pgm;8
|
||||
/home/philipp/facerec/data/at/s9/6.pgm;8
|
||||
/home/philipp/facerec/data/at/s9/9.pgm;8
|
||||
/home/philipp/facerec/data/at/s9/5.pgm;8
|
||||
/home/philipp/facerec/data/at/s9/3.pgm;8
|
||||
/home/philipp/facerec/data/at/s9/4.pgm;8
|
||||
/home/philipp/facerec/data/at/s9/10.pgm;8
|
||||
/home/philipp/facerec/data/at/s9/8.pgm;8
|
||||
/home/philipp/facerec/data/at/s9/1.pgm;8
|
||||
/home/philipp/facerec/data/at/s37/2.pgm;36
|
||||
/home/philipp/facerec/data/at/s37/7.pgm;36
|
||||
/home/philipp/facerec/data/at/s37/6.pgm;36
|
||||
/home/philipp/facerec/data/at/s37/9.pgm;36
|
||||
/home/philipp/facerec/data/at/s37/5.pgm;36
|
||||
/home/philipp/facerec/data/at/s37/3.pgm;36
|
||||
/home/philipp/facerec/data/at/s37/4.pgm;36
|
||||
/home/philipp/facerec/data/at/s37/10.pgm;36
|
||||
/home/philipp/facerec/data/at/s37/8.pgm;36
|
||||
/home/philipp/facerec/data/at/s37/1.pgm;36
|
||||
/home/philipp/facerec/data/at/s24/2.pgm;23
|
||||
/home/philipp/facerec/data/at/s24/7.pgm;23
|
||||
/home/philipp/facerec/data/at/s24/6.pgm;23
|
||||
/home/philipp/facerec/data/at/s24/9.pgm;23
|
||||
/home/philipp/facerec/data/at/s24/5.pgm;23
|
||||
/home/philipp/facerec/data/at/s24/3.pgm;23
|
||||
/home/philipp/facerec/data/at/s24/4.pgm;23
|
||||
/home/philipp/facerec/data/at/s24/10.pgm;23
|
||||
/home/philipp/facerec/data/at/s24/8.pgm;23
|
||||
/home/philipp/facerec/data/at/s24/1.pgm;23
|
||||
/home/philipp/facerec/data/at/s19/2.pgm;18
|
||||
/home/philipp/facerec/data/at/s19/7.pgm;18
|
||||
/home/philipp/facerec/data/at/s19/6.pgm;18
|
||||
/home/philipp/facerec/data/at/s19/9.pgm;18
|
||||
/home/philipp/facerec/data/at/s19/5.pgm;18
|
||||
/home/philipp/facerec/data/at/s19/3.pgm;18
|
||||
/home/philipp/facerec/data/at/s19/4.pgm;18
|
||||
/home/philipp/facerec/data/at/s19/10.pgm;18
|
||||
/home/philipp/facerec/data/at/s19/8.pgm;18
|
||||
/home/philipp/facerec/data/at/s19/1.pgm;18
|
||||
/home/philipp/facerec/data/at/s8/2.pgm;7
|
||||
/home/philipp/facerec/data/at/s8/7.pgm;7
|
||||
/home/philipp/facerec/data/at/s8/6.pgm;7
|
||||
/home/philipp/facerec/data/at/s8/9.pgm;7
|
||||
/home/philipp/facerec/data/at/s8/5.pgm;7
|
||||
/home/philipp/facerec/data/at/s8/3.pgm;7
|
||||
/home/philipp/facerec/data/at/s8/4.pgm;7
|
||||
/home/philipp/facerec/data/at/s8/10.pgm;7
|
||||
/home/philipp/facerec/data/at/s8/8.pgm;7
|
||||
/home/philipp/facerec/data/at/s8/1.pgm;7
|
||||
/home/philipp/facerec/data/at/s21/2.pgm;20
|
||||
/home/philipp/facerec/data/at/s21/7.pgm;20
|
||||
/home/philipp/facerec/data/at/s21/6.pgm;20
|
||||
/home/philipp/facerec/data/at/s21/9.pgm;20
|
||||
/home/philipp/facerec/data/at/s21/5.pgm;20
|
||||
/home/philipp/facerec/data/at/s21/3.pgm;20
|
||||
/home/philipp/facerec/data/at/s21/4.pgm;20
|
||||
/home/philipp/facerec/data/at/s21/10.pgm;20
|
||||
/home/philipp/facerec/data/at/s21/8.pgm;20
|
||||
/home/philipp/facerec/data/at/s21/1.pgm;20
|
||||
/home/philipp/facerec/data/at/s1/2.pgm;0
|
||||
/home/philipp/facerec/data/at/s1/7.pgm;0
|
||||
/home/philipp/facerec/data/at/s1/6.pgm;0
|
||||
/home/philipp/facerec/data/at/s1/9.pgm;0
|
||||
/home/philipp/facerec/data/at/s1/5.pgm;0
|
||||
/home/philipp/facerec/data/at/s1/3.pgm;0
|
||||
/home/philipp/facerec/data/at/s1/4.pgm;0
|
||||
/home/philipp/facerec/data/at/s1/10.pgm;0
|
||||
/home/philipp/facerec/data/at/s1/8.pgm;0
|
||||
/home/philipp/facerec/data/at/s1/1.pgm;0
|
||||
/home/philipp/facerec/data/at/s7/2.pgm;6
|
||||
/home/philipp/facerec/data/at/s7/7.pgm;6
|
||||
/home/philipp/facerec/data/at/s7/6.pgm;6
|
||||
/home/philipp/facerec/data/at/s7/9.pgm;6
|
||||
/home/philipp/facerec/data/at/s7/5.pgm;6
|
||||
/home/philipp/facerec/data/at/s7/3.pgm;6
|
||||
/home/philipp/facerec/data/at/s7/4.pgm;6
|
||||
/home/philipp/facerec/data/at/s7/10.pgm;6
|
||||
/home/philipp/facerec/data/at/s7/8.pgm;6
|
||||
/home/philipp/facerec/data/at/s7/1.pgm;6
|
||||
/home/philipp/facerec/data/at/s16/2.pgm;15
|
||||
/home/philipp/facerec/data/at/s16/7.pgm;15
|
||||
/home/philipp/facerec/data/at/s16/6.pgm;15
|
||||
/home/philipp/facerec/data/at/s16/9.pgm;15
|
||||
/home/philipp/facerec/data/at/s16/5.pgm;15
|
||||
/home/philipp/facerec/data/at/s16/3.pgm;15
|
||||
/home/philipp/facerec/data/at/s16/4.pgm;15
|
||||
/home/philipp/facerec/data/at/s16/10.pgm;15
|
||||
/home/philipp/facerec/data/at/s16/8.pgm;15
|
||||
/home/philipp/facerec/data/at/s16/1.pgm;15
|
||||
/home/philipp/facerec/data/at/s36/2.pgm;35
|
||||
/home/philipp/facerec/data/at/s36/7.pgm;35
|
||||
/home/philipp/facerec/data/at/s36/6.pgm;35
|
||||
/home/philipp/facerec/data/at/s36/9.pgm;35
|
||||
/home/philipp/facerec/data/at/s36/5.pgm;35
|
||||
/home/philipp/facerec/data/at/s36/3.pgm;35
|
||||
/home/philipp/facerec/data/at/s36/4.pgm;35
|
||||
/home/philipp/facerec/data/at/s36/10.pgm;35
|
||||
/home/philipp/facerec/data/at/s36/8.pgm;35
|
||||
/home/philipp/facerec/data/at/s36/1.pgm;35
|
||||
/home/philipp/facerec/data/at/s25/2.pgm;24
|
||||
/home/philipp/facerec/data/at/s25/7.pgm;24
|
||||
/home/philipp/facerec/data/at/s25/6.pgm;24
|
||||
/home/philipp/facerec/data/at/s25/9.pgm;24
|
||||
/home/philipp/facerec/data/at/s25/5.pgm;24
|
||||
/home/philipp/facerec/data/at/s25/3.pgm;24
|
||||
/home/philipp/facerec/data/at/s25/4.pgm;24
|
||||
/home/philipp/facerec/data/at/s25/10.pgm;24
|
||||
/home/philipp/facerec/data/at/s25/8.pgm;24
|
||||
/home/philipp/facerec/data/at/s25/1.pgm;24
|
||||
/home/philipp/facerec/data/at/s14/2.pgm;13
|
||||
/home/philipp/facerec/data/at/s14/7.pgm;13
|
||||
/home/philipp/facerec/data/at/s14/6.pgm;13
|
||||
/home/philipp/facerec/data/at/s14/9.pgm;13
|
||||
/home/philipp/facerec/data/at/s14/5.pgm;13
|
||||
/home/philipp/facerec/data/at/s14/3.pgm;13
|
||||
/home/philipp/facerec/data/at/s14/4.pgm;13
|
||||
/home/philipp/facerec/data/at/s14/10.pgm;13
|
||||
/home/philipp/facerec/data/at/s14/8.pgm;13
|
||||
/home/philipp/facerec/data/at/s14/1.pgm;13
|
||||
/home/philipp/facerec/data/at/s34/2.pgm;33
|
||||
/home/philipp/facerec/data/at/s34/7.pgm;33
|
||||
/home/philipp/facerec/data/at/s34/6.pgm;33
|
||||
/home/philipp/facerec/data/at/s34/9.pgm;33
|
||||
/home/philipp/facerec/data/at/s34/5.pgm;33
|
||||
/home/philipp/facerec/data/at/s34/3.pgm;33
|
||||
/home/philipp/facerec/data/at/s34/4.pgm;33
|
||||
/home/philipp/facerec/data/at/s34/10.pgm;33
|
||||
/home/philipp/facerec/data/at/s34/8.pgm;33
|
||||
/home/philipp/facerec/data/at/s34/1.pgm;33
|
||||
/home/philipp/facerec/data/at/s11/2.pgm;10
|
||||
/home/philipp/facerec/data/at/s11/7.pgm;10
|
||||
/home/philipp/facerec/data/at/s11/6.pgm;10
|
||||
/home/philipp/facerec/data/at/s11/9.pgm;10
|
||||
/home/philipp/facerec/data/at/s11/5.pgm;10
|
||||
/home/philipp/facerec/data/at/s11/3.pgm;10
|
||||
/home/philipp/facerec/data/at/s11/4.pgm;10
|
||||
/home/philipp/facerec/data/at/s11/10.pgm;10
|
||||
/home/philipp/facerec/data/at/s11/8.pgm;10
|
||||
/home/philipp/facerec/data/at/s11/1.pgm;10
|
||||
/home/philipp/facerec/data/at/s26/2.pgm;25
|
||||
/home/philipp/facerec/data/at/s26/7.pgm;25
|
||||
/home/philipp/facerec/data/at/s26/6.pgm;25
|
||||
/home/philipp/facerec/data/at/s26/9.pgm;25
|
||||
/home/philipp/facerec/data/at/s26/5.pgm;25
|
||||
/home/philipp/facerec/data/at/s26/3.pgm;25
|
||||
/home/philipp/facerec/data/at/s26/4.pgm;25
|
||||
/home/philipp/facerec/data/at/s26/10.pgm;25
|
||||
/home/philipp/facerec/data/at/s26/8.pgm;25
|
||||
/home/philipp/facerec/data/at/s26/1.pgm;25
|
||||
/home/philipp/facerec/data/at/s18/2.pgm;17
|
||||
/home/philipp/facerec/data/at/s18/7.pgm;17
|
||||
/home/philipp/facerec/data/at/s18/6.pgm;17
|
||||
/home/philipp/facerec/data/at/s18/9.pgm;17
|
||||
/home/philipp/facerec/data/at/s18/5.pgm;17
|
||||
/home/philipp/facerec/data/at/s18/3.pgm;17
|
||||
/home/philipp/facerec/data/at/s18/4.pgm;17
|
||||
/home/philipp/facerec/data/at/s18/10.pgm;17
|
||||
/home/philipp/facerec/data/at/s18/8.pgm;17
|
||||
/home/philipp/facerec/data/at/s18/1.pgm;17
|
||||
/home/philipp/facerec/data/at/s29/2.pgm;28
|
||||
/home/philipp/facerec/data/at/s29/7.pgm;28
|
||||
/home/philipp/facerec/data/at/s29/6.pgm;28
|
||||
/home/philipp/facerec/data/at/s29/9.pgm;28
|
||||
/home/philipp/facerec/data/at/s29/5.pgm;28
|
||||
/home/philipp/facerec/data/at/s29/3.pgm;28
|
||||
/home/philipp/facerec/data/at/s29/4.pgm;28
|
||||
/home/philipp/facerec/data/at/s29/10.pgm;28
|
||||
/home/philipp/facerec/data/at/s29/8.pgm;28
|
||||
/home/philipp/facerec/data/at/s29/1.pgm;28
|
||||
/home/philipp/facerec/data/at/s33/2.pgm;32
|
||||
/home/philipp/facerec/data/at/s33/7.pgm;32
|
||||
/home/philipp/facerec/data/at/s33/6.pgm;32
|
||||
/home/philipp/facerec/data/at/s33/9.pgm;32
|
||||
/home/philipp/facerec/data/at/s33/5.pgm;32
|
||||
/home/philipp/facerec/data/at/s33/3.pgm;32
|
||||
/home/philipp/facerec/data/at/s33/4.pgm;32
|
||||
/home/philipp/facerec/data/at/s33/10.pgm;32
|
||||
/home/philipp/facerec/data/at/s33/8.pgm;32
|
||||
/home/philipp/facerec/data/at/s33/1.pgm;32
|
||||
/home/philipp/facerec/data/at/s12/2.pgm;11
|
||||
/home/philipp/facerec/data/at/s12/7.pgm;11
|
||||
/home/philipp/facerec/data/at/s12/6.pgm;11
|
||||
/home/philipp/facerec/data/at/s12/9.pgm;11
|
||||
/home/philipp/facerec/data/at/s12/5.pgm;11
|
||||
/home/philipp/facerec/data/at/s12/3.pgm;11
|
||||
/home/philipp/facerec/data/at/s12/4.pgm;11
|
||||
/home/philipp/facerec/data/at/s12/10.pgm;11
|
||||
/home/philipp/facerec/data/at/s12/8.pgm;11
|
||||
/home/philipp/facerec/data/at/s12/1.pgm;11
|
||||
/home/philipp/facerec/data/at/s6/2.pgm;5
|
||||
/home/philipp/facerec/data/at/s6/7.pgm;5
|
||||
/home/philipp/facerec/data/at/s6/6.pgm;5
|
||||
/home/philipp/facerec/data/at/s6/9.pgm;5
|
||||
/home/philipp/facerec/data/at/s6/5.pgm;5
|
||||
/home/philipp/facerec/data/at/s6/3.pgm;5
|
||||
/home/philipp/facerec/data/at/s6/4.pgm;5
|
||||
/home/philipp/facerec/data/at/s6/10.pgm;5
|
||||
/home/philipp/facerec/data/at/s6/8.pgm;5
|
||||
/home/philipp/facerec/data/at/s6/1.pgm;5
|
||||
/home/philipp/facerec/data/at/s22/2.pgm;21
|
||||
/home/philipp/facerec/data/at/s22/7.pgm;21
|
||||
/home/philipp/facerec/data/at/s22/6.pgm;21
|
||||
/home/philipp/facerec/data/at/s22/9.pgm;21
|
||||
/home/philipp/facerec/data/at/s22/5.pgm;21
|
||||
/home/philipp/facerec/data/at/s22/3.pgm;21
|
||||
/home/philipp/facerec/data/at/s22/4.pgm;21
|
||||
/home/philipp/facerec/data/at/s22/10.pgm;21
|
||||
/home/philipp/facerec/data/at/s22/8.pgm;21
|
||||
/home/philipp/facerec/data/at/s22/1.pgm;21
|
||||
/home/philipp/facerec/data/at/s15/2.pgm;14
|
||||
/home/philipp/facerec/data/at/s15/7.pgm;14
|
||||
/home/philipp/facerec/data/at/s15/6.pgm;14
|
||||
/home/philipp/facerec/data/at/s15/9.pgm;14
|
||||
/home/philipp/facerec/data/at/s15/5.pgm;14
|
||||
/home/philipp/facerec/data/at/s15/3.pgm;14
|
||||
/home/philipp/facerec/data/at/s15/4.pgm;14
|
||||
/home/philipp/facerec/data/at/s15/10.pgm;14
|
||||
/home/philipp/facerec/data/at/s15/8.pgm;14
|
||||
/home/philipp/facerec/data/at/s15/1.pgm;14
|
||||
/home/philipp/facerec/data/at/s2/2.pgm;1
|
||||
/home/philipp/facerec/data/at/s2/7.pgm;1
|
||||
/home/philipp/facerec/data/at/s2/6.pgm;1
|
||||
/home/philipp/facerec/data/at/s2/9.pgm;1
|
||||
/home/philipp/facerec/data/at/s2/5.pgm;1
|
||||
/home/philipp/facerec/data/at/s2/3.pgm;1
|
||||
/home/philipp/facerec/data/at/s2/4.pgm;1
|
||||
/home/philipp/facerec/data/at/s2/10.pgm;1
|
||||
/home/philipp/facerec/data/at/s2/8.pgm;1
|
||||
/home/philipp/facerec/data/at/s2/1.pgm;1
|
||||
/home/philipp/facerec/data/at/s31/2.pgm;30
|
||||
/home/philipp/facerec/data/at/s31/7.pgm;30
|
||||
/home/philipp/facerec/data/at/s31/6.pgm;30
|
||||
/home/philipp/facerec/data/at/s31/9.pgm;30
|
||||
/home/philipp/facerec/data/at/s31/5.pgm;30
|
||||
/home/philipp/facerec/data/at/s31/3.pgm;30
|
||||
/home/philipp/facerec/data/at/s31/4.pgm;30
|
||||
/home/philipp/facerec/data/at/s31/10.pgm;30
|
||||
/home/philipp/facerec/data/at/s31/8.pgm;30
|
||||
/home/philipp/facerec/data/at/s31/1.pgm;30
|
||||
/home/philipp/facerec/data/at/s28/2.pgm;27
|
||||
/home/philipp/facerec/data/at/s28/7.pgm;27
|
||||
/home/philipp/facerec/data/at/s28/6.pgm;27
|
||||
/home/philipp/facerec/data/at/s28/9.pgm;27
|
||||
/home/philipp/facerec/data/at/s28/5.pgm;27
|
||||
/home/philipp/facerec/data/at/s28/3.pgm;27
|
||||
/home/philipp/facerec/data/at/s28/4.pgm;27
|
||||
/home/philipp/facerec/data/at/s28/10.pgm;27
|
||||
/home/philipp/facerec/data/at/s28/8.pgm;27
|
||||
/home/philipp/facerec/data/at/s28/1.pgm;27
|
||||
/home/philipp/facerec/data/at/s40/2.pgm;39
|
||||
/home/philipp/facerec/data/at/s40/7.pgm;39
|
||||
/home/philipp/facerec/data/at/s40/6.pgm;39
|
||||
/home/philipp/facerec/data/at/s40/9.pgm;39
|
||||
/home/philipp/facerec/data/at/s40/5.pgm;39
|
||||
/home/philipp/facerec/data/at/s40/3.pgm;39
|
||||
/home/philipp/facerec/data/at/s40/4.pgm;39
|
||||
/home/philipp/facerec/data/at/s40/10.pgm;39
|
||||
/home/philipp/facerec/data/at/s40/8.pgm;39
|
||||
/home/philipp/facerec/data/at/s40/1.pgm;39
|
||||
/home/philipp/facerec/data/at/s3/2.pgm;2
|
||||
/home/philipp/facerec/data/at/s3/7.pgm;2
|
||||
/home/philipp/facerec/data/at/s3/6.pgm;2
|
||||
/home/philipp/facerec/data/at/s3/9.pgm;2
|
||||
/home/philipp/facerec/data/at/s3/5.pgm;2
|
||||
/home/philipp/facerec/data/at/s3/3.pgm;2
|
||||
/home/philipp/facerec/data/at/s3/4.pgm;2
|
||||
/home/philipp/facerec/data/at/s3/10.pgm;2
|
||||
/home/philipp/facerec/data/at/s3/8.pgm;2
|
||||
/home/philipp/facerec/data/at/s3/1.pgm;2
|
||||
/home/philipp/facerec/data/at/s38/2.pgm;37
|
||||
/home/philipp/facerec/data/at/s38/7.pgm;37
|
||||
/home/philipp/facerec/data/at/s38/6.pgm;37
|
||||
/home/philipp/facerec/data/at/s38/9.pgm;37
|
||||
/home/philipp/facerec/data/at/s38/5.pgm;37
|
||||
/home/philipp/facerec/data/at/s38/3.pgm;37
|
||||
/home/philipp/facerec/data/at/s38/4.pgm;37
|
||||
/home/philipp/facerec/data/at/s38/10.pgm;37
|
||||
/home/philipp/facerec/data/at/s38/8.pgm;37
|
||||
/home/philipp/facerec/data/at/s38/1.pgm;37
|
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
|
||||
* Released to public domain under terms of the BSD Simplified license.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the organization nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* See <http://www.opensource.org/licenses/bsd-license>
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/face.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::face;
|
||||
using namespace std;
|
||||
|
||||
static Mat norm_0_255(InputArray _src) {
|
||||
Mat src = _src.getMat();
|
||||
// Create and return normalized image:
|
||||
Mat dst;
|
||||
switch(src.channels()) {
|
||||
case 1:
|
||||
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
|
||||
break;
|
||||
case 3:
|
||||
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
|
||||
break;
|
||||
default:
|
||||
src.copyTo(dst);
|
||||
break;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
|
||||
std::ifstream file(filename.c_str(), ifstream::in);
|
||||
if (!file) {
|
||||
string error_message = "No valid input file was given, please check the given filename.";
|
||||
CV_Error(CV_StsBadArg, error_message);
|
||||
}
|
||||
string line, path, classlabel;
|
||||
while (getline(file, line)) {
|
||||
stringstream liness(line);
|
||||
getline(liness, path, separator);
|
||||
getline(liness, classlabel);
|
||||
if(!path.empty() && !classlabel.empty()) {
|
||||
images.push_back(imread(path, 0));
|
||||
labels.push_back(atoi(classlabel.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
// Check for valid command line arguments, print usage
|
||||
// if no arguments were given.
|
||||
if (argc != 2) {
|
||||
cout << "usage: " << argv[0] << " <csv.ext>" << endl;
|
||||
exit(1);
|
||||
}
|
||||
// Get the path to your CSV.
|
||||
string fn_csv = string(argv[1]);
|
||||
// These vectors hold the images and corresponding labels.
|
||||
vector<Mat> images;
|
||||
vector<int> labels;
|
||||
// Read in the data. This can fail if no valid
|
||||
// input filename is given.
|
||||
try {
|
||||
read_csv(fn_csv, images, labels);
|
||||
} catch (cv::Exception& e) {
|
||||
cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
|
||||
// nothing more we can do
|
||||
exit(1);
|
||||
}
|
||||
// Quit if there are not enough images for this demo.
|
||||
if(images.size() <= 1) {
|
||||
string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
|
||||
CV_Error(CV_StsError, error_message);
|
||||
}
|
||||
// Get the height from the first image. We'll need this
|
||||
// later in code to reshape the images to their original
|
||||
// size:
|
||||
int height = images[0].rows;
|
||||
// The following lines simply get the last images from
|
||||
// your dataset and remove it from the vector. This is
|
||||
// done, so that the training data (which we learn the
|
||||
// cv::FaceRecognizer on) and the test data we test
|
||||
// the model with, do not overlap.
|
||||
Mat testSample = images[images.size() - 1];
|
||||
int testLabel = labels[labels.size() - 1];
|
||||
images.pop_back();
|
||||
labels.pop_back();
|
||||
// The following lines create an Eigenfaces model for
|
||||
// face recognition and train it with the images and
|
||||
// labels read from the given CSV file.
|
||||
// This here is a full PCA, if you just want to keep
|
||||
// 10 principal components (read Eigenfaces), then call
|
||||
// the factory method like this:
|
||||
//
|
||||
// cv::createEigenFaceRecognizer(10);
|
||||
//
|
||||
// If you want to create a FaceRecognizer with a
|
||||
// confidennce threshold, call it with:
|
||||
//
|
||||
// cv::createEigenFaceRecognizer(10, 123.0);
|
||||
//
|
||||
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
|
||||
model->train(images, labels);
|
||||
// The following line predicts the label of a given
|
||||
// test image:
|
||||
int predictedLabel = model->predict(testSample);
|
||||
//
|
||||
// To get the confidence of a prediction call the model with:
|
||||
//
|
||||
// int predictedLabel = -1;
|
||||
// double confidence = 0.0;
|
||||
// model->predict(testSample, predictedLabel, confidence);
|
||||
//
|
||||
string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
|
||||
cout << result_message << endl;
|
||||
// Sometimes you'll need to get/set internal model data,
|
||||
// which isn't exposed by the public cv::FaceRecognizer.
|
||||
// Since each cv::FaceRecognizer is derived from a
|
||||
// cv::Algorithm, you can query the data.
|
||||
//
|
||||
// First we'll use it to set the threshold of the FaceRecognizer
|
||||
// to 0.0 without retraining the model. This can be useful if
|
||||
// you are evaluating the model:
|
||||
//
|
||||
model->set("threshold", 0.0);
|
||||
// Now the threshold of this model is set to 0.0. A prediction
|
||||
// now returns -1, as it's impossible to have a distance below
|
||||
// it
|
||||
predictedLabel = model->predict(testSample);
|
||||
cout << "Predicted class = " << predictedLabel << endl;
|
||||
// Here is how to get the eigenvalues of this Eigenfaces model:
|
||||
Mat eigenvalues = model->getMat("eigenvalues");
|
||||
// And we can do the same to display the Eigenvectors (read Eigenfaces):
|
||||
Mat W = model->getMat("eigenvectors");
|
||||
// From this we will display the (at most) first 10 Eigenfaces:
|
||||
for (int i = 0; i < min(10, W.cols); i++) {
|
||||
string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
|
||||
cout << msg << endl;
|
||||
// get eigenvector #i
|
||||
Mat ev = W.col(i).clone();
|
||||
// Reshape to original size & normalize to [0...255] for imshow.
|
||||
Mat grayscale = norm_0_255(ev.reshape(1, height));
|
||||
// Show the image & apply a Jet colormap for better sensing.
|
||||
Mat cgrayscale;
|
||||
applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
|
||||
imshow(format("%d", i), cgrayscale);
|
||||
}
|
||||
waitKey(0);
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,400 +0,0 @@
|
||||
/path/to/at/s13/2.pgm;12
|
||||
/path/to/at/s13/7.pgm;12
|
||||
/path/to/at/s13/6.pgm;12
|
||||
/path/to/at/s13/9.pgm;12
|
||||
/path/to/at/s13/5.pgm;12
|
||||
/path/to/at/s13/3.pgm;12
|
||||
/path/to/at/s13/4.pgm;12
|
||||
/path/to/at/s13/10.pgm;12
|
||||
/path/to/at/s13/8.pgm;12
|
||||
/path/to/at/s13/1.pgm;12
|
||||
/path/to/at/s17/2.pgm;16
|
||||
/path/to/at/s17/7.pgm;16
|
||||
/path/to/at/s17/6.pgm;16
|
||||
/path/to/at/s17/9.pgm;16
|
||||
/path/to/at/s17/5.pgm;16
|
||||
/path/to/at/s17/3.pgm;16
|
||||
/path/to/at/s17/4.pgm;16
|
||||
/path/to/at/s17/10.pgm;16
|
||||
/path/to/at/s17/8.pgm;16
|
||||
/path/to/at/s17/1.pgm;16
|
||||
/path/to/at/s32/2.pgm;31
|
||||
/path/to/at/s32/7.pgm;31
|
||||
/path/to/at/s32/6.pgm;31
|
||||
/path/to/at/s32/9.pgm;31
|
||||
/path/to/at/s32/5.pgm;31
|
||||
/path/to/at/s32/3.pgm;31
|
||||
/path/to/at/s32/4.pgm;31
|
||||
/path/to/at/s32/10.pgm;31
|
||||
/path/to/at/s32/8.pgm;31
|
||||
/path/to/at/s32/1.pgm;31
|
||||
/path/to/at/s10/2.pgm;9
|
||||
/path/to/at/s10/7.pgm;9
|
||||
/path/to/at/s10/6.pgm;9
|
||||
/path/to/at/s10/9.pgm;9
|
||||
/path/to/at/s10/5.pgm;9
|
||||
/path/to/at/s10/3.pgm;9
|
||||
/path/to/at/s10/4.pgm;9
|
||||
/path/to/at/s10/10.pgm;9
|
||||
/path/to/at/s10/8.pgm;9
|
||||
/path/to/at/s10/1.pgm;9
|
||||
/path/to/at/s27/2.pgm;26
|
||||
/path/to/at/s27/7.pgm;26
|
||||
/path/to/at/s27/6.pgm;26
|
||||
/path/to/at/s27/9.pgm;26
|
||||
/path/to/at/s27/5.pgm;26
|
||||
/path/to/at/s27/3.pgm;26
|
||||
/path/to/at/s27/4.pgm;26
|
||||
/path/to/at/s27/10.pgm;26
|
||||
/path/to/at/s27/8.pgm;26
|
||||
/path/to/at/s27/1.pgm;26
|
||||
/path/to/at/s5/2.pgm;4
|
||||
/path/to/at/s5/7.pgm;4
|
||||
/path/to/at/s5/6.pgm;4
|
||||
/path/to/at/s5/9.pgm;4
|
||||
/path/to/at/s5/5.pgm;4
|
||||
/path/to/at/s5/3.pgm;4
|
||||
/path/to/at/s5/4.pgm;4
|
||||
/path/to/at/s5/10.pgm;4
|
||||
/path/to/at/s5/8.pgm;4
|
||||
/path/to/at/s5/1.pgm;4
|
||||
/path/to/at/s20/2.pgm;19
|
||||
/path/to/at/s20/7.pgm;19
|
||||
/path/to/at/s20/6.pgm;19
|
||||
/path/to/at/s20/9.pgm;19
|
||||
/path/to/at/s20/5.pgm;19
|
||||
/path/to/at/s20/3.pgm;19
|
||||
/path/to/at/s20/4.pgm;19
|
||||
/path/to/at/s20/10.pgm;19
|
||||
/path/to/at/s20/8.pgm;19
|
||||
/path/to/at/s20/1.pgm;19
|
||||
/path/to/at/s30/2.pgm;29
|
||||
/path/to/at/s30/7.pgm;29
|
||||
/path/to/at/s30/6.pgm;29
|
||||
/path/to/at/s30/9.pgm;29
|
||||
/path/to/at/s30/5.pgm;29
|
||||
/path/to/at/s30/3.pgm;29
|
||||
/path/to/at/s30/4.pgm;29
|
||||
/path/to/at/s30/10.pgm;29
|
||||
/path/to/at/s30/8.pgm;29
|
||||
/path/to/at/s30/1.pgm;29
|
||||
/path/to/at/s39/2.pgm;38
|
||||
/path/to/at/s39/7.pgm;38
|
||||
/path/to/at/s39/6.pgm;38
|
||||
/path/to/at/s39/9.pgm;38
|
||||
/path/to/at/s39/5.pgm;38
|
||||
/path/to/at/s39/3.pgm;38
|
||||
/path/to/at/s39/4.pgm;38
|
||||
/path/to/at/s39/10.pgm;38
|
||||
/path/to/at/s39/8.pgm;38
|
||||
/path/to/at/s39/1.pgm;38
|
||||
/path/to/at/s35/2.pgm;34
|
||||
/path/to/at/s35/7.pgm;34
|
||||
/path/to/at/s35/6.pgm;34
|
||||
/path/to/at/s35/9.pgm;34
|
||||
/path/to/at/s35/5.pgm;34
|
||||
/path/to/at/s35/3.pgm;34
|
||||
/path/to/at/s35/4.pgm;34
|
||||
/path/to/at/s35/10.pgm;34
|
||||
/path/to/at/s35/8.pgm;34
|
||||
/path/to/at/s35/1.pgm;34
|
||||
/path/to/at/s23/2.pgm;22
|
||||
/path/to/at/s23/7.pgm;22
|
||||
/path/to/at/s23/6.pgm;22
|
||||
/path/to/at/s23/9.pgm;22
|
||||
/path/to/at/s23/5.pgm;22
|
||||
/path/to/at/s23/3.pgm;22
|
||||
/path/to/at/s23/4.pgm;22
|
||||
/path/to/at/s23/10.pgm;22
|
||||
/path/to/at/s23/8.pgm;22
|
||||
/path/to/at/s23/1.pgm;22
|
||||
/path/to/at/s4/2.pgm;3
|
||||
/path/to/at/s4/7.pgm;3
|
||||
/path/to/at/s4/6.pgm;3
|
||||
/path/to/at/s4/9.pgm;3
|
||||
/path/to/at/s4/5.pgm;3
|
||||
/path/to/at/s4/3.pgm;3
|
||||
/path/to/at/s4/4.pgm;3
|
||||
/path/to/at/s4/10.pgm;3
|
||||
/path/to/at/s4/8.pgm;3
|
||||
/path/to/at/s4/1.pgm;3
|
||||
/path/to/at/s9/2.pgm;8
|
||||
/path/to/at/s9/7.pgm;8
|
||||
/path/to/at/s9/6.pgm;8
|
||||
/path/to/at/s9/9.pgm;8
|
||||
/path/to/at/s9/5.pgm;8
|
||||
/path/to/at/s9/3.pgm;8
|
||||
/path/to/at/s9/4.pgm;8
|
||||
/path/to/at/s9/10.pgm;8
|
||||
/path/to/at/s9/8.pgm;8
|
||||
/path/to/at/s9/1.pgm;8
|
||||
/path/to/at/s37/2.pgm;36
|
||||
/path/to/at/s37/7.pgm;36
|
||||
/path/to/at/s37/6.pgm;36
|
||||
/path/to/at/s37/9.pgm;36
|
||||
/path/to/at/s37/5.pgm;36
|
||||
/path/to/at/s37/3.pgm;36
|
||||
/path/to/at/s37/4.pgm;36
|
||||
/path/to/at/s37/10.pgm;36
|
||||
/path/to/at/s37/8.pgm;36
|
||||
/path/to/at/s37/1.pgm;36
|
||||
/path/to/at/s24/2.pgm;23
|
||||
/path/to/at/s24/7.pgm;23
|
||||
/path/to/at/s24/6.pgm;23
|
||||
/path/to/at/s24/9.pgm;23
|
||||
/path/to/at/s24/5.pgm;23
|
||||
/path/to/at/s24/3.pgm;23
|
||||
/path/to/at/s24/4.pgm;23
|
||||
/path/to/at/s24/10.pgm;23
|
||||
/path/to/at/s24/8.pgm;23
|
||||
/path/to/at/s24/1.pgm;23
|
||||
/path/to/at/s19/2.pgm;18
|
||||
/path/to/at/s19/7.pgm;18
|
||||
/path/to/at/s19/6.pgm;18
|
||||
/path/to/at/s19/9.pgm;18
|
||||
/path/to/at/s19/5.pgm;18
|
||||
/path/to/at/s19/3.pgm;18
|
||||
/path/to/at/s19/4.pgm;18
|
||||
/path/to/at/s19/10.pgm;18
|
||||
/path/to/at/s19/8.pgm;18
|
||||
/path/to/at/s19/1.pgm;18
|
||||
/path/to/at/s8/2.pgm;7
|
||||
/path/to/at/s8/7.pgm;7
|
||||
/path/to/at/s8/6.pgm;7
|
||||
/path/to/at/s8/9.pgm;7
|
||||
/path/to/at/s8/5.pgm;7
|
||||
/path/to/at/s8/3.pgm;7
|
||||
/path/to/at/s8/4.pgm;7
|
||||
/path/to/at/s8/10.pgm;7
|
||||
/path/to/at/s8/8.pgm;7
|
||||
/path/to/at/s8/1.pgm;7
|
||||
/path/to/at/s21/2.pgm;20
|
||||
/path/to/at/s21/7.pgm;20
|
||||
/path/to/at/s21/6.pgm;20
|
||||
/path/to/at/s21/9.pgm;20
|
||||
/path/to/at/s21/5.pgm;20
|
||||
/path/to/at/s21/3.pgm;20
|
||||
/path/to/at/s21/4.pgm;20
|
||||
/path/to/at/s21/10.pgm;20
|
||||
/path/to/at/s21/8.pgm;20
|
||||
/path/to/at/s21/1.pgm;20
|
||||
/path/to/at/s1/2.pgm;0
|
||||
/path/to/at/s1/7.pgm;0
|
||||
/path/to/at/s1/6.pgm;0
|
||||
/path/to/at/s1/9.pgm;0
|
||||
/path/to/at/s1/5.pgm;0
|
||||
/path/to/at/s1/3.pgm;0
|
||||
/path/to/at/s1/4.pgm;0
|
||||
/path/to/at/s1/10.pgm;0
|
||||
/path/to/at/s1/8.pgm;0
|
||||
/path/to/at/s1/1.pgm;0
|
||||
/path/to/at/s7/2.pgm;6
|
||||
/path/to/at/s7/7.pgm;6
|
||||
/path/to/at/s7/6.pgm;6
|
||||
/path/to/at/s7/9.pgm;6
|
||||
/path/to/at/s7/5.pgm;6
|
||||
/path/to/at/s7/3.pgm;6
|
||||
/path/to/at/s7/4.pgm;6
|
||||
/path/to/at/s7/10.pgm;6
|
||||
/path/to/at/s7/8.pgm;6
|
||||
/path/to/at/s7/1.pgm;6
|
||||
/path/to/at/s16/2.pgm;15
|
||||
/path/to/at/s16/7.pgm;15
|
||||
/path/to/at/s16/6.pgm;15
|
||||
/path/to/at/s16/9.pgm;15
|
||||
/path/to/at/s16/5.pgm;15
|
||||
/path/to/at/s16/3.pgm;15
|
||||
/path/to/at/s16/4.pgm;15
|
||||
/path/to/at/s16/10.pgm;15
|
||||
/path/to/at/s16/8.pgm;15
|
||||
/path/to/at/s16/1.pgm;15
|
||||
/path/to/at/s36/2.pgm;35
|
||||
/path/to/at/s36/7.pgm;35
|
||||
/path/to/at/s36/6.pgm;35
|
||||
/path/to/at/s36/9.pgm;35
|
||||
/path/to/at/s36/5.pgm;35
|
||||
/path/to/at/s36/3.pgm;35
|
||||
/path/to/at/s36/4.pgm;35
|
||||
/path/to/at/s36/10.pgm;35
|
||||
/path/to/at/s36/8.pgm;35
|
||||
/path/to/at/s36/1.pgm;35
|
||||
/path/to/at/s25/2.pgm;24
|
||||
/path/to/at/s25/7.pgm;24
|
||||
/path/to/at/s25/6.pgm;24
|
||||
/path/to/at/s25/9.pgm;24
|
||||
/path/to/at/s25/5.pgm;24
|
||||
/path/to/at/s25/3.pgm;24
|
||||
/path/to/at/s25/4.pgm;24
|
||||
/path/to/at/s25/10.pgm;24
|
||||
/path/to/at/s25/8.pgm;24
|
||||
/path/to/at/s25/1.pgm;24
|
||||
/path/to/at/s14/2.pgm;13
|
||||
/path/to/at/s14/7.pgm;13
|
||||
/path/to/at/s14/6.pgm;13
|
||||
/path/to/at/s14/9.pgm;13
|
||||
/path/to/at/s14/5.pgm;13
|
||||
/path/to/at/s14/3.pgm;13
|
||||
/path/to/at/s14/4.pgm;13
|
||||
/path/to/at/s14/10.pgm;13
|
||||
/path/to/at/s14/8.pgm;13
|
||||
/path/to/at/s14/1.pgm;13
|
||||
/path/to/at/s34/2.pgm;33
|
||||
/path/to/at/s34/7.pgm;33
|
||||
/path/to/at/s34/6.pgm;33
|
||||
/path/to/at/s34/9.pgm;33
|
||||
/path/to/at/s34/5.pgm;33
|
||||
/path/to/at/s34/3.pgm;33
|
||||
/path/to/at/s34/4.pgm;33
|
||||
/path/to/at/s34/10.pgm;33
|
||||
/path/to/at/s34/8.pgm;33
|
||||
/path/to/at/s34/1.pgm;33
|
||||
/path/to/at/s11/2.pgm;10
|
||||
/path/to/at/s11/7.pgm;10
|
||||
/path/to/at/s11/6.pgm;10
|
||||
/path/to/at/s11/9.pgm;10
|
||||
/path/to/at/s11/5.pgm;10
|
||||
/path/to/at/s11/3.pgm;10
|
||||
/path/to/at/s11/4.pgm;10
|
||||
/path/to/at/s11/10.pgm;10
|
||||
/path/to/at/s11/8.pgm;10
|
||||
/path/to/at/s11/1.pgm;10
|
||||
/path/to/at/s26/2.pgm;25
|
||||
/path/to/at/s26/7.pgm;25
|
||||
/path/to/at/s26/6.pgm;25
|
||||
/path/to/at/s26/9.pgm;25
|
||||
/path/to/at/s26/5.pgm;25
|
||||
/path/to/at/s26/3.pgm;25
|
||||
/path/to/at/s26/4.pgm;25
|
||||
/path/to/at/s26/10.pgm;25
|
||||
/path/to/at/s26/8.pgm;25
|
||||
/path/to/at/s26/1.pgm;25
|
||||
/path/to/at/s18/2.pgm;17
|
||||
/path/to/at/s18/7.pgm;17
|
||||
/path/to/at/s18/6.pgm;17
|
||||
/path/to/at/s18/9.pgm;17
|
||||
/path/to/at/s18/5.pgm;17
|
||||
/path/to/at/s18/3.pgm;17
|
||||
/path/to/at/s18/4.pgm;17
|
||||
/path/to/at/s18/10.pgm;17
|
||||
/path/to/at/s18/8.pgm;17
|
||||
/path/to/at/s18/1.pgm;17
|
||||
/path/to/at/s29/2.pgm;28
|
||||
/path/to/at/s29/7.pgm;28
|
||||
/path/to/at/s29/6.pgm;28
|
||||
/path/to/at/s29/9.pgm;28
|
||||
/path/to/at/s29/5.pgm;28
|
||||
/path/to/at/s29/3.pgm;28
|
||||
/path/to/at/s29/4.pgm;28
|
||||
/path/to/at/s29/10.pgm;28
|
||||
/path/to/at/s29/8.pgm;28
|
||||
/path/to/at/s29/1.pgm;28
|
||||
/path/to/at/s33/2.pgm;32
|
||||
/path/to/at/s33/7.pgm;32
|
||||
/path/to/at/s33/6.pgm;32
|
||||
/path/to/at/s33/9.pgm;32
|
||||
/path/to/at/s33/5.pgm;32
|
||||
/path/to/at/s33/3.pgm;32
|
||||
/path/to/at/s33/4.pgm;32
|
||||
/path/to/at/s33/10.pgm;32
|
||||
/path/to/at/s33/8.pgm;32
|
||||
/path/to/at/s33/1.pgm;32
|
||||
/path/to/at/s12/2.pgm;11
|
||||
/path/to/at/s12/7.pgm;11
|
||||
/path/to/at/s12/6.pgm;11
|
||||
/path/to/at/s12/9.pgm;11
|
||||
/path/to/at/s12/5.pgm;11
|
||||
/path/to/at/s12/3.pgm;11
|
||||
/path/to/at/s12/4.pgm;11
|
||||
/path/to/at/s12/10.pgm;11
|
||||
/path/to/at/s12/8.pgm;11
|
||||
/path/to/at/s12/1.pgm;11
|
||||
/path/to/at/s6/2.pgm;5
|
||||
/path/to/at/s6/7.pgm;5
|
||||
/path/to/at/s6/6.pgm;5
|
||||
/path/to/at/s6/9.pgm;5
|
||||
/path/to/at/s6/5.pgm;5
|
||||
/path/to/at/s6/3.pgm;5
|
||||
/path/to/at/s6/4.pgm;5
|
||||
/path/to/at/s6/10.pgm;5
|
||||
/path/to/at/s6/8.pgm;5
|
||||
/path/to/at/s6/1.pgm;5
|
||||
/path/to/at/s22/2.pgm;21
|
||||
/path/to/at/s22/7.pgm;21
|
||||
/path/to/at/s22/6.pgm;21
|
||||
/path/to/at/s22/9.pgm;21
|
||||
/path/to/at/s22/5.pgm;21
|
||||
/path/to/at/s22/3.pgm;21
|
||||
/path/to/at/s22/4.pgm;21
|
||||
/path/to/at/s22/10.pgm;21
|
||||
/path/to/at/s22/8.pgm;21
|
||||
/path/to/at/s22/1.pgm;21
|
||||
/path/to/at/s15/2.pgm;14
|
||||
/path/to/at/s15/7.pgm;14
|
||||
/path/to/at/s15/6.pgm;14
|
||||
/path/to/at/s15/9.pgm;14
|
||||
/path/to/at/s15/5.pgm;14
|
||||
/path/to/at/s15/3.pgm;14
|
||||
/path/to/at/s15/4.pgm;14
|
||||
/path/to/at/s15/10.pgm;14
|
||||
/path/to/at/s15/8.pgm;14
|
||||
/path/to/at/s15/1.pgm;14
|
||||
/path/to/at/s2/2.pgm;1
|
||||
/path/to/at/s2/7.pgm;1
|
||||
/path/to/at/s2/6.pgm;1
|
||||
/path/to/at/s2/9.pgm;1
|
||||
/path/to/at/s2/5.pgm;1
|
||||
/path/to/at/s2/3.pgm;1
|
||||
/path/to/at/s2/4.pgm;1
|
||||
/path/to/at/s2/10.pgm;1
|
||||
/path/to/at/s2/8.pgm;1
|
||||
/path/to/at/s2/1.pgm;1
|
||||
/path/to/at/s31/2.pgm;30
|
||||
/path/to/at/s31/7.pgm;30
|
||||
/path/to/at/s31/6.pgm;30
|
||||
/path/to/at/s31/9.pgm;30
|
||||
/path/to/at/s31/5.pgm;30
|
||||
/path/to/at/s31/3.pgm;30
|
||||
/path/to/at/s31/4.pgm;30
|
||||
/path/to/at/s31/10.pgm;30
|
||||
/path/to/at/s31/8.pgm;30
|
||||
/path/to/at/s31/1.pgm;30
|
||||
/path/to/at/s28/2.pgm;27
|
||||
/path/to/at/s28/7.pgm;27
|
||||
/path/to/at/s28/6.pgm;27
|
||||
/path/to/at/s28/9.pgm;27
|
||||
/path/to/at/s28/5.pgm;27
|
||||
/path/to/at/s28/3.pgm;27
|
||||
/path/to/at/s28/4.pgm;27
|
||||
/path/to/at/s28/10.pgm;27
|
||||
/path/to/at/s28/8.pgm;27
|
||||
/path/to/at/s28/1.pgm;27
|
||||
/path/to/at/s40/2.pgm;39
|
||||
/path/to/at/s40/7.pgm;39
|
||||
/path/to/at/s40/6.pgm;39
|
||||
/path/to/at/s40/9.pgm;39
|
||||
/path/to/at/s40/5.pgm;39
|
||||
/path/to/at/s40/3.pgm;39
|
||||
/path/to/at/s40/4.pgm;39
|
||||
/path/to/at/s40/10.pgm;39
|
||||
/path/to/at/s40/8.pgm;39
|
||||
/path/to/at/s40/1.pgm;39
|
||||
/path/to/at/s3/2.pgm;2
|
||||
/path/to/at/s3/7.pgm;2
|
||||
/path/to/at/s3/6.pgm;2
|
||||
/path/to/at/s3/9.pgm;2
|
||||
/path/to/at/s3/5.pgm;2
|
||||
/path/to/at/s3/3.pgm;2
|
||||
/path/to/at/s3/4.pgm;2
|
||||
/path/to/at/s3/10.pgm;2
|
||||
/path/to/at/s3/8.pgm;2
|
||||
/path/to/at/s3/1.pgm;2
|
||||
/path/to/at/s38/2.pgm;37
|
||||
/path/to/at/s38/7.pgm;37
|
||||
/path/to/at/s38/6.pgm;37
|
||||
/path/to/at/s38/9.pgm;37
|
||||
/path/to/at/s38/5.pgm;37
|
||||
/path/to/at/s38/3.pgm;37
|
||||
/path/to/at/s38/4.pgm;37
|
||||
/path/to/at/s38/10.pgm;37
|
||||
/path/to/at/s38/8.pgm;37
|
||||
/path/to/at/s38/1.pgm;37
|
@@ -19,6 +19,7 @@
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/face.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@@ -50,7 +51,7 @@ static void read_csv(const string& filename, vector<Mat>& images, vector<int>& l
|
||||
std::ifstream file(filename.c_str(), ifstream::in);
|
||||
if (!file) {
|
||||
string error_message = "No valid input file was given, please check the given filename.";
|
||||
CV_Error(CV_StsBadArg, error_message);
|
||||
CV_Error(Error::StsBadArg, error_message);
|
||||
}
|
||||
string line, path, classlabel;
|
||||
while (getline(file, line)) {
|
||||
@@ -92,7 +93,7 @@ int main(int argc, const char *argv[]) {
|
||||
// Quit if there are not enough images for this demo.
|
||||
if(images.size() <= 1) {
|
||||
string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
|
||||
CV_Error(CV_StsError, error_message);
|
||||
CV_Error(Error::StsError, error_message);
|
||||
}
|
||||
// Get the height from the first image. We'll need this
|
||||
// later in code to reshape the images to their original
|
||||
@@ -101,7 +102,7 @@ int main(int argc, const char *argv[]) {
|
||||
// The following lines simply get the last images from
|
||||
// your dataset and remove it from the vector. This is
|
||||
// done, so that the training data (which we learn the
|
||||
// cv::FaceRecognizer on) and the test data we test
|
||||
// cv::BasicFaceRecognizer on) and the test data we test
|
||||
// the model with, do not overlap.
|
||||
Mat testSample = images[images.size() - 1];
|
||||
int testLabel = labels[labels.size() - 1];
|
||||
@@ -126,7 +127,7 @@ int main(int argc, const char *argv[]) {
|
||||
//
|
||||
// cv::createEigenFaceRecognizer(0, 123.0);
|
||||
//
|
||||
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
|
||||
Ptr<BasicFaceRecognizer> model = createEigenFaceRecognizer();
|
||||
model->train(images, labels);
|
||||
// The following line predicts the label of a given
|
||||
// test image:
|
||||
@@ -141,11 +142,11 @@ int main(int argc, const char *argv[]) {
|
||||
string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
|
||||
cout << result_message << endl;
|
||||
// Here is how to get the eigenvalues of this Eigenfaces model:
|
||||
Mat eigenvalues = model->getMat("eigenvalues");
|
||||
Mat eigenvalues = model->getEigenValues();
|
||||
// And we can do the same to display the Eigenvectors (read Eigenfaces):
|
||||
Mat W = model->getMat("eigenvectors");
|
||||
Mat W = model->getEigenVectors();
|
||||
// Get the sample mean from the training data
|
||||
Mat mean = model->getMat("mean");
|
||||
Mat mean = model->getMean();
|
||||
// Display or save:
|
||||
if(argc == 2) {
|
||||
imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
|
||||
@@ -175,8 +176,8 @@ int main(int argc, const char *argv[]) {
|
||||
for(int num_components = min(W.cols, 10); num_components < min(W.cols, 300); num_components+=15) {
|
||||
// slice the eigenvectors from the model
|
||||
Mat evs = Mat(W, Range::all(), Range(0, num_components));
|
||||
Mat projection = subspaceProject(evs, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = subspaceReconstruct(evs, mean, projection);
|
||||
Mat projection = LDA::subspaceProject(evs, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = LDA::subspaceReconstruct(evs, mean, projection);
|
||||
// Normalize the result:
|
||||
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
|
||||
// Display or save:
|
@@ -19,6 +19,7 @@
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/face.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@@ -50,7 +51,7 @@ static void read_csv(const string& filename, vector<Mat>& images, vector<int>& l
|
||||
std::ifstream file(filename.c_str(), ifstream::in);
|
||||
if (!file) {
|
||||
string error_message = "No valid input file was given, please check the given filename.";
|
||||
CV_Error(CV_StsBadArg, error_message);
|
||||
CV_Error(Error::StsBadArg, error_message);
|
||||
}
|
||||
string line, path, classlabel;
|
||||
while (getline(file, line)) {
|
||||
@@ -92,7 +93,7 @@ int main(int argc, const char *argv[]) {
|
||||
// Quit if there are not enough images for this demo.
|
||||
if(images.size() <= 1) {
|
||||
string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
|
||||
CV_Error(CV_StsError, error_message);
|
||||
CV_Error(Error::StsError, error_message);
|
||||
}
|
||||
// Get the height from the first image. We'll need this
|
||||
// later in code to reshape the images to their original
|
||||
@@ -101,7 +102,7 @@ int main(int argc, const char *argv[]) {
|
||||
// The following lines simply get the last images from
|
||||
// your dataset and remove it from the vector. This is
|
||||
// done, so that the training data (which we learn the
|
||||
// cv::FaceRecognizer on) and the test data we test
|
||||
// cv::BasicFaceRecognizer on) and the test data we test
|
||||
// the model with, do not overlap.
|
||||
Mat testSample = images[images.size() - 1];
|
||||
int testLabel = labels[labels.size() - 1];
|
||||
@@ -125,7 +126,7 @@ int main(int argc, const char *argv[]) {
|
||||
//
|
||||
// cv::createFisherFaceRecognizer(0, 123.0);
|
||||
//
|
||||
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
|
||||
Ptr<BasicFaceRecognizer> model = createFisherFaceRecognizer();
|
||||
model->train(images, labels);
|
||||
// The following line predicts the label of a given
|
||||
// test image:
|
||||
@@ -140,11 +141,11 @@ int main(int argc, const char *argv[]) {
|
||||
string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
|
||||
cout << result_message << endl;
|
||||
// Here is how to get the eigenvalues of this Eigenfaces model:
|
||||
Mat eigenvalues = model->getMat("eigenvalues");
|
||||
Mat eigenvalues = model->getEigenValues();
|
||||
// And we can do the same to display the Eigenvectors (read Eigenfaces):
|
||||
Mat W = model->getMat("eigenvectors");
|
||||
Mat W = model->getEigenVectors();
|
||||
// Get the sample mean from the training data
|
||||
Mat mean = model->getMat("mean");
|
||||
Mat mean = model->getMean();
|
||||
// Display or save:
|
||||
if(argc == 2) {
|
||||
imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
|
||||
@@ -173,8 +174,8 @@ int main(int argc, const char *argv[]) {
|
||||
for(int num_component = 0; num_component < min(16, W.cols); num_component++) {
|
||||
// Slice the Fisherface from the model:
|
||||
Mat ev = W.col(num_component);
|
||||
Mat projection = subspaceProject(ev, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = subspaceReconstruct(ev, mean, projection);
|
||||
Mat projection = LDA::subspaceProject(ev, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = LDA::subspaceReconstruct(ev, mean, projection);
|
||||
// Normalize the result:
|
||||
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
|
||||
// Display or save:
|
@@ -32,7 +32,7 @@ static void read_csv(const string& filename, vector<Mat>& images, vector<int>& l
|
||||
std::ifstream file(filename.c_str(), ifstream::in);
|
||||
if (!file) {
|
||||
string error_message = "No valid input file was given, please check the given filename.";
|
||||
CV_Error(CV_StsBadArg, error_message);
|
||||
CV_Error(Error::StsBadArg, error_message);
|
||||
}
|
||||
string line, path, classlabel;
|
||||
while (getline(file, line)) {
|
||||
@@ -70,16 +70,12 @@ int main(int argc, const char *argv[]) {
|
||||
// Quit if there are not enough images for this demo.
|
||||
if(images.size() <= 1) {
|
||||
string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
|
||||
CV_Error(CV_StsError, error_message);
|
||||
CV_Error(Error::StsError, error_message);
|
||||
}
|
||||
// Get the height from the first image. We'll need this
|
||||
// later in code to reshape the images to their original
|
||||
// size:
|
||||
int height = images[0].rows;
|
||||
// The following lines simply get the last images from
|
||||
// your dataset and remove it from the vector. This is
|
||||
// done, so that the training data (which we learn the
|
||||
// cv::FaceRecognizer on) and the test data we test
|
||||
// cv::LBPHFaceRecognizer on) and the test data we test
|
||||
// the model with, do not overlap.
|
||||
Mat testSample = images[images.size() - 1];
|
||||
int testLabel = labels[labels.size() - 1];
|
||||
@@ -107,7 +103,7 @@ int main(int argc, const char *argv[]) {
|
||||
//
|
||||
// cv::createLBPHFaceRecognizer(1,8,8,8,123.0)
|
||||
//
|
||||
Ptr<FaceRecognizer> model = createLBPHFaceRecognizer();
|
||||
Ptr<LBPHFaceRecognizer> model = createLBPHFaceRecognizer();
|
||||
model->train(images, labels);
|
||||
// The following line predicts the label of a given
|
||||
// test image:
|
||||
@@ -121,16 +117,11 @@ int main(int argc, const char *argv[]) {
|
||||
//
|
||||
string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
|
||||
cout << result_message << endl;
|
||||
// Sometimes you'll need to get/set internal model data,
|
||||
// which isn't exposed by the public cv::FaceRecognizer.
|
||||
// Since each cv::FaceRecognizer is derived from a
|
||||
// cv::Algorithm, you can query the data.
|
||||
//
|
||||
// First we'll use it to set the threshold of the FaceRecognizer
|
||||
// First we'll use it to set the threshold of the LBPHFaceRecognizer
|
||||
// to 0.0 without retraining the model. This can be useful if
|
||||
// you are evaluating the model:
|
||||
//
|
||||
model->set("threshold", 0.0);
|
||||
model->setThreshold(0.0);
|
||||
// Now the threshold of this model is set to 0.0. A prediction
|
||||
// now returns -1, as it's impossible to have a distance below
|
||||
// it
|
||||
@@ -142,14 +133,14 @@ int main(int argc, const char *argv[]) {
|
||||
// within the model:
|
||||
cout << "Model Information:" << endl;
|
||||
string model_info = format("\tLBPH(radius=%i, neighbors=%i, grid_x=%i, grid_y=%i, threshold=%.2f)",
|
||||
model->getInt("radius"),
|
||||
model->getInt("neighbors"),
|
||||
model->getInt("grid_x"),
|
||||
model->getInt("grid_y"),
|
||||
model->getDouble("threshold"));
|
||||
model->getRadius(),
|
||||
model->getNeighbors(),
|
||||
model->getGridX(),
|
||||
model->getGridY(),
|
||||
model->getThreshold());
|
||||
cout << model_info << endl;
|
||||
// We could get the histograms for example:
|
||||
vector<Mat> histograms = model->getMatVector("histograms");
|
||||
vector<Mat> histograms = model->getHistograms();
|
||||
// But should I really visualize it? Probably the length is interesting:
|
||||
cout << "Size of the histograms: " << histograms[0].total() << endl;
|
||||
return 0;
|
@@ -19,6 +19,7 @@
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/face.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@@ -50,7 +51,7 @@ static void read_csv(const string& filename, vector<Mat>& images, vector<int>& l
|
||||
std::ifstream file(filename.c_str(), ifstream::in);
|
||||
if (!file) {
|
||||
string error_message = "No valid input file was given, please check the given filename.";
|
||||
CV_Error(CV_StsBadArg, error_message);
|
||||
CV_Error(Error::StsBadArg, error_message);
|
||||
}
|
||||
string line, path, classlabel;
|
||||
while (getline(file, line)) {
|
||||
@@ -92,7 +93,7 @@ int main(int argc, const char *argv[]) {
|
||||
// Quit if there are not enough images for this demo.
|
||||
if(images.size() <= 1) {
|
||||
string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
|
||||
CV_Error(CV_StsError, error_message);
|
||||
CV_Error(Error::StsError, error_message);
|
||||
}
|
||||
// Get the height from the first image. We'll need this
|
||||
// later in code to reshape the images to their original
|
||||
@@ -126,7 +127,7 @@ int main(int argc, const char *argv[]) {
|
||||
//
|
||||
// cv::createEigenFaceRecognizer(0, 123.0);
|
||||
//
|
||||
Ptr<FaceRecognizer> model0 = createEigenFaceRecognizer();
|
||||
Ptr<BasicFaceRecognizer> model0 = createEigenFaceRecognizer();
|
||||
model0->train(images, labels);
|
||||
// save the model to eigenfaces_at.yaml
|
||||
model0->save("eigenfaces_at.yml");
|
||||
@@ -134,7 +135,7 @@ int main(int argc, const char *argv[]) {
|
||||
//
|
||||
// Now create a new Eigenfaces Recognizer
|
||||
//
|
||||
Ptr<FaceRecognizer> model1 = createEigenFaceRecognizer();
|
||||
Ptr<BasicFaceRecognizer> model1 = createEigenFaceRecognizer();
|
||||
model1->load("eigenfaces_at.yml");
|
||||
// The following line predicts the label of a given
|
||||
// test image:
|
||||
@@ -149,11 +150,11 @@ int main(int argc, const char *argv[]) {
|
||||
string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
|
||||
cout << result_message << endl;
|
||||
// Here is how to get the eigenvalues of this Eigenfaces model:
|
||||
Mat eigenvalues = model1->getMat("eigenvalues");
|
||||
Mat eigenvalues = model1->getEigenValues();
|
||||
// And we can do the same to display the Eigenvectors (read Eigenfaces):
|
||||
Mat W = model1->getMat("eigenvectors");
|
||||
Mat W = model1->getEigenVectors();
|
||||
// Get the sample mean from the training data
|
||||
Mat mean = model1->getMat("mean");
|
||||
Mat mean = model1->getMean();
|
||||
// Display or save:
|
||||
if(argc == 2) {
|
||||
imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
|
||||
@@ -182,8 +183,8 @@ int main(int argc, const char *argv[]) {
|
||||
for(int num_components = 10; num_components < 300; num_components+=15) {
|
||||
// slice the eigenvectors from the model
|
||||
Mat evs = Mat(W, Range::all(), Range(0, num_components));
|
||||
Mat projection = subspaceProject(evs, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = subspaceReconstruct(evs, mean, projection);
|
||||
Mat projection = LDA::subspaceProject(evs, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = LDA::subspaceReconstruct(evs, mean, projection);
|
||||
// Normalize the result:
|
||||
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
|
||||
// Display or save:
|
@@ -34,7 +34,7 @@ static void read_csv(const string& filename, vector<Mat>& images, vector<int>& l
|
||||
std::ifstream file(filename.c_str(), ifstream::in);
|
||||
if (!file) {
|
||||
string error_message = "No valid input file was given, please check the given filename.";
|
||||
CV_Error(CV_StsBadArg, error_message);
|
||||
CV_Error(Error::StsBadArg, error_message);
|
||||
}
|
||||
string line, path, classlabel;
|
||||
while (getline(file, line)) {
|
||||
@@ -79,7 +79,7 @@ int main(int argc, const char *argv[]) {
|
||||
int im_width = images[0].cols;
|
||||
int im_height = images[0].rows;
|
||||
// Create a FaceRecognizer and train it on the given images:
|
||||
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
|
||||
Ptr<BasicFaceRecognizer> model = createFisherFaceRecognizer();
|
||||
model->train(images, labels);
|
||||
// That's it for learning the Face Recognition model. You now
|
||||
// need to create the classifier for the task of Face Detection.
|
||||
@@ -103,14 +103,14 @@ int main(int argc, const char *argv[]) {
|
||||
Mat original = frame.clone();
|
||||
// Convert the current frame to grayscale:
|
||||
Mat gray;
|
||||
cvtColor(original, gray, CV_BGR2GRAY);
|
||||
cvtColor(original, gray, COLOR_BGR2GRAY);
|
||||
// Find the faces in the frame:
|
||||
vector< Rect_<int> > faces;
|
||||
haar_cascade.detectMultiScale(gray, faces);
|
||||
// At this point you have the position of the faces in
|
||||
// faces. Now we'll get the faces, make a prediction and
|
||||
// annotate it in the video. Cool or what?
|
||||
for(int i = 0; i < faces.size(); i++) {
|
||||
for(size_t i = 0; i < faces.size(); i++) {
|
||||
// Process face by face:
|
||||
Rect face_i = faces[i];
|
||||
// Crop the face from the image. So simple with OpenCV C++:
|
||||
@@ -131,7 +131,7 @@ int main(int argc, const char *argv[]) {
|
||||
int prediction = model->predict(face_resized);
|
||||
// And finally write all we've found out to the original image!
|
||||
// First of all draw a green rectangle around the detected face:
|
||||
rectangle(original, face_i, CV_RGB(0, 255,0), 1);
|
||||
rectangle(original, face_i, Scalar(0, 255,0), 1);
|
||||
// Create the text we will annotate the box with:
|
||||
string box_text = format("Prediction = %d", prediction);
|
||||
// Calculate the position for annotated text (make sure we don't
|
||||
@@ -139,7 +139,7 @@ int main(int argc, const char *argv[]) {
|
||||
int pos_x = std::max(face_i.tl().x - 10, 0);
|
||||
int pos_y = std::max(face_i.tl().y - 10, 0);
|
||||
// And now put it into the image:
|
||||
putText(original, box_text, Point(pos_x, pos_y), FONT_HERSHEY_PLAIN, 1.0, CV_RGB(0,255,0), 2.0);
|
||||
putText(original, box_text, Point(pos_x, pos_y), FONT_HERSHEY_PLAIN, 1.0, Scalar(0,255,0), 2);
|
||||
}
|
||||
// Show the result:
|
||||
imshow("face_recognizer", original);
|
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
|
||||
* Released to public domain under terms of the BSD Simplified license.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the organization nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* See <http://www.opensource.org/licenses/bsd-license>
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/face.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::face;
|
||||
using namespace std;
|
||||
|
||||
static Mat norm_0_255(InputArray _src) {
|
||||
Mat src = _src.getMat();
|
||||
// Create and return normalized image:
|
||||
Mat dst;
|
||||
switch(src.channels()) {
|
||||
case 1:
|
||||
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
|
||||
break;
|
||||
case 3:
|
||||
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
|
||||
break;
|
||||
default:
|
||||
src.copyTo(dst);
|
||||
break;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
|
||||
std::ifstream file(filename.c_str(), ifstream::in);
|
||||
if (!file) {
|
||||
string error_message = "No valid input file was given, please check the given filename.";
|
||||
CV_Error(CV_StsBadArg, error_message);
|
||||
}
|
||||
string line, path, classlabel;
|
||||
while (getline(file, line)) {
|
||||
stringstream liness(line);
|
||||
getline(liness, path, separator);
|
||||
getline(liness, classlabel);
|
||||
if(!path.empty() && !classlabel.empty()) {
|
||||
images.push_back(imread(path, 0));
|
||||
labels.push_back(atoi(classlabel.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
// Check for valid command line arguments, print usage
|
||||
// if no arguments were given.
|
||||
if (argc != 2) {
|
||||
cout << "usage: " << argv[0] << " <csv.ext>" << endl;
|
||||
exit(1);
|
||||
}
|
||||
// Get the path to your CSV.
|
||||
string fn_csv = string(argv[1]);
|
||||
// These vectors hold the images and corresponding labels.
|
||||
vector<Mat> images;
|
||||
vector<int> labels;
|
||||
// Read in the data. This can fail if no valid
|
||||
// input filename is given.
|
||||
try {
|
||||
read_csv(fn_csv, images, labels);
|
||||
} catch (cv::Exception& e) {
|
||||
cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
|
||||
// nothing more we can do
|
||||
exit(1);
|
||||
}
|
||||
// Quit if there are not enough images for this demo.
|
||||
if(images.size() <= 1) {
|
||||
string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
|
||||
CV_Error(CV_StsError, error_message);
|
||||
}
|
||||
// Get the height from the first image. We'll need this
|
||||
// later in code to reshape the images to their original
|
||||
// size:
|
||||
int height = images[0].rows;
|
||||
// The following lines simply get the last images from
|
||||
// your dataset and remove it from the vector. This is
|
||||
// done, so that the training data (which we learn the
|
||||
// cv::FaceRecognizer on) and the test data we test
|
||||
// the model with, do not overlap.
|
||||
Mat testSample = images[images.size() - 1];
|
||||
int testLabel = labels[labels.size() - 1];
|
||||
images.pop_back();
|
||||
labels.pop_back();
|
||||
// The following lines create an Eigenfaces model for
|
||||
// face recognition and train it with the images and
|
||||
// labels read from the given CSV file.
|
||||
// This here is a full PCA, if you just want to keep
|
||||
// 10 principal components (read Eigenfaces), then call
|
||||
// the factory method like this:
|
||||
//
|
||||
// cv::createEigenFaceRecognizer(10);
|
||||
//
|
||||
// If you want to create a FaceRecognizer with a
|
||||
// confidennce threshold, call it with:
|
||||
//
|
||||
// cv::createEigenFaceRecognizer(10, 123.0);
|
||||
//
|
||||
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
|
||||
model->train(images, labels);
|
||||
// The following line predicts the label of a given
|
||||
// test image:
|
||||
int predictedLabel = model->predict(testSample);
|
||||
//
|
||||
// To get the confidence of a prediction call the model with:
|
||||
//
|
||||
// int predictedLabel = -1;
|
||||
// double confidence = 0.0;
|
||||
// model->predict(testSample, predictedLabel, confidence);
|
||||
//
|
||||
string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
|
||||
cout << result_message << endl;
|
||||
// Sometimes you'll need to get/set internal model data,
|
||||
// which isn't exposed by the public cv::FaceRecognizer.
|
||||
// Since each cv::FaceRecognizer is derived from a
|
||||
// cv::Algorithm, you can query the data.
|
||||
//
|
||||
// First we'll use it to set the threshold of the FaceRecognizer
|
||||
// to 0.0 without retraining the model. This can be useful if
|
||||
// you are evaluating the model:
|
||||
//
|
||||
model->set("threshold", 0.0);
|
||||
// Now the threshold of this model is set to 0.0. A prediction
|
||||
// now returns -1, as it's impossible to have a distance below
|
||||
// it
|
||||
predictedLabel = model->predict(testSample);
|
||||
cout << "Predicted class = " << predictedLabel << endl;
|
||||
// Here is how to get the eigenvalues of this Eigenfaces model:
|
||||
Mat eigenvalues = model->getMat("eigenvalues");
|
||||
// And we can do the same to display the Eigenvectors (read Eigenfaces):
|
||||
Mat W = model->getMat("eigenvectors");
|
||||
// From this we will display the (at most) first 10 Eigenfaces:
|
||||
for (int i = 0; i < min(10, W.cols); i++) {
|
||||
string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
|
||||
cout << msg << endl;
|
||||
// get eigenvector #i
|
||||
Mat ev = W.col(i).clone();
|
||||
// Reshape to original size & normalize to [0...255] for imshow.
|
||||
Mat grayscale = norm_0_255(ev.reshape(1, height));
|
||||
// Show the image & apply a Jet colormap for better sensing.
|
||||
Mat cgrayscale;
|
||||
applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
|
||||
imshow(format("%d", i), cgrayscale);
|
||||
}
|
||||
waitKey(0);
|
||||
|
||||
return 0;
|
||||
}
|
@@ -246,7 +246,7 @@ every source code listing is commented in detail, so you should have no problems
|
||||
The source code for this demo application is also available in the src folder coming with this
|
||||
documentation:
|
||||
|
||||
@include src/facerec_eigenfaces.cpp
|
||||
@include face/samples/facerec_eigenfaces.cpp
|
||||
|
||||
I've used the jet colormap, so you can see how the grayscale values are distributed within the
|
||||
specific Eigenfaces. You can see, that the Eigenfaces do not only encode facial features, but also
|
||||
@@ -263,8 +263,8 @@ let's see how many Eigenfaces are needed for a good reconstruction. I'll do a su
|
||||
for(int num_components = 10; num_components < 300; num_components+=15) {
|
||||
// slice the eigenvectors from the model
|
||||
Mat evs = Mat(W, Range::all(), Range(0, num_components));
|
||||
Mat projection = subspaceProject(evs, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = subspaceReconstruct(evs, mean, projection);
|
||||
Mat projection = LDA::subspaceProject(evs, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = LDA::subspaceReconstruct(evs, mean, projection);
|
||||
// Normalize the result:
|
||||
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
|
||||
// Display or save:
|
||||
@@ -370,7 +370,7 @@ given by:
|
||||
The source code for this demo application is also available in the src folder coming with this
|
||||
documentation:
|
||||
|
||||
@include src/facerec_fisherfaces.cpp
|
||||
@include face/samples/facerec_fisherfaces.cpp
|
||||
|
||||
For this example I am going to use the Yale Facedatabase A, just because the plots are nicer. Each
|
||||
Fisherface has the same length as an original image, thus it can be displayed as an image. The demo
|
||||
@@ -398,8 +398,8 @@ Fisherfaces describes:
|
||||
for(int num_component = 0; num_component < min(16, W.cols); num_component++) {
|
||||
// Slice the Fisherface from the model:
|
||||
Mat ev = W.col(num_component);
|
||||
Mat projection = subspaceProject(ev, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = subspaceReconstruct(ev, mean, projection);
|
||||
Mat projection = LDA::subspaceProject(ev, mean, images[0].reshape(1,1));
|
||||
Mat reconstruction = LDA::subspaceReconstruct(ev, mean, projection);
|
||||
// Normalize the result:
|
||||
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
|
||||
// Display or save:
|
||||
@@ -528,7 +528,7 @@ Patterns Histograms*.
|
||||
The source code for this demo application is also available in the src folder coming with this
|
||||
documentation:
|
||||
|
||||
@include src/facerec_lbph.cpp
|
||||
@include face/samples/facerec_lbph.cpp
|
||||
|
||||
Conclusion {#tutorial_face_conclusion}
|
||||
----------
|
||||
@@ -658,7 +658,7 @@ at/s17/3.pgm;1
|
||||
|
||||
Here is the script, if you can't find it:
|
||||
|
||||
@verbinclude face/samples/src/create_csv.py
|
||||
@verbinclude face/samples/etc/create_csv.py
|
||||
|
||||
### Aligning Face Images {#tutorial_face_appendix_align}
|
||||
|
||||
@@ -677,7 +677,7 @@ where:
|
||||
If you are using the same *offset_pct* and *dest_sz* for your images, they are all aligned at the
|
||||
eyes.
|
||||
|
||||
@verbinclude face/samples/src/crop_face.py
|
||||
@verbinclude face/samples/etc/crop_face.py
|
||||
|
||||
Imagine we are given [this photo of Arnold
|
||||
Schwarzenegger](http://en.wikipedia.org/wiki/File:Arnold_Schwarzenegger_edit%28ws%29.jpg), which is
|
||||
|
Reference in New Issue
Block a user