簡體   English   中英

Android OpenCV:在包中找不到屬性“camera_id”的資源標識符

[英]Android OpenCV : No resource identifier found for attribute 'camera_id' in package

我在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>

Eclipse編譯器抱怨:

No resource identifier found for attribute 'show_fps' in package 
No resource identifier found for attribute 'camera_id' in package 

請在項目的values目錄中添加以下資源文件:

attrs.xml

以下內容:

<?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>

在我看來,這兩個先前給出的問題的答案是對實際問題的綳帶。 當我遇到此錯誤消息時,我需要更改一些項目屬性。

  1. 右鍵單擊項目並選擇“屬性”
  2. 在樹形控件中選擇“Android”
  3. 確保OpenCV庫存在,並在“庫”部分旁邊有一個綠色復選標記(見下圖)

成功鏈接OpenCV庫

如果OpenCV庫不存在或旁邊有紅色X,則需要修復庫依賴項。 去做這個:

  1. 刪除損壞的庫(如有必要)
  2. 單擊“添加”,然后選擇“OpenCV庫”
  3. 如果OpenCV庫不存在,則需要將庫添加到項目中

你沒有給這個變量賦值或者沒有在opencv類中聲明..

    opencv {

   show_fps="true"
   camera_id="any"

     }

  First assign the those two variables globally with necessary values....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM