Ask Your Question

Joseph118's profile - activity

2016-04-03 18:23:09 -0600 received badge  Notable Question (source)
2015-03-29 22:34:33 -0600 received badge  Popular Question (source)
2014-03-04 03:15:34 -0600 received badge  Editor (source)
2014-03-04 03:13:46 -0600 asked a question face recognition prediction returns the same value

I have this code that i am running, where it loops into a folder and get all png files and seperate them via labels. The code runs fine however it always return the same label.

        IplImage greyTestImage = IplImage.create(testImage.width(), testImage.height(), IPL_DEPTH_8U, 1);

        FaceRecognizer faceRecognizer = createFisherFaceRecognizer();
        faceRecognizer.train(images, labels);

        cvCvtColor(testImage, greyTestImage, CV_BGR2GRAY);

        int[] plabel = new int[1];
        double[] pconfidence = new double[1];

        faceRecognizer.predict(greyTestImage, plabel, pconfidence);
        int predictedLabel = plabel[0];
        double confidence = pconfidence[0];
        System.out.println("Predicted label: " + predictedLabel + " & confidence: " + confidence);

I have 3 images in the folder with 3 different labels... 1 , 2 , & 3. when i test the application it always return label 1. and the confidence when showing;

  • label 1 = ~500
  • label 2 = ~2000
  • label 3 = ~3000

i assume that all of the labels are compared only to label 1.. what can i do to be able to force the application to check with label 2 and 3 as well?

2014-03-01 08:34:50 -0600 commented question JavaCV - Try to create a class for face recognition that is going to be used on desktop computer

do you know any tutorials that uses openCV for face recognition on java?

2014-03-01 08:27:42 -0600 commented question JavaCV - Try to create a class for face recognition that is going to be used on desktop computer

thank you

2014-03-01 07:35:08 -0600 asked a question 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

2014-01-31 22:32:07 -0600 asked a question paintComponent - Image not being Converted (Java)

I have The following Code which i got from tutorials, and this is the way I interpret it; An image get converted from mat to buffered image then drawn on the JPanel. However the Image is staying always null. What am I doing wrong? or is there a misunderstanding from my side?

public class Cam extends JPanel{

private static final long serialVersionUID = 6940315436377323914L;

private BufferedImage image;
GridLayout camLayout = new GridLayout(1, 1);

public Cam(){
    super();
    setLayout(camLayout);
}

protected void paintComponent (Graphics g) {
    if (image == null) {
        System.out.println("Image is Empty");
        return;
    }
    super.paintComponent(g);
    System.out.println(this.image.getWidth() + this.image.getHeight() + "test");
    g.drawImage(this.image, 10, 10, this.image.getWidth(), this.image.getHeight(), null);
}

public boolean matToBufferedImage(Mat m){
    MatOfByte mb = new MatOfByte();
    Highgui.imencode(".jpg", m, mb);

    byte[] byteArray = mb.toArray();

    try {
        InputStream in = new ByteArrayInputStream(byteArray);
        image = ImageIO.read(in);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}

}

2014-01-30 09:18:38 -0600 commented question Exception Error while trying to run the code

damn it i had my webcam turned of no wonder it didn't work! Thanks dude i would of spent hours of research for nothing if it wasn't you :p

2014-01-30 09:16:32 -0600 commented question Exception Error while trying to run the code

oh i got it now... and i didn't mention it but i am trying to display my webcam on my GUI as my first goal, so later on i can try implement something else

2014-01-30 09:05:19 -0600 commented question Exception Error while trying to run the code

this is a method and when it is called it displays this exception. i send a mat as a perimeter; "Mat webcam_image = new Mat()"

2014-01-30 08:34:41 -0600 asked a question Exception Error while trying to run the code

I am new to OpenCV and i got no experience in graphics and algorithms. Anyway on to the question. I have this method which is currently giving me problems that I cannot solve. I have little experience of what is going on.

public BufferedImage toBufferedImage(Mat m){
    int type = BufferedImage.TYPE_BYTE_GRAY;
    if ( m.channels() > 1 ) {
        type = BufferedImage.TYPE_3BYTE_BGR;
    }
    int bufferSize = m.channels()*m.cols()*m.rows();
    byte [] b = new byte[bufferSize];
    m.get(0,0,b); // get all the pixels
    ***BufferedImage image = new BufferedImage(m.cols(),m.rows(), type);***
    final byte[] targetPixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
    System.arraycopy(b, 0, targetPixels, 0, b.length); 
    return image;
}

This method returns an exception on "BufferedImage image = new BufferedImage(m.cols(),m.rows(), type);" which is;

Exception in thread "main" java.lang.IllegalArgumentException: Width (0) and height (0) must be > 0 at java.awt.image.SampleModel.<init>(Unknown Source) at java.awt.image.ComponentSampleModel.<init>(Unknown Source) at java.awt.image.PixelInterleavedSampleModel.<init>(Unknown Source) at java.awt.image.Raster.createInterleavedRaster(Unknown Source) at java.awt.image.Raster.createInterleavedRaster(Unknown Source) at java.awt.image.Raster.createInterleavedRaster(Unknown Source) at java.awt.image.ComponentColorModel.createCompatibleWritableRaster(Unknown Source) at java.awt.image.BufferedImage.<init>(Unknown Source) at Interface.CameraPanel.toBufferedImage(CameraPanel.java:73) at Interface.CameraPanel.setCamera(CameraPanel.java:52) at Interface.UserUI.components(UserUI.java:31) at Project.main(Project.java:12)

can anyone tell me what is wrong? and what has to be done?

2014-01-30 04:39:57 -0600 commented answer Error :no opencv_java246 in java.library.path

Thank you!

2014-01-30 04:39:34 -0600 received badge  Supporter (source)