Ask Your Question

bunta's profile - activity

2018-06-12 15:08:07 -0600 received badge  Notable Question (source)
2018-06-12 15:08:07 -0600 received badge  Popular Question (source)
2016-10-13 05:24:05 -0600 received badge  Student (source)
2015-05-31 04:15:23 -0600 received badge  Notable Question (source)
2014-09-28 19:51:36 -0600 received badge  Popular Question (source)
2013-11-12 08:10:45 -0600 commented question Android Camera opens in landscape mode orientation for front camera in openCV\javaCV

@AFK You need to change the orientation to 270 or 90 once the surface is created, then it will start working

2013-11-05 07:37:07 -0600 asked a question Any Sad Face detection Classifier

Is there any Sad Facedetection classifier available to test few cases , like smile is available. Right now don't want to train the classifier so want any availlable options if available.

2013-10-27 14:14:47 -0600 asked a question getting unsatisfiedLinkerror while trying to re-use opencv-facedection sample

I am trying to use openCV in android. So I am following the link - http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html

My basic intenstion is to create my own Android project and copying all the OpenCV Sample - face-detection sample source code to the new project and test the same to verify the android project setup.

I created an android project XYZ and then added the openCV library, then copied the jni directory from OpenCV Sample - face-detection to XYZ project and then trigger http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/android_dev_intro.html#cdt-builder

which generate a armeabi-v7a directory inside lib folder. Then I copied all the sourcecode from sample to xyz and run and then I found the following error-

java.lang.UnsatisfiedLinkError: Native method not found:

com.example.emotiondetector.DetectionBasedTracker.nativeCreateObject:(Ljava/lang/String;I) at com.example.emotiondetector.DetectionBasedTracker.nativeCreateObject(Native Method)

at com.example.emotiondetector.DetectionBasedTracker.<init> com.example.emotiondetector.FdView.<init>(FdView.java:146)

Means jni didnt work properly. Can anyone suggest where did I miss the core thing ?

Following warning came while generating jni-

C:\android-ndk-r9-windows-x86_64\android-ndk-r9\ndk-build.cmd Android NDK: WARNING:jni/Android.mk:detection_based_tracker: non-system libraries in linker flags: -lopencv_java Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the Android NDK:
current module Install : libdetection_based_tracker.so => libs/armeabi-v7a/libdetection_based_tracker.so

AFter quick search I found its a popular problem-

"java.lang.UnsatisfiedLinkError: Native method not found: com.test.camera.DetectionBasedTracker.nativeCreateObject:(Ljava/lang/String;I)J", FdView.java ->

But couldnt get any solution ...

2013-10-22 10:42:35 -0600 asked a question Android OpenCV Sample - face-detection is crashing

I am trying t

I am trying to run OpenCV Sample - face-detection example because found lot of response saying to use this version of openCV not javaCV as it still uses old version. But the problem is this sample get crashes if I try to do the detection with front Camera within no time.

mCamera = new VideoCapture(Highgui.CV_CAP_ANDROID_FRONT);

I changes this to make front camera work but it restarts my mobile ie Nexus4 which hardware has a good benchmark. So if Nexus4 is failing means somewhere big resource issue Where can i sort it out as Android is not at all giving or throwing any error and by the time I reach to solve the same it get crashes.

2013-10-21 06:16:08 -0600 received badge  Scholar (source)
2013-10-18 05:17:34 -0600 commented question FaceDetection is not happening over the proper region in an ImageViewer

updated the screenshot , its better but not perfect, since it was not perfect thats why I moved to full screen mode, but i think I need to work in this only

2013-10-18 04:50:30 -0600 commented question FaceDetection is not happening over the proper region in an ImageViewer

@steven , which all APi's are old here , i will then change them .. considering Android and javaCV are the only choices left with me, then

2013-10-18 04:17:00 -0600 commented question FaceDetection is not happening over the proper region in an ImageViewer

actually i tried that and in that case Face rectangle goes more left and mouth rectangle doesn't even visible. Thats why I modified that part

