Ask Your Question
1

how to trigger two classifiers in Android javaCV example

asked 2013-10-09 14:13:38 -0600

bunta gravatar image

updated 2013-10-10 01:16:57 -0600

Moster gravatar image

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-10-14 01:50:43 -0600

bunta gravatar image

updated 2013-10-14 01:57:35 -0600

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 :-)
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-10-09 14:13:38 -0600

Seen: 435 times

Last updated: Oct 14 '13