Ask Your Question

Revision history [back]

Video Stop/Crash on Samsung Galaxy S4

Hi,When I start the camara using camaraIndex different of 1 (Front Camara) on my Samsung Galaxy S4 the video crash it.

The test that I did: mCameraView = new NativeCameraView(this, 0); //fail mCameraView = new NativeCameraView(this, 1); //successfull mCameraView = new NativeCameraView(this, -1); //fail

Also I tested it with and Camera index different of 1: OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3,this, mLoaderCallback); //fail OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_8,this, mLoaderCallback); //fail

I am using OpenCV Manager version: 2.16

Device Information: Hardware ARM v7 with Neon and VFPv4 OS version: REL(4.3), API 18

Installed packages: Built-in OpenCV library(active) Library version: 2.4.8.0 rev 1 Target hardware: armv7a neon

The full code is:

package com.threevdreams.app;

import android.os.Bundle; import android.app.Activity; import android.view.WindowManager; 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.NativeCameraView; import org.opencv.android.OpenCVLoader; import org.opencv.core.Mat;

public class CameraTestActivity extends Activity implements CvCameraViewListener2 {

private CameraBridgeViewBase mCameraView;

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

@Override public void onCameraViewStarted(final int width, final int height) { }

@Override public void onCameraViewStopped() { }

@Override public Mat onCameraFrame(final CvCameraViewFrame inputFrame) { final Mat rgba = inputFrame.rgba();

return rgba; }

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

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

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

}

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

mCameraView = new NativeCameraView(this, 0); mCameraView.setCvCameraViewListener(this); setContentView(mCameraView); }
}

</code>

Video Stop/Crash on Samsung Galaxy S4

Hi,When I start the camara using camaraIndex different of 1 (Front Camara) on my Samsung Galaxy S4 the video crash it.

The test that I did: mCameraView = new NativeCameraView(this, 0); //fail //fail

mCameraView = new NativeCameraView(this, 1); //successfull //successfull

mCameraView = new NativeCameraView(this, -1); //fail

Also I tested it with and Camera index different of 1: 1:

OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3,this, mLoaderCallback); //fail //fail

OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_8,this, mLoaderCallback); //fail

I am using OpenCV Manager version: 2.16

Device Information: Hardware ARM v7 with Neon and VFPv4 OS version: REL(4.3), API 18

Installed packages: Built-in OpenCV library(active) Library version: 2.4.8.0 rev 1 Target hardware: armv7a neon

The full code is:

package com.threevdreams.app;

import android.os.Bundle; import android.app.Activity; import android.view.WindowManager; 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.NativeCameraView; import org.opencv.android.OpenCVLoader; import org.opencv.core.Mat;

public class CameraTestActivity extends Activity implements CvCameraViewListener2 {

private CameraBridgeViewBase mCameraView;

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

@Override public void onCameraViewStarted(final int width, final int height) { }

@Override public void onCameraViewStopped() { }

@Override public Mat onCameraFrame(final CvCameraViewFrame inputFrame) { final Mat rgba = inputFrame.rgba();

return rgba; }

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

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

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

}

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

mCameraView = new NativeCameraView(this, 0); mCameraView.setCvCameraViewListener(this); setContentView(mCameraView); }
}

</code>