Pre processing with tan trigs functions

asked 2016-09-15 04:00:42 -0600

atv gravatar image

So i added the tan trigs function to preprocess the image (probe set only, not training set).

I pass my image to it:

      // Convert to grayscale
    cvtColor(contrast, gray, CV_BGR2GRAY); // first arg used to be brightness on 6/09/2016
    // Equalize
    equalizeHist(gray,equalize);
    Mat preprocessed = tan_triggs_preprocessing(equalize);
    // Find the faces in the frame:
    vector< Rect_<int> > faces;
    haar_cascade.detectMultiScale(preprocessed, faces,1.2,4,0|CASCADE_SCALE_IMAGE, Size(min_face_size,min_face_size),Size(max_face_size,max_face_size));

But when i run it it crashes with:

OpenCV Error: Assertion failed (scaleFactor > 1 && _image.depth() == CV_8U) in detectMultiScale, file /Users/alefveld/Downloads/opencv/modules/objdetect/src/cascadedetect.cpp, line 1323
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/alefveld/Downloads/opencv/modules/objdetect/src/cascadedetect.cpp:1323: error: (-215) scaleFactor > 1 && _image.depth() == CV_8U in function detectMultiScale

Abort trap: 6

So i added this to the end the tan trigs function so it returns 8UC1 image instead:

 I.convertTo(I, CV_8UC1);
 return I;

But now it doesn't detect any image at all. Is it the scale that is wrong instead? Or should i not have converted it back. But detectmultiscale expects a CV_8UC image..

Many thanks for help.

edit retag flag offensive close merge delete

Comments

"But now it doesn't detect any image at all." -- this is quite expected.

if you want to use tan_triggs normalization, put it after the detection ( and before the recognition, if there is any )

berak gravatar imageberak ( 2016-09-15 04:11:40 -0600 )edit

Ah. That seems to work much better indeed. Thanks! Some questions if you wouldn't mind: a) While it now seems to work, for whatever reason it seems to recognise the image as the first person in the csv file. Very stable eigenvalues though (but probably because of this behaviour)

I don't think i need to do this preprocessing on the training set (as the paper i think mentions only doing it on the probe set)

atv gravatar imageatv ( 2016-09-15 05:00:03 -0600 )edit

a: "Very stable eigenvalues though" -- that means, that you get the eigenvalues of your filter, not of the content. (have a look at the images produced there !)

b: if you apply different preprocessing to train and test set, you're comparing apples to pears.

berak gravatar imageberak ( 2016-09-15 05:44:43 -0600 )edit

as for a) i forgot to do norm_0_255(image) so the image was almost entirely black for the human eye. Surprising how powerful it is as once i pass it through trig it recovers the image pretty good. Still it's a bit weird as to how it seems it gets stuck on the first item in the csv because i didn't normalise. Why would i do such a thing?

b) Common sense i guess, but i didn't realise how important it was to use the same preprocessing steps in both train and test set. Thanks again!

atv gravatar imageatv ( 2016-09-15 07:08:12 -0600 )edit

I found face_cascade cant detect face after image is processed by tan_triggs. Could you share right procedure with me ? I have tried with norm255 function

wellcomez gravatar imagewellcomez ( 2017-09-13 21:44:32 -0600 )edit
1

i found after image is processed by tan it is hard to be detected. I have try with CLache and equalizeHist which can help me detect face which bad light condition.After I read paper, i think tan is suit .for face recognize not detection

wellcomez gravatar imagewellcomez ( 2017-09-13 23:11:59 -0600 )edit

@wellcomez -- yes, that is the case.

berak gravatar imageberak ( 2017-09-14 08:32:46 -0600 )edit