Android OpenCV:在包中找不到属性"camera_id"的资源标识符

jae*_*anx 6 java eclipse android opencv

我在Eclipse中设置了OpenCV和Android.以下是我的布局文件之一:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:opencv="http://schemas.android.com/apk/res-auto"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

    <org.opencv.android.JavaCameraView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="gone"
        android:id="@+id/hello"
        opencv:show_fps="true"
        opencv:camera_id="any" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Eclipse编译器抱怨:

No resource identifier found for attribute 'show_fps' in package 
No resource identifier found for attribute 'camera_id' in package 
Run Code Online (Sandbox Code Playgroud)

Abh*_*rde 6

请在项目的values目录中添加以下资源文件:

attrs.xml
Run Code Online (Sandbox Code Playgroud)

以下内容:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name = "CameraBridgeViewBase" >
       <attr name="show_fps" format="boolean"/>
       <attr name="camera_id" format="integer" >
          <enum name="any" value="-1" />
          <enum name="back" value="0" />
          <enum name="front" value="1" />
       </attr>
    </declare-styleable>
</resources>
Run Code Online (Sandbox Code Playgroud)


har*_*nan 0

您没有为此变量指定值或未在 opencv 类中声明。

    opencv {

   show_fps="true"
   camera_id="any"

     }

  First assign the those two variables globally with necessary values....
Run Code Online (Sandbox Code Playgroud)