我正在开发一个简单的应用程序,该应用程序可以从我的智能手机相机获取帧。当我的手机具有较旧的API(24及以下)时,由于没有进行任何图像处理,因此我通常会以30 fps的速度进行拍摄。令我惊讶的是,当我尝试在与Android Oreo 8.0(API 26)相同的手机上使用该应用程序时,即使将相机分辨率更改为最低(320x240),我也只能获得7.5 fps。我试图在App的清单中添加android:largeHeap =“ true”,但没有成功。可能发生了什么事?我该如何解决?
电话:摩托罗拉Z-Play-3GB Ram
OpenCV: 3.1.0
电话操作系统::8.0(API 26)
主要活动
public class MainActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2{
private static String TAG = "MainActivity";
JavaCameraView javaCameraView;
Mat mRgba;
BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status){
case BaseLoaderCallback.SUCCESS:
javaCameraView.enableView();
javaCameraView.setCameraIndex(1);
break;
default:
super.onManagerConnected(status);
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
javaCameraView = (JavaCameraView)findViewById(R.id.java_camera_view);
javaCameraView.setVisibility(View.VISIBLE);
javaCameraView.setCvCameraViewListener(this);
javaCameraView.setMaxFrameSize(320,240);
javaCameraView.enableFpsMeter();
}
@Override
protected void onPause(){
super.onPause();
if(javaCameraView != null)
javaCameraView.disableView();
}
protected void onDestroy(){
super.onDestroy();
if(javaCameraView != null)
javaCameraView.disableView();
}
protected void onResume(){
super.onResume();
if(OpenCVLoader.initDebug()){
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
}
else {
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, this, mLoaderCallback);
}
}
@Override
public void onCameraViewStarted(int width, int height) {
mRgba = new Mat (height, width, CvType.CV_8UC4);
}
@Override
public void onCameraViewStopped() {
mRgba.release();
}
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame)
mRgba = inputFrame.rgba();
return mRgba;
}
}