我是Opencv的新手。在android应用程序中,opencv工作但在logcat中给出了错误。我怎么解决这个问题 ?在运行时相机运行但进一步的应用程序我不能做对象识别。我该怎么办? 任何资源或文档都有帮助。谢谢。
清单
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.front"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.front.autofocus"
android:required="false" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
这是我的源代码
public class MainActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2{
private static final String TAG = "OpenCV Taha Camera : ";
public static CameraBridgeViewBase cameraBridgeViewBase;
public TextView screen_info;
private static final int REQUEST_PERMISSION = 100;
static {
if(!OpenCVLoader.initDebug()){
Log.d(TAG,"OpenCV NOT LOADED.");
}else {
Log.d(TAG,"OpenCV Loaded Successfully.");
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
screen_info = findViewById(R.id.screen_info);
if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.CAMERA},REQUEST_PERMISSION);
}
cameraBridgeViewBase = findViewById(R.id.camera_screen);
cameraBridgeViewBase.setVisibility(SurfaceView.VISIBLE);
cameraBridgeViewBase.setCvCameraViewListener(this);
screen_info.setText("---No Info Currently---");
}
@Override
public void onResume() {
super.onResume();
if(!OpenCVLoader.initDebug()){
Log.d(TAG,"OpenCV Library NOT LOADED! ");
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_4_0,this,baseLoaderCallback);
}else{
Log.d(TAG,"OpenCV Loaded Successfully");
baseLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
}
}
private BaseLoaderCallback baseLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status){
case LoaderCallbackInterface.SUCCESS:
cameraBridgeViewBase.enableView();
break;
default:
super.onManagerConnected(status);
break;
}
}
};
@Override
public void onCameraViewStarted(int width, int height) {
}
@Override
public void onCameraViewStopped() {
}
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
return inputFrame.rgba();
}
}
Logcat:
> 05-03 00:20:22.550 789-789/? E/libc: Access denied finding property
> "persist.camera.debug.assert"
> Access denied finding property "persist.camera.debug.logfile" 05-03 00:20:22.550 789-789/? W/libc: Unable to set property
> "persist.camera.debug.logfile" to "0": connection failed; errno=13
> (Permission denied) 05-03 00:20:22.550 789-789/? E/libc: Access denied
> finding property "persist.camera.fdleak.enable" 05-03 00:20:22.551
> 789-789/? E/libc: Access denied finding property
> "persist.camera.global.debug"
> Access denied finding property "persist.camera.mct.debug"
> Access denied finding property "persist.camera.sensor.debug"
> Access denied finding property "persist.camera.iface.logs"
> Access denied finding property "persist.camera.isp.debug"
> Access denied finding property "persist.camera.pproc.debug.mask"
> Access denied finding property "persist.camera.imglib.logs" 05-03 00:20:22.552 789-789/? E/libc: Access denied finding property
> "persist.camera.cpp.debug.mask"
> Access denied finding property "persist.camera.hal.debug"
> Access denied finding property "persist.camera.mmstill.logs"
> Access denied finding property "persist.camera.c2d.debug.mask"
> Access denied finding property "persist.camera.stats.debug"
> Access denied finding property "persist.camera.stats.af.debug"
> Access denied finding property "persist.camera.stats.aec.debug"
> Access denied finding property "persist.camera.stats.awb.debug"
> Access denied finding property "persist.camera.stats.asd.debug"
> Access denied finding property "persist.camera.stats.afd.debug"
> Access denied finding property "persist.camera.stats.q3a.debug"
> Access denied finding property "persist.camera.stats.is.debug"
> Access denied finding property "persist.camera.stats.haf.debug"
> Access denied finding property "persist.camera.stats.cafscan"
> Access denied finding property "persist.camera.shim.debug"