Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

JavaCV - Try to create a class for face recognition that is going to be used on desktop computer

Is it possible for face recognition class to recognize a face with only 1 image in the database? I am only using frontal faces and I would like to use fisherfaces algorithm.

Anyway i am trying to implement a method based on the samples i found on the internet, it is not complete yet and not tested.

The method will use a frame from the video capture which returns Mat, the Mat frame is converted into bufferedImage and I am sending this bufferedImage as a parameter to this method that i am intending to use for face recognition. How ever when i am using

IplImage getVCFrame = createFrom(frame)

it says that createFrom(BufferedImage) is undefined. I want this to convert the buffered Image to IplImage.

Here is my rest of the code till now, (be aware that it is not complete, i just want to figure out why eclipse is giving me undefined error)

package Function;

import com.googlecode.javacv.cpp.opencv_core;

import static com.googlecode.javacv.cpp.opencv_highgui.*;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_contrib.*;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FilenameFilter;

import org.opencv.core.Mat;

public class FaceRecognition {

    public void checkFace(String imagePath, BufferedImage frame) {
        // Video Camera Frame       
        IplImage getVCFrame = new IplImage();
        getVCFrame = createFrom(frame);

        // Frame from Storage
        IplImage img;
        IplImage grayImg;
        int numberOfImages = 1;
        int label;

        MatVector images = new MatVector(numberOfImages);
        int[] labels = new int[numberOfImages];

        img = cvLoadImage(imagePath);
        label = 1;
        grayImg = IplImage.create(img.width(), img.height(), IPL_DEPTH_8U, 1);
        cvCvtColor(img, grayImg, CV_BGR2GRAY);

        images.put(0, img);
        labels[0] = label;

        IplImage GrayVCFrame = IplImage.create(getVCFrame.width(), getVCFrame.height(), IPL_DEPTH_8U, 1);


        FaceRecognizer fr = createFisherFaceRecognizer();
        //FaceRecognizer faceRecognizer = createEigenFaceRecognizer();
        // FaceRecognizer faceRecognizer = createLBPHFaceRecognizer();

        fr.train(images, labels);
        cvCvtColor(getVCFrame, GrayVCFrame, CV_BGR2GRAY);
    }
}

At first I was using OpenCV for face detection but when It came to face recognition i couldn't find any help and tutorials, so I imported JavaCV to try and use it for face recognition

JavaCV - Try to create a class for face recognition that is going to be used on desktop computer

Is it possible for face recognition class to recognize a face with only 1 image in the database? I am only using frontal faces and I would like to use fisherfaces algorithm.

Anyway i am trying to implement a method based on the samples i found on the internet, it is not complete yet and not tested.

The method will use a frame from the video capture which returns Mat, the Mat frame is converted into bufferedImage and I am sending this bufferedImage as a parameter to this method that i am intending to use for face recognition. How ever when i am using

IplImage getVCFrame = createFrom(frame)

it says that createFrom(BufferedImage) is undefined. I want this to convert the buffered Image to IplImage.

Here is my rest of the code till now, (be aware that it is not complete, i just want to figure out why eclipse is giving me undefined error)

package Function;

import com.googlecode.javacv.cpp.opencv_core;

import static com.googlecode.javacv.cpp.opencv_highgui.*;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_contrib.*;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FilenameFilter;

import org.opencv.core.Mat;

public class FaceRecognition {

    public void checkFace(String imagePath, BufferedImage frame) {
        // Video Camera Frame       
        IplImage getVCFrame = new IplImage();
        getVCFrame = createFrom(frame);

        // Frame from Storage
        IplImage img;
        IplImage grayImg;
        int numberOfImages = 1;
        int label;

        MatVector images = new MatVector(numberOfImages);
        int[] labels = new int[numberOfImages];

        img = cvLoadImage(imagePath);
        label = 1;
        grayImg = IplImage.create(img.width(), img.height(), IPL_DEPTH_8U, 1);
        cvCvtColor(img, grayImg, CV_BGR2GRAY);

        images.put(0, img);
        labels[0] = label;

        IplImage GrayVCFrame = IplImage.create(getVCFrame.width(), getVCFrame.height(), IPL_DEPTH_8U, 1);


        FaceRecognizer fr = createFisherFaceRecognizer();
        //FaceRecognizer faceRecognizer = createEigenFaceRecognizer();
        // FaceRecognizer faceRecognizer = createLBPHFaceRecognizer();

        fr.train(images, labels);
        cvCvtColor(getVCFrame, GrayVCFrame, CV_BGR2GRAY);
    }
}

At first I was using OpenCV for face detection but when It came to face recognition i couldn't find any help and tutorials, so I imported JavaCV to try and use it for face recognition