Ask Your Question

Fisher's profile - activity

2018-10-20 11:57:56 -0500 received badge  Notable Question (source)
2017-11-04 13:49:43 -0500 received badge  Notable Question (source)
2017-04-19 00:21:36 -0500 received badge  Popular Question (source)
2016-10-25 02:15:06 -0500 received badge  Popular Question (source)
2016-02-24 05:53:39 -0500 received badge  Popular Question (source)
2014-06-15 19:39:50 -0500 asked a question How to take picture with CameraBridgeViewBase or change it resolution

Hello

I am using OpenCV4Android 2.4.9. My app is using camera via CameraBridgeViewBase object. For now I am taking picture by converting single camera frame Mat object to Bitmap and saving it on SD card. Output image is very small - 800x480. I have Nexus 4 which is capable of 1280x720 resolution. If I take picture with phone camera, resolution is even higher.

1) How can I set parameters to CameraBridgeViewBase object, so the preview size is higher resolution? 2) Is there any other right way of taking photos, maybe my method is wrong?

2014-03-04 18:45:59 -0500 asked a question Face Features Detection - corner of eyes, eyebrows

Hello

I am creating basic emotion detection system for mobile phone with usage of OpenCV4Android. My system is already capable of finding mouth and doing some preprocessing. I have nice results of getting face objects from Canny:

Examplary Face1: https://dl.dropboxusercontent.com/u/108321090/FACE%20%282%29.png

Examplary Face2: https://dl.dropboxusercontent.com/u/108321090/FACE%20%281%29.png

  • Red rectangles are areas found by cascades. I have those saved as Mat objects.

  • Blue dots are points I need to find. Problem is, that I have both eyebrows and eyes on the same segment.

Additionaly there are situations in which eyebrows are directly connected to eyes (in some emotion states). It's hard to access some points. I have also normal images (of course) and tresholded ones which are also interesting for eyebrow shapes - but I lose some other objects (mouth - well that one doesn't matter cuz its already done, eyes) due to bad light, well eyebrows are always well visible. Of course I could change tresholding a bit, cuz I dont need it in finding other features. Like I said mouths is done well. Eyes/Eyebrows left.

Examplary Face3: https://dl.dropboxusercontent.com/u/108321090/Screenshot_2014-01-17-01-33-14.png

Examplary Face4: https://dl.dropboxusercontent.com/u/108321090/Screenshot_2014-01-17-01-26-33.png

Examplary Face5 (a bit problematic, eyes gone, but if I treshold them localy not globaly its fine) https://dl.dropboxusercontent.com/u/108321090/Screenshot_2014-03-05-01-30-48.png

Exampalary Face6 (eyebrows conencted to eyes) https://dl.dropboxusercontent.com/u/108321090/Screenshot_2014-03-05-01-28-21.png

I want to ask you if you could provide me with any materials/ideas connected to detection of eye, and eyebrows action units.

2014-03-02 18:02:54 -0500 asked a question Adding ROI to Mat created by split operation

Hello

I have problem with handling problem:

Mat cannyImageBGR = cleanFaceMatBGR.clone();
List<Mat> lBgr = new ArrayList<Mat>(3);
Core.split(cannyImageBGR, lBgr);
Mat matCannyRedChannel = lBgr.get(2);
Imgproc.Canny(matCannyRedChannel, matCannyRedChannel, 55, 105);

There is a BGR matrix cleanFaceMatBGR. I clone it to Matrix cannyImageBGR. I want to take red channel of this matrix and perform Canny filter on it to find edges of mouth. So I'm using split operation to get red channel separated from others. Basing on this I create matCannyRedChannel Mat. I Canny filter on matCannyRedChannel and it works well for me. I am satisfied with effect.

Where is the problem? Well, I performed Canny filtering on whole face. I am interested now in area around mouth, so I want to put ROI on new created matrix and im doing it like this:

Mat imgProcMatCannyMouth= new Mat(matCannyRedChannel, mouthArray[0]);

When I dump imgProcMatCannyMouth matrix its empty. All 0. Where is the mistake? How to fix it?


For example:

Mat imgProcMatCannyMouth= new Mat(cleanFaceMatBGR, mouthArray[0]);

this works fine

2013-12-31 08:47:47 -0500 commented answer Illumination Normalization not giving expected results

I did one normalization after Mat I = tan_triggs_preprocessing(cleanFaceMatGRAY); did you try it in C++ and It gave better results?

2013-12-31 08:30:40 -0500 commented answer Illumination Normalization not giving expected results

thank you for help then, it seems to get the result i want is still long way to go

2013-12-31 08:26:34 -0500 commented answer Illumination Normalization not giving expected results

So you say that the result is correct but I need to experiment with the float alpha = 0.1f; float tau = 10.0f; float gamma = 0.2f; int sigma0 = 1; int sigma1 = 2; values? Did I get this right?

2013-12-31 08:18:03 -0500 commented answer Illumination Normalization not giving expected results

I tried this: I.put(r, c, (Math.tanh(I.get(r,c)[0]) / tau)); instead of I.get(r,c)[0] = Math.tanh(I.get(r,c)[0]) / tau; but the result is much worse https://dl.dropboxusercontent.com/u/108321090/Screenshot_2013-12-31-15-17-36.png

2013-12-31 07:46:28 -0500 received badge  Student (source)
2013-12-31 07:25:27 -0500 asked a question Illumination Normalization not giving expected results

Hello

I am using OpenCV4Android to process my images. I wanted to preform Illumination Normalization which was linked to me with this work:

http://lear.inrialpes.fr/pubs/2007/TT07/Tan-amfg07a.pdf

furthermore I was given COMPLETE IMPLEMENTATION in C++ (OpenCV):

https://github.com/bytefish/opencv/blob/master/misc/tan_triggs.cpp

I tried to rewrite this code do Java, but I think there might be mistake somewhere. So, what I get from this alghorithm is close but not good enough. Check the expected results on the PDF above on page for example 12. And this is what i get:

https://dl.dropboxusercontent.com/u/108321090/a1.png https://dl.dropboxusercontent.com/u/108321090/Screenshot_2013-12-31-14-09-25.png

So there is still too much noise between background and face features, but I think it's my fault here. This is my code:

//GET IMAGE URI
Uri selectedImage = imageReturnedIntent.getData();

//CREATE BITMAP FROM IT
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;      

Bitmap bmp = BitmapFactory.decodeStream(getContentResolver().openInputStream(selectedImage), 
                        null, bmpFactoryOptions);

//CREATE OPENCV MAT OBJECT
Mat imageMat = new Mat();
Utils.bitmapToMat(bmp, imageMat);

//CONVERT TO GRAYSCALE
Mat grayMat = new Mat();
Imgproc.cvtColor(imageMat, grayMat, Imgproc.COLOR_BGR2GRAY);

//CUT OUT FACE FROM WHOLE IMAGE
(...) face detection cascades localize face and writes the region where face is located 
in array, then I create mat with only face in it:

 Mat cleanFaceMatGRAY = new Mat();
cleanFaceMatGRAY = new Mat(faceDetectMatGRAY, facesArray[0]);

//PROCESSING OF MAT WITH FACE (alghorithm from PDF & .cpp file)
Mat I = tan_triggs_preprocessing(cleanFaceMatGRAY);
Core.normalize(I, I,0, 255, Core.NORM_MINMAX, CvType.CV_8UC1);

//DISPLAY MAT IN IMAGEVIEW
ivPickedPhoto.setImageBitmap(AppTools.createBitmapFromMat(I, Bitmap.Config.ARGB_8888));

And method with algorithm (as u can see its total copy-paste from .cpp file with edited/rewrited methods to OpenCV4Android):

