Ask Your Question

nicorsi's profile - activity

2015-05-05 05:24:52 -0600 asked a question OpenCV Face-detection doesn't work--unable to start activity ComponentInfo-- Galaxy S3 Android 4.3

Hello Community,

I try to start the face-detection sample from the OpenCV sdk v 2.4.10 . There is no error in the source code anymore and I import successfull the OpenCV library and android ndk.

So when i start the app it stops immediately and i get the following locat output (I have no idea how to solve it...) image description

my android.mk sourde code is the following image description

I can't say why it crashes because i changed nothing in the source code. I hope someone can help me.

2015-04-30 08:47:03 -0600 answered a question face-detection sample not work

I have the same problem...can somebody helps here??

2015-04-23 09:47:28 -0600 asked a question OpenCV Library - 2.4.10] Could not find OpenCV Library - 2.4.10.apk!

Hello Community,

i have a problem with the OpenCV face detection. You can the mainActivity at the bottom. Nowhere appears an error so i am quite sure that i importet the OpenCV library 2.4.10 correctly. But when I want to try the app this error appears in the console: "Could not find OpenCV Library - 2.4.10.apk!".

I search in the internet and try different things like using OpenCV library 2.4.9 or delete the whole project and develop it again, but nothing works. It is also added as library in the Project properties.

I hope that someone can help me.

Source Code:

import java.io.File; import java.io.FileOutputStream; import java.io.InputStream;

import org.opencv.android.BaseLoaderCallback; import org.opencv.android.CameraBridgeViewBase; import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener; import org.opencv.android.JavaCameraView; import org.opencv.android.LoaderCallbackInterface; import org.opencv.android.OpenCVLoader; import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.MatOfRect; import org.opencv.core.Rect; import org.opencv.core.Scalar; import org.opencv.core.Size; import org.opencv.imgproc.Imgproc; import org.opencv.objdetect.CascadeClassifier;

import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.WindowManager;

public class MainActivity extends Activity implements CvCameraViewListener { private CameraBridgeViewBase openCvCameraView; private CascadeClassifier cascadeClassifier;; private Mat grayscaleImage; private int absoluteFaceSize;

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    openCvCameraView = new JavaCameraView(this, -1);
    setContentView(openCvCameraView);
    openCvCameraView.setCvCameraViewListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings)
    {
        return true;
    }
    return super.onOptionsItemSelected(item);
}
public void onResume()
{
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this,baseLoaderCallback);
}

private BaseLoaderCallback baseLoaderCallback = new BaseLoaderCallback(this)
{
    @Override
    public void onManagerConnected(int status)
    {
        switch (status)
        {
        case LoaderCallbackInterface.SUCCESS:
            initializeOpenCVDependencies();
            break;
        default:
            super.onManagerConnected(status);
            break;
        }
    }
};

private void initializeOpenCVDependencies()
{
    try
    {
        // Copy the resource int a temp file so OpenCV can load it
        InputStream is = getResources().openRawResource(
                R.raw.lbpcascade_frontalface);
        File cascadeDir = getDir("cascade", Context.MODE_PRIVATE);
        File cascadeFile = new File(cascadeDir,
                "lbpcascade_frontalface.xml");
        FileOutputStream os = new FileOutputStream(cascadeFile);

        byte[] buffer = new byte[4096];
        int bytesread;
        while ((bytesread = is.read(buffer)) != -1)
        {
            os.write(buffer, 0, bytesread);
        }
        is.close();
        os.close();
        // Load the cascade classifier
        cascadeClassifier = new CascadeClassifier(
                cascadeFile.getAbsolutePath());

    } catch (Exception e)
    {
        Log.e("MainActivity", "Error loading Cascade", e);
    }

    openCvCameraView.enableView();
}

@Override
public void onCameraViewStarted(int width, int height)
{
    // The face will be 20 % of the height of the screen
    absoluteFaceSize = (int) (height * 0.2);
}

@Override
public void onCameraViewStopped()
{

}

@Override
public Mat onCameraFrame(Mat inputFrame)
{
    // Create a grayscale Image
    Imgproc.cvtColor(inputFrame, grayscaleImage, Imgproc.COLOR_RGBA2RGB ...
(more)