jaesanx
jaesanx

Reputation: 205

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

I have OpenCV and Android set up in my Eclipse. The following is one of my layout files:

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

The Eclipse compiler complains about:

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

Upvotes: 6

Views: 4214

Answers (3)

Kameron Kincade
Kameron Kincade

Reputation: 623

The two previously given answers to this question, in my opinion, are bandaids to the actual problem. When I encountered this error message, I needed to change some project properties.

  1. Right click project and select Properties
  2. Select 'Android' in the tree control
  3. Make sure the OpenCV library is present and has a green check mark next to it in the 'Library' section (seen in the image below)

Successfully linked OpenCV Library

If the OpenCV library is not present or has a red X next to it, you need to fix the Library dependency. To do this:

  1. Remove broken library (if necessary)
  2. Click Add and select OpenCV Library
  3. If OpenCV library is not present, you need to add the library to the project

Upvotes: 1

Abhijeet Kasurde
Abhijeet Kasurde

Reputation: 4127

Please add following resource file in your project's values directory :

attrs.xml

with following content :

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

Upvotes: 7

harikrishnan
harikrishnan

Reputation: 1945

you did not given value for this variables or not declare in opencv class..

    opencv {

   show_fps="true"
   camera_id="any"

     }

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

Upvotes: 0

Related Questions