2013-10-18 04:01:13 -0600 asked a question FaceDetection is not happening over the proper region in an ImageViewer

I am trying to do a FaceDetection over an Image displayed over Android ImageView. I have made the ImageView as fulls screen mode, then I loaded the Image from storage as-

IplImage image = cvLoadImage(strImageFilePath, // filename
                CV_LOAD_IMAGE_GRAYSCALE);

Then I ran the classifiers and then tried to draw the rectangle but its coming some other region-

canvas.drawRect(new Rect(x, y, x + w, y + h), paint);

Following is the code sample-

public void process(String strImageFilePath) {


        ClassifierLoader classifierLoader = ClassifierLoader.getInstance(getContext());
        classifier = classifierLoader.getClassifier_face();
        classifier_mouth = classifierLoader.getClassifier_mouth();
        IplImage image = cvLoadImage(strImageFilePath, // filename
                CV_LOAD_IMAGE_GRAYSCALE);
        cvClearMemStorage(storage);
        Log.i("imageimage ", ""+image.height()+" Width "+image.width());


        cvClearMemStorage(storage);
        faces = cvHaarDetectObjects(image, classifier, storage, 1.1, 4,
                CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_DO_ROUGH_SEARCH);
        mouth = cvHaarDetectObjects(image, classifier_mouth, storage, 1.1, 3,
                CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_DO_ROUGH_SEARCH);

        invalidate();

        Log.i("AYA ", "IMAGE AAYA " + image+" FAC "+faces.total()+" mouth "+mouth.total()+ " THIS "+this.getWidth() );

    }

    @SuppressLint("DrawAllocation")
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = new Paint();
        paint.setColor(Color.RED);
        paint.setTextSize(20);
        paint.setStrokeWidth(8);
        paint.setStyle(Paint.Style.STROKE);
        canvas.drawCircle(20, 40, 5, paint);
        if(faces != null){
        if (faces.total() > 0) {

            String s = "Processed Face";
            float textWidth = paint.measureText(s);
            canvas.drawText(s, (getWidth() - textWidth) / 2, 20, paint);
            CvRect r = new CvRect(cvGetSeqElem(faces, 0));
            int x = r.x(), y = r.y(), w = r.width(), h = r.height();
            Log.i("IMAGE VIEW DRAW ", "x "+x+" y "+y+" w "+w+" h "+h);
            canvas.drawRect(new Rect(x, y, x + w, y + h), paint);

            if(mouth.total() > 0){
                CvRect rct = new CvRect(cvGetSeqElem(mouth, 0));
                canvas.drawRect(new Rect(rct.x(),rct.y(),rct.x()+rct.width(),rct.y()+rct.height()), paint);
            }

        }
    }
    }

