No face detection?

Dec 20, 2011 at 7:47 PM

Hi!

I've just built the source code and tried on HTC 7 Trophy and HTC 7 Pro. I've tried also various lighting conditions. Still no face detection. What am I doing wrong?

PreviewResolution for both phones is 640x480 - may this be the issue?

Coordinator
Dec 27, 2011 at 7:10 PM

Apologies for the late reply. The face detection works well on my phone (Samsung Focus) in decent lighting conditions and for different faces. The resolution should be okay, an issue might be the face size. Are the faces you are using small? See if you can detect the face at: http://www.slendertone.com/Face/images/face_large_2.jpg. I will try to take a look at this later tonight when I get home.

Dec 27, 2011 at 8:07 PM

I just had a chance to test the application on "LG E900 Optimus 7" and works fine. Seems there may be the issue only with HTC phones. I will analyse this some later time during the project.

Coordinator
Dec 28, 2011 at 4:16 AM

Yeah I've had some problems with HTC phones with testers of my app as well. The app crashes when it tries to get preview buffer y (greyscale preview buffer). I don't know why it isn't working, hard to debug because I don't have an HTC phone. Ugh, all phones should work the same! Phone specific issues are very difficult to deal with.

Mar 23, 2012 at 12:06 AM

Hi,

sorry i know this discussion is old, but i got the same error.
I'm searching for a Augmented Reality Library. I dont want face detection, but any other objects.
As i read on your start page i can change the detection by providing other xml files.

for testing i installed your testapp on my nokia lumia 800. but it detects nothing. no matter if picture of face or real face.
I recognized the camera isnt focused. is this a problem?

 

Hope you can help me
caldi

Coordinator
Mar 24, 2012 at 9:06 PM

Hi caldi,

 

I am going to look into this now, but it's very tough for me to debug these issues because I have a nokia phone! I do know of a couple non-standard things my app does so I will try to make my app comply with what the samples on msdn suggest. Just to confirm, are you able to run the application at http://go.microsoft.com/fwlink/?LinkId=219063? It is the grayscale phone sample

Mar 24, 2012 at 11:21 PM
Edited Mar 24, 2012 at 11:28 PM

Hi julenka,

thanks for your quick reply.
I've just downloaded the grayscale sample and it works perfectly.

If i can help finding the problem, please let me know.

I'm quite new to Windows Phone, and to image analysing.
 You assume, that the probleme occur by getting the grayscale buffer from camera or converting grayscale to argb?

Perhaps this can help you:
In the "DoFaceDetection" method the GetPreviewBufferArgb32 method is called without any exceptions.
It seems you would excpect an error in some cases?!

                try
                {
                    m_camera.GetPreviewBufferY(pixelDataGray);
                }
                catch (InvalidOperationException e)
                {
                    m_camera.GetPreviewBufferArgb32(pixelDataArgb);
                    pixelDataGray = Utils.HistogramEqualization(Utils.GetGrayscaleBytes(pixelDataArgb));
                }

Thanks for your help caldi

Coordinator
Mar 25, 2012 at 5:28 AM

Caldi,

Can you download the latest revision (or do an update in mercurial) and test out that version? In this revision I also refactored the code so that there's a seperate "cameraviewer" control that you might find useful in the future...

Mar 25, 2012 at 12:49 PM

Hi julenka,

sadly, it doesnt work.
I get the grayscale picture in the upper left corner, but no faces were detected.

thanks
caldi

Coordinator
Mar 25, 2012 at 4:12 PM
Edited Mar 25, 2012 at 4:12 PM

Just to be consistent, can you confirm that you cannot recognize the following face: http://arizonafoothillsmagazine.com/images/stories/april09/face-recognition.jpg

Note the faces need to be fairly large to be found with the settings in the sample. 

Can you also please confirm that zero faces are found by setting a breakpoint right after the following code in MainPage.xaml.cs? The faces list should be empty if no faces are found. Also, remember to grab the LATEST release (the previous 2 releases were broken).

List<FaceDetectionWinPhone.Rectangle> faces = 
                _detector.getFaces(
                _pixelDataGrayInt, 
                w / _downsampleFactor, 
                h / _downsampleFactor, 
                2f, 1.25f, 0.1f, 1, false);
Coordinator
Mar 25, 2012 at 4:16 PM

Note that to verify that you have the latest version you should see some text under the grayscale image that says "Processed data"

Mar 25, 2012 at 7:23 PM

Hi,

I've just tested your new version (changeset 89476d774df6) with the "face-recognition.jpg" image.
"Processed Data" is shown under the grayscale picture.

The faces list is empty.
I've tested it by writing "faces.Count" in the immediate window:
faces.Count
0

thanks
caldi

 

Coordinator
Mar 25, 2012 at 9:41 PM

Hm, maybe the preview resolution of the lumia is different. To confirm this, I've added a simple debugging message to the app and committed this. Could you please get the latest version again (change set 37dcadc54380 ) and tell me what the preview resolution is? It should be under 'processed data' in the app.

Also I just want to confirm, you are using haarcascade_frontalface_alt.xml correct? Finally, if you could please send attach a link (or email me) of the image that you see when running the app and trying to find the face-recognition.jpg face that would be very helpful as well.

Thank you for helping me fix this!

Mar 25, 2012 at 10:22 PM
Edited Mar 25, 2012 at 10:23 PM

thanks for your very quick response :)

I've just tested the new version.
Preview resolution is 640 x 480

I am using the "haarcascade_fontalface_alt.xml". I haven't changed anything in the project.
Here you can find a picture of the lumia800 trying to detect the face-recognition.jpg face.

