Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Question about performance(android opencv java api)

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!

click to hide/show revision 2
No.2 Revision

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

berak gravatar image

Question about performance(android opencv java api)

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!