private Mat tan_triggs_preprocessing(Mat image) {
    float alpha = 0.1f; 
    float tau = 10.0f;
    float gamma = 0.2f; 
    int sigma0 = 1;
    int sigma1 = 2;

    // Convert to floating point:
    Mat X = image;
    X.convertTo(X, CvType.CV_32FC1);
    // Start preprocessing:
    Mat I = new Mat();
    Core.pow(X, gamma, I);
    // Calculate the DOG Image:
    {
        Mat gaussian0 = new Mat();
        Mat gaussian1 = new Mat();
        // Kernel Size:
        int kernel_sz0 = (3*sigma0);
        int kernel_sz1 = (3*sigma1);
        // Make them odd for OpenCV:
        kernel_sz0 += ((kernel_sz0 % 2) == 0) ? 1 : 0;
        kernel_sz1 += ((kernel_sz1 % 2) == 0) ? 1 : 0;
        Size ksize1 = new Size(kernel_sz0,kernel_sz0);
        Size ksize2 = new Size(kernel_sz1,kernel_sz1);
        Imgproc.GaussianBlur(I, gaussian0, ksize1, sigma0, sigma0, Imgproc.BORDER_CONSTANT);
        Imgproc.GaussianBlur(I, gaussian1, ksize2, sigma1, sigma1, Imgproc.BORDER_CONSTANT);
        Core.subtract(gaussian0, gaussian1, I);
    }

    {
        double meanI = 0.0;
        {
            Mat tmp = new Mat();
            Mat abstmp = new Mat();
            Core.absdiff(I, new Scalar(0), abstmp);
            Core.pow(abstmp, alpha, tmp);
            meanI = Core.mean(tmp).val[0];
        }
        Core.divide( Math.pow(meanI, 1.0/alpha), I, I);
    }

    {
        double meanI = 0.0;
        {
            Mat tmp = new Mat(); 
            Mat abstmp = new Mat();
            Mat mintmp = new Mat();
            Core.absdiff(I, new Scalar(0), abstmp);
            Core.min(abstmp, new Scalar(tau), mintmp);
            Core.pow(mintmp, alpha, tmp);
            meanI = Core.mean(tmp).val[0];
        }
        Core.divide( Math.pow(meanI, 1.0/alpha ...
(more)
2013-12-30 18:09:20 -0500 received badge  Editor (source)
2013-12-30 18:05:16 -0500 asked a question OpenCV4Android mathematical operations on Mat objects

Hello. I am new to OpenCV4Android. I want to rewrite code from C++ to OpenCV4Android:

{
double meanI = 0.0;
{
    Mat tmp;
    pow(abs(I), alpha, tmp);
    meanI = mean(tmp).val[0];

}
I = I / pow(meanI, 1.0/alpha);

}

{
double meanI = 0.0;
{
    Mat tmp;
    pow(min(abs(I), tau), alpha, tmp);
    meanI = mean(tmp).val[0];
}
I = I / pow(meanI, 1.0/alpha);

}

So I have a problem, because I dont know how to make:
1. abs of mat object -> abs(I)
2. how to divide matrix by DOUBLE -> I = I / pow(meanI, 1.0/alpha)


Can anyone help me with that?


Ad.1 I have no clue how to do it by function
Ad.2 I tried sth like that: Core.divide( Math.pow(meanI, 1.0/alpha), I, I) is that correct?

2013-12-30 18:00:21 -0500 received badge  Scholar (source)
2013-12-30 18:00:20 -0500 received badge  Supporter (source)
2013-12-19 16:21:13 -0500 asked a question Face threshold in various light

Hello

I want to create system that identifies human emotions based on face images. I have my eyes, eyebrows, nose, mouth found. I have problem with face binarization. I want my system to be as much universal as possible. Face images are taken with mobile phone camera, because of that there is a different light on each image. What I know for sure is that, I need to get rid or weaken effect of shadows that appear on faces due to bad light.

What have I done:

I tried to implement Niblack Thresholding algorithm but to be honest it's not working well with faces. I came up with my own idea for now because any algorithm I tried fails me. The best results I get with this:

Core.normalize(cleanFaceMatGRAY, cleanFaceMatGRAY,0, 255, Core.NORM_MINMAX, CvType.CV_8U);
niblackThresholding(cleanFaceMatGRAY, -0.2);    

private void niblackThresholding(Mat image, double parameter) {
    Mat meanPowered = image.clone();
    Core.multiply(image, image, meanPowered);

    double mean = Core.mean(image).val[0];
    double stdmean = Core.mean(meanPowered).val[0];     
    double tresholdValue = mean + parameter * stdmean;

//      MatOfDouble mean = new MatOfDouble();
//      MatOfDouble std = new MatOfDouble();
//      Core.meanStdDev(image, mean, std);
//      double tresholdValue = mean.toArray()[0] + parameter * std.toArray()[0];

    int totalRows = image.rows();
    int totalCols = image.cols();

    for (int cols=0; cols < totalCols; cols++) {
        for (int rows=0; rows < totalRows; rows++) {
            if (image.get(rows, cols)[0] > tresholdValue) {
                image.put(rows, cols, 255);
            } else {
                image.put(rows, cols, 0);
            }
        }
    }
}

The results are really good, but still not enough for some images. I paste links cuz images are big and I don't want to take too much screen:

For example this one is tresholded really fine:
https://dl.dropboxusercontent.com/u/108321090/a1.png
https://dl.dropboxusercontent.com/u/108321090/a.png

But bad light produce shadows sometimes and this gives this effect:
https://dl.dropboxusercontent.com/u/108321090/b1.png
https://dl.dropboxusercontent.com/u/108321090/b.png

So... I tried to manipulate manually my threshold value for B picture but it won't ever give good result.

Please help me with this problem. I appreciate any comment, suggestion, reference material. I tried a lot of things and I lack ideas.