On the old version (before your help) i've tried other models.
With the default and alt2 model it detects always a face in the upper left corner. even if the camera picture is black.

hope this is helpfull :)
caldi

Coordinator
Mar 25, 2012 at 10:43 PM

Okay, glad preview resolution is the same. The face detection won't work on the image you showed for 2 reasons:

1. The face is too dark

2. The face is too small

Can you try a setup such as the one in this image?

Mar 25, 2012 at 11:16 PM

ok, i tried to improve the two things.
But it doesnt detect the face.
I dont get the picture much brighter. i tried changing the brightness of the monitor and of the picture.
The brightest solution is shown in the picture below.

please find here the picture of my last try.

is this caused by the model or by the algorithm?
The objects, which i want to detect, will be smaller, because the person should be also seen.

Coordinator
Mar 25, 2012 at 11:26 PM

Hm that one would work I'm pretty sure. If that's the black and white image that you're using to detect faces than that should *definitely* work, I thought the problem would be with the camera or the image that the face detector is using as input (not the algorithm since those are the same). Just to make sure we're using the *exact* same code, can you deploy the following .xap file to your phone?

http://dl.dropbox.com/u/5187107/Sample.xap

This is the sample application that I have deployed on my phone. To do this you need the app deployment tool: http://msdn.microsoft.com/en-us/library/ff769512(v=vs.92).aspx

That is just caused by the parameters passed to the algorithm in the sample code. You can detect smaller images by allowing a smaller minimum size. I make the minimum size fairly large to improve performance but you could for instance search a small range of images within the small image size.

 

Mar 26, 2012 at 12:06 PM

sorry for the late reply.

i've deployed the xap file. But the result is the same.
no faces were detected.

caldi

Coordinator
Mar 26, 2012 at 4:52 PM

Okay, I'm trying to determine whether the problem is in the camera or algorithm.

So in the next xap file for you to download and check please (still at http://dl.dropbox.com/u/5187107/Sample.xap) I have basically made it so that the the image that the sample app uses to find a face is the grayscale image, and it never changes. This is the EXACT same image that I have used for my phone and I have verified that this works.

If the face detection is working then you should see a red square in the middle of the screen when you run the xap. If that doesn't work then I'm totally baffled because I don't see how the basic face detection wouldn't work on a different phone, the code is being executed should be the same and so you should get the same result. 

I've also committed the latest code so that you can debug it as well, however please use the xap above just for consistency.

Mar 26, 2012 at 5:22 PM

hmm it still detects no faces.
the picture shows the test with the xap file.

ive also tested it in debug mode.
the faces list is still empty.

very strange ...

Coordinator
Mar 26, 2012 at 6:13 PM

Okay that is really weird, this was the case I was hoping would work.

Can you verify that the face detection code is actually being executed? When I get home I'll set up a bunch of more debugging printlns to verify the steps of the algorithm and see what's different. Or, perhaps you could do this and commit to the repo and I'll output my results for comparison? 

Coordinator
Mar 26, 2012 at 10:56 PM

Okay caldicot, I've put up debugging information. Please update the code, and then I have two things for you to try/verify:

1) Please try running the code in the emulator. On my side, the face detection works with the emulator. The emulator is the exact same software so it should work for you. Please take a screenshot and copy/paste the debug output (from output window) if it doesnt (please email me with this as it will clog up the discussion, or post link to log).

2) Please try this out on your phone and copy/paste the debugging output as well so that I can compare against my output.

Don't run the app for too long at the output outputs every frame.

Coordinator
Mar 27, 2012 at 3:53 AM

Caldicot are you in the states? If not the error could have been due to an xml parse error. I have changed all parsing to doubles to ensure that 0.0 is parsed correctly (i.e. phone doesn't expect 0,0). Try the latest update and let me know if it worked.

Mar 27, 2012 at 6:28 AM

sorry didn't saw your post yesterday.
I'll try this when i come home today.

no I'm not in the states, i'm from germany.
the parsing problem would make perfectly sense.

I'm going to try this on afternoon and post the result here.

thanks

Mar 27, 2012 at 3:43 PM

i've just tried out the new version.

first on the phone, and nothing changed to the previous version. 
then on the emulator and it works. See picture.

after that I've tried it on the phone again, and it also seems to work. the output is the same as on the emulator.
perhaps the projected wasnt deployed properly on the phone ...

i'm trying to change the source, that the camera picture is used instead of the debugging picture.

thanks
caldi

Coordinator
Mar 27, 2012 at 5:29 PM

Did you update the code in between when you deployed on the phone, then on the emulator, then the phone again? I think the internationalization bug is the most likely cause of the error so if you updated in between the three deploys that would make sense.

When I get home I will fix up the library and re-release, assuming it still works for you. Would you also be interested in helping me debug any issues that arise with using other object files? I have a lingering issue in the library which I think might be a problem for you if you want to use this for augmented reality because I don't think right now the toolkit works for any xml files except frontalface_alt. 

If you do try another OpenCV model file and it works, please do let me know which file you tried, I'm interested.

Mar 27, 2012 at 7:22 PM

i didn't update the code between the deployments.
thats a bit weird, but obiously it's working. the red rectangle is shown on the same position as the emulator does.

I'm always interessted in learning programming on winphone, so it would be nice if i can help you with debugging other object files.

i would use your library for a project in software engineering lecture.
perhaps i must change to android, because the remaining team members are more familiar with java and android.
of course i prefere .net on winphone :)

we want to detect a belt and project cool stuff.. :)