Ask Your Question

Revision history [back]

I' ve faced this problem either. I' ve tried to decrease the camera resolution with mOpenCvCameraView.setMaxFrameSize(1280, 720);

However it is still slow. I' ve been trying to work parallel with Threads, but it is still 3.5FPS.

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    //System.gc();
    carrierMat = inputFrame.gray();
    Thread thread = new Thread(new MultThread(carrierMat, this));
    thread.start();
    try {
        thread.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    return carrierMat;
}

My MultThread class is just like this

public class MultThread implements Runnable {
private Mat source;
private Context context;

public MultThread(Mat source, Context context) {
    this.source = source;
    this.context = context;
}

@Override
public void run() {
    //output = General.Threshold(source);
    int x = General.MSERP(source);
    Log.i("MtMTxtDtc:Main","x: " + x);
    if (x > 10){
        ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(500);

    }

}
}