Ask Your Question

fontain's profile - activity

2014-06-14 19:09:42 -0600 asked a question Question about using VideoCapture API on specifc

I used VideoCapture API on android to grab frame. I think that this API is working well on JellyBean device(android version 4.1.2) But there is crash problem kitkat device(android version 4.4.2 GalaxyS4) I don't know exactly cause of problems Can you check my log when having crash?


06-12 19:03:26.103: W/ApplicationPackageManager(24037): getCSCPackageItemText()
06-12 19:03:26.184: I/Adreno-EGL(24037): <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build:  (CL3869936)
06-12 19:03:26.184: I/Adreno-EGL(24037): OpenGL ES Shader Compiler Version: 17.01.11.SPL
06-12 19:03:26.184: I/Adreno-EGL(24037): Build Date: 01/17/14 Fri
06-12 19:03:26.184: I/Adreno-EGL(24037): Local Branch: 
06-12 19:03:26.184: I/Adreno-EGL(24037): Remote Branch: 
06-12 19:03:26.184: I/Adreno-EGL(24037): Local Patches: 
06-12 19:03:26.184: I/Adreno-EGL(24037): Reconstruct Branch: 
06-12 19:03:26.294: D/OpenGLRenderer(24037): Enabling debug mode 0
06-12 19:03:26.314: W/ContextImpl(24037): Implicit intents with startService are not safe: Intent { act=org.opencv.engine.BIND } android.content.ContextWrapper.bindService:529 org.opencv.android.AsyncServiceHelper.initOpenCV:24 org.opencv.android.OpenCVLoader.initAsync:64 
06-12 19:03:26.444: D/OpenCVManager/Helper(24037): Service connection created
06-12 19:03:26.444: D/OpenCVManager/Helper(24037): Trying to get library path
06-12 19:03:26.554: D/OpenCVManager/Helper(24037): Trying to get library list
06-12 19:03:26.614: D/OpenCVManager/Helper(24037): Library list: ""
06-12 19:03:26.614: D/OpenCVManager/Helper(24037): First attempt to load libs
06-12 19:03:26.614: D/OpenCVManager/Helper(24037): Trying to init OpenCV libs
06-12 19:03:26.614: D/OpenCVManager/Helper(24037): Trying to load library /data/app-lib/org.opencv.engine-2/libopencv_java.so
06-12 19:03:26.614: D/dalvikvm(24037): Trying to load lib /data/app-lib/org.opencv.engine-2/libopencv_java.so 0x42a28018
06-12 19:03:26.924: D/dalvikvm(24037): Added shared lib /data/app-lib/org.opencv.engine-2/libopencv_java.so 0x42a28018
06-12 19:03:26.924: D/OpenCVManager/Helper(24037): OpenCV libs init was ok!
06-12 19:03:26.924: D/OpenCVManager/Helper(24037): First attempt to load libs is OK
06-12 19:03:26.924: I/OpenCVManager/Helper(24037): General configuration for OpenCV 2.4.9 =====================================
06-12 19:03:26.924: I/OpenCVManager/Helper(24037):   Version control:               2.4.9
06-12 19:03:26.924: I/OpenCVManager/Helper(24037):   Platform:
06-12 19:03:26.924: I/OpenCVManager/Helper(24037):     Host:                        Linux 3.2.0-56-generic x86_64
06-12 19:03:26.924: I/OpenCVManager/Helper(24037):     Target:                      Linux 1 armv7-a
06-12 19:03:26.924: I/OpenCVManager/Helper(24037):     CMake:                       2.8.12.1
06-12 19:03:26.924: I/OpenCVManager/Helper(24037):     CMake generator:             Ninja
06-12 19:03:26.924: I/OpenCVManager/Helper(24037):     CMake build tool:            /usr/local/bin/ninja
06-12 19:03:26.924: I/OpenCVManager/Helper(24037):     Configuration:               Release
06-12 19:03:26.924: I/OpenCVManager/Helper(24037):   C/C ...
(more)
2014-06-10 23:34:45 -0600 asked a question Motion detect using opencv on android

Hi I'm trying to implementing motion detect using opencv on android. I applied sample motion detection code and made jni call. I ran this on android, it works but processed preview is super slow. I removed motion detection process part then preview worked normally. How can I improve the the performance? I added my source code for motion detect and jni. please check and advice me.

import java.util.ArrayList; import java.util.List;

import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.hardware.Camera;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;


