Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to load ClassifierCascade in Android using JavaCV?
    primarykey
    data
    text
    <p>I'm trying to use facial recognition with Android . All the loads are ok , but the <strong>haarcascade_frontalface_alt2.xml</strong> file wich i don't know how to load it using JavaCV. This is the code i have:</p> <pre><code>public static void detectFacialFeatures() { // The cascade definition to be used for detection. // This will redirect the OpenCV errors to the Java console to give you // feedback about any problems that may occur. new JavaCvErrorCallback(); // Load the original image. // 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. IplImage grayImage = IplImage.create(iplImage.width(),iplImage.height(), IPL_DEPTH_8U, 1); // We convert the original image to grayscale. cvCvtColor(iplImage, grayImage, CV_BGR2GRAY); CvMemStorage storage = CvMemStorage.create(); // We instantiate a classifier cascade to be used for detection, using the cascade definition. CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad("./haarcascade_frontalface_alt2.xml")); // We detect the faces. CvSeq faces = cvHaarDetectObjects(grayImage, cascade, storage, 1.1, 1, 0); Log.d("CARAS","Hay "+faces.total()+" caras ahora mismo"); } </code></pre> <p>The problem is here</p> <blockquote> <p>CvHaarClassifierCascade(cvLoad("./haarcascade_frontalface_alt2.xml"));</p> </blockquote> <p>I have tried putting the xml file it into the /assets folder , but i have no idea of how must i load it. It's always giving me the next error:</p> <pre><code>03-26 17:31:25.385: E/cv::error()(14787): OpenCV Error: Null pointer (Invalid classifier cascade) in CvSeq* cvHaarDetectObjectsForROC(const CvArr*, CvHaarClassifierCascade*, CvMemStorage*, std::vector&lt;int&gt;&amp;, std::vector&lt;double&gt;&amp;, double, int, int, CvSize, CvSize, bool), file /home/saudet/projects/cppjars/OpenCV-2.4.4/modules/objdetect/src/haar.cpp, line 1514 </code></pre> <p>... looking more near at the error it points to this code line:</p> <blockquote> <p>CvSeq faces = cvHaarDetectObjects(grayImage, cascade, storage, 1.1, 1, 0);</p> </blockquote> <p>That's why i'm pretty sure that the problem comes from the haarcascade_frontalface_alt2.xml load.</p> <p>Thanks for your help.</p> <p><strong>P.D: I want to include the cascade into the apk not in sdcard .</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload