Question about performance(android opencv java api) [closed]

asked 2014-02-13 14:21:07 -0600

fontain gravatar image

updated 2014-02-13 14:25:31 -0600

berak gravatar image

Hi there,

I'm trying to implement motion processing using opencv java api.

I used and applied opencv camera preview android sample application. The motion processing is working now, but processed preview is super slow, Is there any way I can improve preview speed? The motion processing part is just like below.

@Override
    public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
        minputMat = inputFrame.rgba();
        // TODO Auto-generated method stub
        Imgproc.blur(m_inputMat, mdstMat, m_kSize);
        ...
        Imgproc.accumulateWeighted(mdstMat, mmotionAvgMat, .03);
        Core.convertScaleAbs(m_motionAvgMat, mscaleMat);
        Core.absdiff(mdstMat, m_scaleMat, m_diffMat);
        Imgproc.cvtColor(m_diffMat, mgrayMat, Imgproc.COLOR_BGR2GRAY);
        Imgproc.threshold(mgrayMat, mgrayMat, 25, 255, Imgproc.THRESH_BINARY);
        m_motionPercent = 100.0 * Core.countNonZero(mgrayMat) / m_totalPixels;
                ....

        return m_inputMat;
    }

Thank you!

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-11 03:07:29.245228

Comments

blur sounds like the most expensive one from your list there

berak gravatar imageberak ( 2014-02-13 14:29:07 -0600 )edit

It depends on what are you trying to accomplish with the motion processing, what are you trying to do? I think there might be simpler approaches. Or you can reduce the size of your image or kernel sizes.

Rui Marques gravatar imageRui Marques ( 2014-02-25 16:16:30 -0600 )edit