Ask Your Question
0

How to calculate surface roughness in disparity map?

asked 2019-08-06 08:35:38 -0600

prostoi chelovek gravatar image

Hello! I am developing small project connected with security. I created simple face detection/recognition and stereo matching. So i have disparity map of the face region.
image description image description
The first disparity map belongs to real face, the second is photo of the face showed from the phone.
I want to determine where is real and where not. i think that for this propose can be used something like "surface roughness", but i cant figure out how to calculate it.
Please tell me the method can be used for calculate "surface roughness", or better way to do the same.
Thanks!

edit retag flag offensive close merge delete

Comments

If you are using a stereo camera (I suppose so), you need to let the cameras be really close one to each other to see such differences. Try with a printed photo to compare against it first of all, to see if you can cheat the system. I think that the first result that you can see is that using real face you get different results: The nose is darker, the eyes are blacked. But Stereo matching even if can be used for that, is not intended for that kind of use. In fact, if you use a human puppy and if you exploit only the depth you can probably have the same result. So... is the focus of your project recognize faces only using disparity map?

HYPEREGO gravatar imageHYPEREGO ( 2019-08-06 10:26:08 -0600 )edit

@HYPEREGO. thank you for quick reply. I have implemented stereo vision using two cameras and SGBM. I am also implemented face detection and recognition using DNNs. Now, i want to add some extra feature. As i can see, the disparity map of real face is more rough than fake, and i want to try implement some protection using this. But i do not know siautable algoritm for this task. Maybe i misstake and this method cannot give enogh accuracy, but i am experementing.

prostoi chelovek gravatar imageprostoi chelovek ( 2019-08-06 11:04:54 -0600 )edit
2

You could try making a normalized histogram of depths over the whole image, or if you can somehow identify a face region or subface region (concentric circle regions?), histograms over those areas, normalize them, and look for some sort of interesting shape or metrics about the histogram curves. I'd think that the depths of a flat image of a face will have flat (linear) characteristics due to the correlations on a flat image, but the actual face will have bumps, You could also try using the depth maps to create contours based on lines across the image (slices down or across) and see how close (in a fuzzy logic way), they come to meeting the slice profiles of real faces. Beware glasses, beards, printed face masks, mannikins, pets, etc.

opalmirror gravatar imageopalmirror ( 2019-08-06 20:46:00 -0600 )edit
1

@opalmirror, thank you for useful tip! i could calculate the histograms and histogram of real and fake faces. And they are differ considerably. Histogram of real face as you said had bumps, and fake had nearly one high line. You can see the histograms here real and fake. But now i do not know the algorithm for estimate this difference programmatically. Can you show me any suitable method, or where i can find information about it, please.

prostoi chelovek gravatar imageprostoi chelovek ( 2019-08-07 03:28:55 -0600 )edit
1

Prostoi, I am sorry, this is an application area (not an opencv operational question). It's also not an area where I have not researched or have experience. I am unable to provide any detailed additional guidance. If it were me, I might try next: normalization of the global depth bias, face skew (face pitch, yaw. roll), scale (to standard size), maybe median filter, then comparison of depth data against known good and bad reference faces. Since you're more interested in classifying (is it a face? true/false) rather than grading (probability it might be a face or segmentation within the face area), this naturally leads to a Support-vector machine or CNN. Best of luck!

opalmirror gravatar imageopalmirror ( 2019-08-07 13:31:56 -0600 )edit
1

@opalmirror, thank you! I tried to find any opencvs or mathematical algorithm, but totally forget about SVM. I already have experience with it - i used SVMs for face recognition and i think that i easily can implement fake-detector using SVM. I will post answer with my result.

prostoi chelovek gravatar imageprostoi chelovek ( 2019-08-08 01:46:06 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2019-08-09 04:23:19 -0600

prostoi chelovek gravatar image

updated 2019-08-09 04:23:36 -0600

So. i solved my problem. Firstly i calculated histogram of face disparity map. Then i collected a small dataset with real and fake face histograms. After that i created SVM and trained it with dataset. And it works perfectly! But my first attempt was to use OpenCV`s implementation of SVM and it works poor. So i used dlib`s SVM and it works good with same parameters and dataset.
All the code for it is in my github repository. And this is opencv version that not works, maybe you can tell me why.
Thank you all for your help!

edit flag offensive delete link more

Comments

Thanks for posting your answer. So, the SVM decides "this histogram looks like the histogram from other faces, and not like the histogram from other non-faces". That's pretty cool. Glad I was able to help.

If you like, you could open a new question comparing the working (dlib) and non-working (opencv) SVM code, with input and output data showing the problem. I know of SVMs but have never implemented one, so maybe that could interest other answers for you.

opalmirror gravatar imageopalmirror ( 2019-08-09 14:47:04 -0600 )edit

Oh, if you are satisfied with your own answer, you can mark it correct too, more karma points. :)

opalmirror gravatar imageopalmirror ( 2019-08-09 15:00:09 -0600 )edit
1

@opalmirror, thank you for supporting and feedback! I solved my problem with SVM when i maked sample code for question and this sample code works cool! That maybe means problem in me, not in OpenCV. But maybe not. So, if you want to view the code - here is that sample and here is not working code. And i cannot mark my answer correct because it require 20 reputation but i do not have enough. Thanks to all for supporting!

prostoi chelovek gravatar imageprostoi chelovek ( 2019-08-10 07:23:13 -0600 )edit
1

I will go ahead and mark it correct for you then. Thanks for contributing a good question, discussion, and answering it on the forum. :)

opalmirror gravatar imageopalmirror ( 2019-08-12 13:21:56 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-08-06 08:35:38 -0600

Seen: 884 times

Last updated: Aug 09 '19