I believe I need to do something with the height of IplImage but since I am directly loading the same from storage , it might be the issue. I actually wanted to load the image from image viewer but I couldn;t get it :( http://answers.opencv.org/question/22636/how-to-load-an-iplimage-from-android-imageview/?comment=22662#comment-22662

This is how algorithm is currently drawing the rectangle-

image description

on Using drawing rectangle as-

 canvas.drawRect(new Rect(x, y, w, y ), paint);

the Mouth rectange is not at all visible.

image description

One observation I found is that the rectangle it draw is not for the face size, but it will match if I open the same window in portrait mode, so It may be something doing for portrait mode, and I need to somewhere invert the image. I am here directly just opening the Image in landscape mode

and If I don;t use full screen mode, then things are quite better like -

image description

But still not the perfect, using canvas.drawRect(new Rect(x, y, x + w, y + h), paint); Other case doesn;t even show the rectangle

2013-10-18 02:21:05 -0600 commented answer How to load an IPlImage from Android ImageView

@Moster, yes :( because I was unable to get the bytes from ImageView and then draw an IPlImage, what I did is anyway ImageView was full screen mode , so I just read it from system.

2013-10-17 14:44:06 -0600 commented answer How to load an IPlImage from Android ImageView

thanks @berak for notifying the point of converting pixel to IplImage..I'll look into it

2013-10-17 14:40:17 -0600 commented answer How to load an IPlImage from Android ImageView

ok I realized one thing that even IplImage.asCvMat is there to use

2013-10-17 14:37:55 -0600 commented answer How to load an IPlImage from Android ImageView

Moster.. sorry for that.. yes I admit thats a wrong point of asking ..@berak.. does it mean I can comfortably use IplImage in javaCv ..

2013-10-17 14:17:58 -0600 commented answer How to load an IPlImage from Android ImageView

any idea about equivalent of Utils.bitmapToMat(bmp32, imgMat); in javaCV

2013-10-17 14:13:20 -0600 commented answer How to load an IPlImage from Android ImageView

Mat image = Highgui.imread("/sdcard/TVguide/Detection/detected.jpg"); hows this ?

2013-10-17 10:23:43 -0600 asked a question How to load an IPlImage from Android ImageView

I have an image displayed in android ImageView. Now I want to convert that image to openCV IPlImage, how to do that. I am not reading the image file from file system because I want to draw on android imageView and width and height of the image displayed on imageView and original image in the storage will be different.

And the solution I used is-

IplImage image = cvLoadImage(strImageFilePath, // filename
                CV_LOAD_IMAGE_GRAYSCALE);
2013-10-14 23:56:25 -0600 asked a question Face Detection is detecting fine , but Mouth Detection is getting failed

I am trying to implemented Face and mouth detection in Android using JavaCV. Things are happening in Landscape mode within a region. FaceDetection is working fine but MouthDetection is failing. Actually Even after Face is detected, I need to process as scaling and all then it worked but the same calculation you can doesn't work with Mouth.

 protected void onDraw(Canvas canvas) {

            Paint paint = new Paint();
            paint.setColor(Color.RED);
            paint.setTextSize(20);


            String s = "Face Detected - This side up.";
            float textWidth = paint.measureText(s);
            canvas.drawText(s, (getWidth()-textWidth)/2, 20, paint);        
            if (faces != null) {
                paint.setStrokeWidth(4);
                paint.setStyle(Paint.Style.STROKE);
                float scaleX = (float)getWidth()/grayImage.width();
                float scaleY = (float)getHeight()/grayImage.height();
                int total = faces.total();
                for (int i = 0; i < total; i++) {               
                    CvRect r = new CvRect(cvGetSeqElem(faces, i));


                    int x = r.x(), y = r.y(), w = r.width(), h = r.height();
                    float xAxis = x*scaleX;
                    Rect rTest = new Rect((int)(2*xAxis-xAxis/6),(int)(y*scaleY), (int)((x+w)*scaleX+(x+w)), (int)((y+h)*scaleY));
                    canvas.drawRect(rTest, paint);
                   // canvas.drawRect(x, y,x+w,y+h,paint);

                    cvClearMemStorage(storage);    
                    //cvSetImageROI(grayImage,new CvRect(r.x(),r.y()+(r.height()*2/4), r.width(), r.height()/3));
                    //cvSetImageROI(grayImage, new CvRect(rTest.left, rTest.top, rTest.right, rTest.bottom));
                    detectMouth(new CvRect(rTest.left, rTest.top, rTest.right, rTest.bottom) ,canvas);

                }
            }


    private void detectMouth(CvRect r, Canvas canvas) {
            Paint paint = new Paint();
            paint.setColor(Color.BLACK);
            paint.setTextSize(40);
            paint.setStrokeWidth(4);
            paint.setStyle(Paint.Style.STROKE);

            int x = r.x(), y = r.y(), w = r.width(), h = r.height();


            String s = "Emotion Detected";
            float textWidth = paint.measureText(s);
            canvas.drawText(s, (getWidth()-textWidth)/2, 40, paint);   

            //cvResetImageROI(grayImage);
            int total = mouth.total();
             for (int i = 0; i < total; i++) {
                 CvRect rM = new CvRect(cvGetSeqElem(mouth, i));
                 cvClearMemStorage(storage);    
                    //L,T,R,B

// This needs change
                 canvas.drawRect(x+rM.x(), 4*rM.y()+y, Math.min(w-rM.width(), 9*rM.width()), Math.max(h-rM.height(),14), paint);
             }

             cvResetImageROI(grayImage);
        }

If I simply write-

canvas.drawRect(x,y,x+w,y+h)

Then mouth rectange works fine but it doesn't come inside Face rectangle , it displays in some part of the screen. Please suggest how should I write the proper rectangle algorithm for Mouth Detection

canvas.drawRect(x+rM.x(), 4*rM.y()+y, Math.min(w-rM.width(), 9*rM.width()), Math.max(h-rM.height(),14), paint);

Above is the part which needed a proper change.

2013-10-14 01:50:43 -0600 answered a question how to trigger two classifiers in Android javaCV example

It was bit easy , I was sincerely creating a mess..

  • Check for the main classifier, I mean first you need to find the face before finding eyes and mouth.
  • Find the face by running classfier, inside each face try to run other classifiers of eyes, nose , mouth
  • Once you find them draw :-)
2013-10-11 12:52:33 -0600 asked a question how to fetch data from detected points of mouth in javaCV

I've detected a mouth of an image in javaCV using harcascased of haarcascade_mcs_mouth.xml. Now I've mouth rectangle , now I want to store the data and compare the data with other person mouth data.

So how should I do that , checking specific mouth data with other person's mouth data

If I am not clear , will try to explain again .

2013-10-10 04:28:45 -0600 commented question how to extract Mouth data from image in javaCV

:-) sorry again for that , any source for training data . And is it actually easy to generate those big big xml files

2013-10-10 04:20:26 -0600 commented question how to extract Mouth data from image in javaCV

sorry its should be emotion , it should be mouth. Training the xml , this is what I want to know properly but as a very new user to this platform and moreover no C++ bakcground creating issue, Can any link there which will make my life bit easier to understand of training the classifier

2013-10-10 03:37:03 -0600 asked a question how to extract Mouth data from image in javaCV

I have an Image , and I want to extract data of Mouth in the face from the Image only in JavaCV. Then I want to compare the same from large database of images (different emotions) and then would like to find the best matched.

I have two questions here- have two questions here- 1. 2.

How to extract emotion data from image.. How to extract emotion data from image.

How to map this with DB images as DB images are some other images , and data extracted from

emotion will be different faces. SO wont the mapping hurt or what all the steps I need to care for achieve.. How to map this with DB images as DB images are some other images , and data extracted from emotion will be different faces. SO wont the mapping hurt or what all the steps I need to care for achieve.

2013-10-10 03:21:01 -0600 commented answer How to detect face by portrait mode?

if its android use javaCV, and rest of the code will work in android platform

2013-10-10 03:09:15 -0600 commented question Facial feature detection with OpenCV with eyes and mouth corners points

have you found the output, if yes can you please update here..

2013-10-10 00:18:04 -0600 commented question (OpenCV4Android) How to use OpenCV camera in Service?

check the sample , there is a way mentioned to use Native camera or the java Camera , any one of them?

2013-10-09 14:13:38 -0600 asked a question how to trigger two classifiers in Android javaCV example

In the basic Object detection javaCV example , i tried to use two classifiers, one for face and other one for eyes. But surely I am doing something wrong that always the single one is coming. I am doing this just for the sake of learning , I even checked other example of OpenCV , but couldn't find whats wrong i am doing.

protected void processImage(byte[] data, int width, int height) {
    // First, downsample our image and convert it into a grayscale IplImage
    int f = SUBSAMPLING_FACTOR;
    if (grayImage == null || grayImage.width() != width/f || grayImage.height() != height/f) {
        grayImage = IplImage.create(width/f, height/f, IPL_DEPTH_8U, 1);
    }
    int imageWidth  = grayImage.width();
    int imageHeight = grayImage.height();
    int dataStride = f*width;
    int imageStride = grayImage.widthStep();
    ByteBuffer imageBuffer = grayImage.getByteBuffer();
    for (int y = 0; y < imageHeight; y++) {
        int dataLine = y*dataStride;
        int imageLine = y*imageStride;
        for (int x = 0; x < imageWidth; x++) {
            imageBuffer.put(imageLine + x, data[dataLine + f*x]);
        }
    }

    cvClearMemStorage(storage);
    faces = cvHaarDetectObjects(grayImage, classifier, storage, 1.1, 3, CV_HAAR_DO_ROUGH_SEARCH | CV_HAAR_FIND_BIGGEST_OBJECT);
    faces = cvHaarDetectObjects(grayImage, classifier_eyes, storage, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING);
    postInvalidate();
}

Here I've tried to add both the classifiers to the same face Object. Initially it was just one. Here always the last one takes preference, can anybody suggest the actual way to add two classifiers in the following scenario

2013-10-09 13:25:44 -0600 commented answer why facedetection not happening in Portrait mode in Android , using javaCV cvHaarDetectObjects method

i tried following piece of code under onPreviewFrame overriden method but no luck-

IplImage my_image = (IplImage) grayImage; CvMat mat = my_image.asCvMat();

    int cols = mat.cols();
    int rows = mat.rows();
    IplImage DstImage = cvCreateImage(cvSize(rows, cols), IPL_DEPTH_8U, 1);


   int angle = ((180 / 90) % 4) * 90;

    //0 : flip vertical; 1 flip horizontal
    int flip_horizontal_or_vertical = angle &gt; 0 ? 1 : 0;
    int  number = Math.abs(angle / 90);
    for(int i = 0; i != number; ++i){
        cvTranspose(grayImage, DstImage);        
        cvFlip(grayImage,DstImage,flip_horizontal_or_vertical);
    }
2013-10-09 13:24:38 -0600 commented answer How to detect face by portrait mode?

I tried-

IplImage my_image = (IplImage) grayImage; CvMat mat = my_image.asCvMat();

    int cols = mat.cols();
    int rows = mat.rows();
    IplImage DstImage = cvCreateImage(cvSize(rows, cols), IPL_DEPTH_8U, 1);


   int angle = ((180 / 90) % 4) * 90;

    //0 : flip vertical; 1 flip horizontal
    int flip_horizontal_or_vertical = angle &gt; 0 ? 1 : 0;
    int  number = Math.abs(angle / 90);
    for(int i = 0; i != number; ++i){
        cvTranspose(grayImage, DstImage);        
        cvFlip(grayImage,DstImage,flip_horizontal_or_vertical);
    }

But couldnt get anything

2013-10-09 07:01:15 -0600 commented answer Is face recognition posible in android openCV?

What if i use javacv layer or face recognition example in android .. It working but getting some problem sometime

2013-10-09 06:42:27 -0600 commented answer FaceRecognizer.java in Opencv4Android 2.4.3

Same issue I found in android while using javacv. Any suggestion to get rid of it in java way

2013-10-09 05:08:03 -0600 received badge  Editor (source)
2013-10-09 05:08:03 -0600 edited question Android Error :Fatal signal 11 (SIGSEGV) at 0x760f1011 (code=1), thread 11933

The above is a common Bug in Android and I found in numerous places and most of the places recommended a solution of cleaning the memory.

Issue thrown at train method. faceRecognizer.train(images, labels);

https://groups.google.com/forum/#!topic/javacv/tniCCfSyg4c

https://code.google.com/p/javacv/issues/attachmentText?id=121&aid=1210011000&name=main.java&token=lCt0M3aJfIOKi8TDckxXmNe82_Q%3A1381308179983

I've tried all solution to solve the problem in Android but nothing worked, but same thing is fine in System\PC because of more memory and process I guess , if thats the reason The Code Sample-

import static com.googlecode.javacv.cpp.opencv_contrib.createEigenFaceRecognizer;
import static com.googlecode.javacv.cpp.opencv_core.IPL_DEPTH_8U;
import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import static com.googlecode.javacv.cpp.opencv_imgproc.CV_BGR2GRAY;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvCvtColor;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;

import android.os.Environment;
import android.util.Log;

import com.googlecode.javacv.cpp.opencv_contrib.FaceRecognizer;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacv.cpp.opencv_core.MatVector;

public class OpenCVFaceRecognizer {

    static List<File> pathList = new ArrayList<File>();
    //pictureFile.getAbsolutePath()
    public static int verifyFace(String strTestImage){

        IplImage testImage = cvLoadImage(strTestImage);
        Log.i("testImagetestImage ", testImage.toString());
        String path = Environment.getExternalStorageDirectory().toString()
                    + "/FaceR_DB/FaceDB";
        Log.i("PATH 2", path);
        File root = new File(path);
        if(pathList != null && pathList.size()>0){
        pathList.clear();
        }
        if(!root.exists() || !root.isDirectory()){
            return -1;
        }
        List<File> listFilesForFolder = listFilesForFolder(root);   

        FilenameFilter pngFilter = new FilenameFilter() {
              public boolean accept(File dir, String name) {
                return name.toLowerCase().endsWith(".png");
              }
            };

            Log.i("SIZEEEEEEee", ""+listFilesForFolder.size());
            if(listFilesForFolder.size()<1){
                return -1;
            }
            MatVector images = new MatVector(listFilesForFolder.size());

            int[] labels = new int[listFilesForFolder.size()];

            int counter = 0;
            int label;

            IplImage img;
            IplImage grayImg;

            for (File image : listFilesForFolder) {
              // Get image and label:
              img = cvLoadImage(image.getAbsolutePath());
              String[] split = image.getName().split( "\\." );
             // System.out.println("NAME "+);
              label = Integer.parseInt(image.getName().split("\\.")[0]);
              // Convert image to grayscale:
              grayImg = IplImage.create(img.width(), img.height(), IPL_DEPTH_8U, 1);
              cvCvtColor(img, grayImg, CV_BGR2GRAY);
              // Append it in the image list:
              images.put(counter, grayImg);
              // And in the labels list:
              labels[counter] = label;
              Log.i("labels ", ""+labels+" img "+img);
              //img.release();
              cvReleaseImage(img); // tried both separately or together, still doesn't work\
            //  img = null;
              System.gc();
              // Increase counter for next image:
              counter++;
              Log.i("RELEASE ", "Released "+counter);
            }

            FaceRecognizer faceRecognizer = createEigenFaceRecognizer();

            Log.i("After images", ""+images.size()+" labels "+labels.length+" faceRecognizer "+faceRecognizer);
            faceRecognizer.train(images, labels);
            Log.i("PROJECTIOn ", "-- "+faceRecognizer.getDouble( "threshold" ));
            faceRecognizer.set( "threshold", 10000 );
            //get the MAT : projectedTrainFaceMat LINE 700
            //CvMat mat = faceRecognizer.getMat( testImage.gto );
           // faceRecognizer.save("C:\\Users\\choudhar\\Bunta_DB\\fisherface_at.yml");
           // CvMat eigenvalues = faceRecognizer.getMat("eigenvalues");
            //CvMat W = faceRecognizer.getMat("eigenvectors");
            //CvMat mean = faceRecognizer.getMat("mean");

            // Load the test image:
            IplImage greyTestImage = IplImage.create(testImage.width(), testImage.height(), IPL_DEPTH_8U, 1);
            cvCvtColor(testImage, greyTestImage, CV_BGR2GRAY);



            // And get a prediction:
          //  faceRecognizer.predict( greyTestImage, labels, new double[] {0.5} );
            return ...
(more)
2013-10-09 05:01:07 -0600 commented question How to detect face by portrait mode?

did u find any solution for the problem ?