Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Bio-inspired features returns NaNs

Hello,

I am using bif function (bif.cpp) from the extra module 'face' of Opencv-3.0.1. When I run the function for a test image, the returned feature vector includes many NaN values. Could you please help me understand why this is happening?

#include "cv.hpp"
#include "opencv.hpp"
#include "highgui.h"
#include "bif.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv) {

    cv::Mat fea;
    cv::Ptr<cv::face::BIF> bif = cv::face::createBIF();
    cv::Mat image(60, 60, CV_32F);
    cv::theRNG().fill(image, cv::RNG::UNIFORM, -1, 1);
    bif->compute(image, fea);
    cout << "fea = " << endl << " " << fea << endl << endl;

    waitKey(0);

    return 0;
}

Thank you in advance.

click to hide/show revision 2
No.2 Revision

updated 2016-10-05 23:00:06 -0600

berak gravatar image

Bio-inspired features returns NaNs

Hello,

I am using bif function (bif.cpp) from the extra module 'face' of Opencv-3.0.1. When I run the function for a test image, the returned feature vector includes many NaN values. Could you please help me understand why this is happening?

#include "cv.hpp"
"opencv2/opencv.hpp"
#include "opencv.hpp"
#include "highgui.h"
#include "bif.hpp"
"opencv2/face/bif.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv) {

    cv::Mat fea;
    cv::Ptr<cv::face::BIF> bif = cv::face::createBIF();
    cv::Mat image(60, 60, CV_32F);
    cv::theRNG().fill(image, cv::RNG::UNIFORM, -1, 1);
    bif->compute(image, fea);
    cout << "fea = " << endl << " " << fea << endl << endl;

    waitKey(0);

    return 0;
}

Thank you in advance.

Bio-inspired features returns NaNs

Hello,

I am using bif function (bif.cpp) from the extra module 'face' of Opencv-3.0.1. When I run the function for a test image, the returned feature vector includes many NaN values. Could you please help me understand why this is happening?

#include "opencv2/opencv.hpp"
#include "opencv2/face/bif.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv) {

    cv::Mat fea;
    cv::Ptr<cv::face::BIF> bif = cv::face::createBIF();
    cv::Mat image(60, 60, CV_32F);
    cv::theRNG().fill(image, cv::RNG::UNIFORM, -1, 0, 1);
    bif->compute(image, fea);
    cout << "fea = " << endl << " " << fea << endl << endl;

    return 0;
}

Thank you in advance.

Bio-inspired features returns NaNs

Hello,

I am using bif function (bif.cpp) from the extra module 'face' of Opencv-3.0.1. When I run the function for a test image, the returned feature vector includes many NaN values. Could you please help me understand why this is happening?

#include "opencv2/opencv.hpp"
#include "opencv2/face/bif.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv) {

    cv::Mat fea;
    cv::Ptr<cv::face::BIF> bif = cv::face::createBIF();
    cv::Mat image(60, 60, CV_32F);
    cv::theRNG().fill(image, cv::RNG::UNIFORM, 0, 1);
    bif->compute(image, fea);
    cout << "fea = " << endl << " " << fea << endl << endl;

    return 0;
}

Thank you in advance.

EDIT: Sorry for my delayed edit, but please let me ask something more. I have done the changes you suggested and for most of the images the NaN value disappeared. However, there still some other images where the problem insists, I am giving an example bellow. Could you please give some help on this?

image description

Bio-inspired features returns NaNs

Hello,

I am using bif function (bif.cpp) from the extra module 'face' of Opencv-3.0.1. When I run the function for a test image, the returned feature vector includes many NaN values. Could you please help me understand why this is happening?

#include "opencv2/opencv.hpp"
#include "opencv2/face/bif.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv) {

    cv::Mat fea;
    cv::Ptr<cv::face::BIF> bif = cv::face::createBIF();
    cv::Mat image(60, 60, CV_32F);
    cv::theRNG().fill(image, cv::RNG::UNIFORM, 0, 1);
    bif->compute(image, fea);
    cout << "fea = " << endl << " " << fea << endl << endl;

    return 0;
}