public class CameraViewActivity extends Activity implements
CvCameraViewListener2 {

    private CameraBridgeViewBase m_OpenCvCameraView;
    private Mat m_inputMat;
    private Mat m_dstMat;
    private Mat m_motionAvgMat;
    private Mat m_grayMat;
    private Mat m_diffMat;
    private Mat m_scaleMat;
    private static Mat m_contourKernel;
    private static Mat m_hierarchy;
    private Point m_rectPoint1;
    private Point m_rectPoint2;
    private static Point m_contourPoint;
    private Scalar m_rectColor;
    private Size m_kSize;
    private Size m_frameSize;
    private double m_totalPixels;
    private double m_motionPercent;

    private boolean isRecording = false;
    private boolean isMotionDetect = false;

    private Camera m_Camera;
    private MediaRecorder m_MediaRecorder;
    private Runnable m_Runnable;
    private Handler m_TimerHandler;
    private TextView m_tvTimer;
    private int value = 0;
    private CountDownTimer timer;

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
            case LoaderCallbackInterface.SUCCESS:
            {
                Log.i(TAG, "OpenCV loaded successfully");
                System.loadLibrary("motion_detect");
                m_OpenCvCameraView.enableView();
            } break;
            default:
            {
                super.onManagerConnected(status);
            } break;
            }
        }
    };

    public CameraViewActivity() {
        Log.i(TAG, "Instantiated new " + this.getClass());
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        Log.i(TAG, "called onCreate");
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        setContentView(R.layout.local_camera_view);
        m_OpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.local_camera_surface_view);
        m_OpenCvCameraView.setCvCameraViewListener(this);
        m_tvTimer = (TextView)findViewById(R.id.tv_timer);
    }


    @Override
    public void onPause()
    {
        super.onPause();
        if (m_OpenCvCameraView != null)
            m_OpenCvCameraView.disableView();
    }

    @Override
    public void onResume()
    {
        super.onResume();
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_8, this, mLoaderCallback);
    }

    public void onDestroy() {
        super.onDestroy();
        if (m_OpenCvCameraView != null)
            m_OpenCvCameraView.disableView();
        m_inputMat.release();
        m_dstMat.release();
        m_motionAvgMat.release();
        m_grayMat.release();
        m_diffMat.release();
        m_scaleMat.release();
        m_contourKernel.release();
        m_hierarchy.release();
    }

    public void onCameraViewStarted(int width, int height) {
        m_inputMat = new Mat();
        m_dstMat = new Mat();
        m_motionAvgMat = null;
        m_grayMat = new Mat();
        m_diffMat = new Mat();
        m_scaleMat = new Mat();
        m_rectPoint1 = new Point();
        m_rectPoint2 = new Point();
        m_rectColor = new Scalar(0, 255, 0);
        m_kSize = new Size(8, 8);
        m_motionPercent = 0.0;
        m_contourKernel = Imgproc.getStructuringElement(Imgproc.MORPH_DILATE, new Size(3, 3), new Point(1, 1));
        m_hierarchy = new Mat();
        m_contourPoint = new Point(-1, -1);
    }

    public void onCameraViewStopped() {
        m_inputMat.release();
        m_dstMat ...
(more)
2014-04-28 22:36:59 -0600 received badge  Student (source)
2014-02-26 03:43:04 -0600 commented answer Is videowriter API not functional in android?

Thank you for reply, I have more question, "currently you can't write or read video files on android using opencv" which means that I can't write or read video during processing the motion detection using opencv? If I use android native api for video record, can I implement recording + simultaneous motion detection using opencv on android?

2014-02-26 01:58:16 -0600 asked a question Is videowriter API not functional in android?

Hi there,

I'm tying to to detect motion using opencv(2.4.8) camera preview on android and record video camera view. Is videowriter API not functional latest opencv on android now? If not now, is there any plan to support that API later?

Thanks

2014-02-24 16:59:36 -0600 asked a question Opencv on android and video record

I'm trying to process camera image on opencv(2.4.8) and record video together on android.

In the middle of just camera preview, video record is done successfully, however, after starting

image process on opencv, there is EXCEPTION like below. It is not functional videowriter API in opnecv on android, so I used MediaRecorder that is android API to record video.

Is there any way I can solve the problems were occurred by when trying to process image and video record at the same time?

Thanks!

02-24 16:38:50.071: E/AndroidRuntime(8117): FATAL EXCEPTION: main 02-24 16:38:50.071: E/AndroidRuntime(8117): java.lang.RuntimeException: Method called after release() 02-24 16:38:50.071: E/AndroidRuntime(8117): at android.hardware.Camera.setHasPreviewCallback(Native Method) 02-24 16:38:50.071: E/AndroidRuntime(8117): at android.hardware.Camera.access$600(Camera.java:133) 02-24 16:38:50.071: E/AndroidRuntime(8117): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:815) 02-24 16:38:50.071: E/AndroidRuntime(8117): at android.os.Handler.dispatchMessage(Handler.java:99) 02-24 16:38:50.071: E/AndroidRuntime(8117): at android.os.Looper.loop(Looper.java:137) 02-24 16:38:50.071: E/AndroidRuntime(8117): at android.app.ActivityThread.main(ActivityThread.java:4961) 02-24 16:38:50.071: E/AndroidRuntime(8117): at java.lang.reflect.Method.invokeNative(Native Method) 02-24 16:38:50.071: E/AndroidRuntime(8117): at java.lang.reflect.Method.invoke(Method.java:511) 02-24 16:38:50.071: E/AndroidRuntime(8117): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004) 02-24 16:38:50.071: E/AndroidRuntime(8117): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771) 02-24 16:38:50.071: E/AndroidRuntime(8117): at dalvik.system.NativeStart.main(Native Method)

2014-02-20 23:33:46 -0600 received badge  Editor (source)
2014-02-20 23:32:55 -0600 asked a question How to record video in android?

Hi there,

I'm doing camera function using opencv in android.

I'd like to record video right after object detect.

Is there any opencv api that I can apply for video record?

I already read the question and answer about this, there is videowriter api is not functional in android now.

Then, should I release for the opecnv camera and open the android native camera for the video record?

Thanks, in advance.

2014-02-13 14:21:07 -0600 asked a question 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!