TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
goo hey
NA
29
5.1k
Facial recognition issue
Jun 16 2020 5:35 AM
Can some help me with this issue, have a facial recognition app but when my camera records an image of a person who is not in the database yet, the application still displays the name of a person I have added to the database... some code below i think the issue might be
if
(isTrained) {
Image < Gray, Byte > grayFaceResult = resultImage.Convert < Gray, Byte > ().Resize(200, 200, Inter.Cubic);
CvInvoke.EqualizeHist(grayFaceResult, grayFaceResult);
var result = recognizer.Predict(grayFaceResult);
pictureBox1.Image = grayFaceResult.Bitmap;
pictureBox2.Image = TrainedFaces[result.Label].Bitmap;
Debug.WriteLine(result.Label +
". "
+ result.Distance);
//Here results found known faces
if
(result.Label != -1 && result.Distance < 2000) {
CvInvoke.PutText(currentFrame, PersonsNames[result.Label],
new
Point(face.X - 2, face.Y - 2),
FontFace.HersheyComplex, 1.0,
new
Bgr(Color.Orange).MCvScalar);
CvInvoke.Rectangle(currentFrame, face,
new
Bgr(Color.Green).MCvScalar, 2);
}
//here results did not found any know faces
else
{
CvInvoke.PutText(currentFrame,
"Unknown"
,
new
Point(face.X - 2, face.Y - 2),
FontFace.HersheyComplex, 1.0,
new
Bgr(Color.Orange).MCvScalar);
CvInvoke.Rectangle(currentFrame, face,
new
Bgr(Color.Red).MCvScalar, 2);
}
}
private
bool
TrainImagesFromDir() {
int
ImagesCount = 0;
double
Threshold = 2000;
TrainedFaces.Clear();
PersonsLabes.Clear();
PersonsNames.Clear();
try
{
string
path = Directory.GetCurrentDirectory() + @
"\TrainedImages"
;
string
[] files = Directory.GetFiles(path,
"*.jpg"
, SearchOption.AllDirectories);
foreach
(var file
in
files) {
Image < Gray,
byte
> trainedImage =
new
Image < Gray,
byte
> (file).Resize(200, 200, Inter.Cubic);
CvInvoke.EqualizeHist(trainedImage, trainedImage);
TrainedFaces.Add(trainedImage);
PersonsLabes.Add(ImagesCount);
string
name = file.Split(
'\\').Last().Split('
_')[0];
PersonsNames.Add(name);
ImagesCount++;
Debug.WriteLine(ImagesCount +
". "
+ name);
}
if
(TrainedFaces.Count() > 0) {
// recognizer = new EigenFaceRecognizer(ImagesCount,Threshold);
recognizer =
new
EigenFaceRecognizer(ImagesCount, Threshold);
recognizer.Train(TrainedFaces.ToArray(), PersonsLabes.ToArray());
isTrained =
true
;
//Debug.WriteLine(ImagesCount);
//Debug.WriteLine(isTrained);
return
true
;
}
else
{
isTrained =
false
;
return
false
;
}
}
catch
(Exception ex) {
isTrained =
false
;
MessageBox.Show(
"Error in Train Images: "
+ ex.Message);
return
false
;
}
Reply
Answers (
0
)
Asynchronously sending Emails in Vb.net?
The name Savechanges() does not exist in the current context