Thank you in advance.

EDIT: Sorry for my delayed edit, but please let me ask something more. I have done the changes you suggested and for most of the images the NaN value disappeared. However, there still the problem is not fixed for some other images where the problem insists, images, I am giving an example bellow. below. Could you please give some help on this?

image description

Bio-inspired features returns NaNs

Hello,

I am using bif function (bif.cpp) from the extra module 'face' of Opencv-3.0.1. When I run the function for a test image, the returned feature vector includes many NaN values. Could you please help me understand why this is happening?

#include "opencv2/opencv.hpp"
#include "opencv2/face/bif.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv) {

    cv::Mat fea;
    cv::Ptr<cv::face::BIF> bif = cv::face::createBIF();
    cv::Mat image(60, 60, CV_32F);
    cv::theRNG().fill(image, cv::RNG::UNIFORM, 0, 1);
    bif->compute(image, fea);
    cout << "fea = " << endl << " " << fea << endl << endl;

    return 0;
}

Thank you in advance.

EDIT: Sorry for my delayed edit, but please let me ask something more. I have done the changes you suggested and for most of the images the NaN value disappeared. However, the problem is not fixed for some images, I am giving an example below. Could you please give some extra help on this?

image description

Bio-inspired features returns NaNs

Hello,

I am using bif function (bif.cpp) from the extra module 'face' of Opencv-3.0.1. When I run the function for a test image, the returned feature vector includes many NaN values. Could you please help me understand why this is happening?

#include "opencv2/opencv.hpp"
#include "opencv2/face/bif.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv) {

    cv::Mat fea;
    cv::Ptr<cv::face::BIF> bif = cv::face::createBIF();
    cv::Mat image(60, 60, CV_32F);
    cv::theRNG().fill(image, cv::RNG::UNIFORM, 0, 1);
    bif->compute(image, fea);
    cout << "fea = " << endl << " " << fea << endl << endl;

    return 0;
}

Thank you in advance.

EDIT: Sorry for my delayed edit, but please let me ask something more. I have done made the changes you suggested and for most of the images the NaN value disappeared. However, the problem for some images is not fixed for some images, fixed. I am giving an example below. Could you please give provide some extra help on this?

image description

Bio-inspired features returns NaNs

Hello,

I am using bif function (bif.cpp) from the extra module 'face' of Opencv-3.0.1. When I run the function for a test image, the returned feature vector includes many NaN NaN values. Could you please help me understand why this is happening?

#include "opencv2/opencv.hpp"
#include "opencv2/face/bif.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv) {

    cv::Mat fea;
    cv::Ptr<cv::face::BIF> bif = cv::face::createBIF();
    cv::Mat image(60, 60, CV_32F);
    cv::theRNG().fill(image, cv::RNG::UNIFORM, 0, 1);
    bif->compute(image, fea);
    cout << "fea = " << endl << " " << fea << endl << endl;

    return 0;
}

Thank you in advance.

EDIT: Sorry for my delayed edit, but please let me ask something more. I have made the changes you suggested and for most of the images the NaN value disappeared. However, the problem for some images is not fixed. I am giving an example below. Could you please provide some extra help on this?

image description

EDIT Possible answer: The code of bif.cpp seems to implement correctly the algorithm presented in the corresponding paper, so the problem of negative values in sqrt is not algorithmic. By debugging the code, I noticed that the negative values were very small, having order of magnitude 10^-17 and 10^-19 for the specific example image and values of order 10^-17 to 10^-21 for other images. According to this post, these very small negative numbers are smaller than the numeric limit for double values and can be casted to 0. Therefore, I suggest that the line 210 can be:

 sd = sqrt((sd / area - mean  mean) < 0 & abs((sd / area - mean  mean)) < std::numeric_limits<double>::epsilon() ? 0 : (sd / area - mean * mean));

If (sd / area - mean mean) is positive, nothing changes. If (sd / area - mean mean) is negative and smaller than the numeric limit for doubles, it is set to 0. By changing line of code 210 as above, no NaN values emerge.