Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 
like image 264
jaesanx Avatar asked Aug 08 '13 20:08

jaesanx


2 Answers

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>
like image 193
Abhijeet Kasurde Avatar answered Oct 19 '22 16:10

Abhijeet Kasurde


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
like image 1
Kameron Kincade Avatar answered Oct 19 '22 15:10

Kameron Kincade