English 中文(简体)
开放CV/JavaCV 甲型肝炎检测
原标题:OpenCV/JavaCV Android Face Detection Initialization

I am working on a Face Detection Problem, I have working code that uses Androids FaceDetector to find the faces but I need to figure out a way to implement OpenCV/JavaCV functions to detect faces. This is not using a live camera, it uses a image from the gallery, I am able to retrieve that images path, but I cant seem to get the CvHaarClassifierCascade classifier, and CvMemStorage storage to initialized, if anyone cant point me in the right direction or provide some source code that initializes these variable correctly in Java. Thanks

问题回答

你可以这样做: 仅此就可提供一种变幻影。

或者将原IplImage直接装上使用VvLoadImage的图像途径。

// provide an BufferedImage
BufferedImage image;

// Preload the opencv_objdetect module to work around a known bug.
Loader.load(opencv_objdetect.class);

// Path to the cascade file provided by opencv
String cascade = "../haarcascade_frontalface_alt2.xml"

CvHaarClassifierCascade cvCascade = new CvHaarClassifierCascade(cvLoad(cascade));

// create storage for face detection
CvMemStorage tempStorage = CvMemStorage.create();

// create IplImage from BufferedImage
IplImage original = IplImage.createFrom(image);

IplImage grayImage = null;

if (original.nChannels() >= 3) {
  // We need a grayscale image in order to do the recognition, so we
  // create a new image of the same size as the original one.
  grayImage = IplImage.create(image.getWidth(), image.getHeight(),
                IPL_DEPTH_8U, 1);
  // We convert the original image to grayscale.
  cvCvtColor(original, grayImage, CV_BGR2GRAY);
} else {
  grayImage = original.clone();
}

// We detect the faces with some default params
CvSeq faces = cvHaarDetectObjects(grayImage, cvCascade,
            tempStorage, 1.1, 3,
            0;

// Get face rectangles
CvRect[] fArray = new CvRect[faces.total()];
for (int i = 0; i < faces.total(); i++) {
            fArray[i] = new CvRect(cvGetSeqElem(faces, i));
        }
// print them out
for(CvRect f: fArray){
   System.out.println("x: " + f.x() + "y: " + f.y() + "width: " + f.width() +  "height: " + f.height());
}

tempStorage.release();

班级定义主要是C类原主档案的关口,加上只有开放CVC++的C++APIC暴露的缺失功能。 http://code.google.com/p/javacv/“rel=“nofollow”http://code.google.com/p/javacv/。

http://geekover Treatment.wordpress.com/tag/opencv-javacv-android-haarcascade-face-detection/“rel="nofollow”http://geekover Treatment.wordpress.com/tag/opencv-javacv-android-haarcascade-face-detection/





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签