2015-09-30 46 views
0

我試圖編譯opencv的一個項目,但我不斷收到這樣的問題:錯誤:(5,18)錯誤:無法找到符號R級Android的工作室 - 錯誤無法找到符號R級在編譯OpenCV的

錯誤發生在這裏:import org.opencv.R;

這僅僅是一個地方,我發現了錯誤代碼的一部分:

package br.raphael.extended; 
import java.util.List; 
import org.opencv.R; 
import org.opencv.android.Utils; 
import org.opencv.core.Mat; 
import org.opencv.core.Size; 
import org.opencv.highgui.Highgui; 

import br.raphael.detector.FpsMeterExtended; 
import android.app.Activity; 
import android.app.AlertDialog; 
import android.content.Context; 
import android.content.DialogInterface; 
import android.content.res.TypedArray; 
import android.graphics.Bitmap; 
import android.graphics.Canvas; 
import android.util.AttributeSet; 
import android.util.Log; 
import android.view.SurfaceHolder; 
import android.view.SurfaceView; 

/** 
* This is a basic class, implementing the interaction with Camera and OpenCV library. 
* The main responsibility of it - is to control when camera can be enabled, process the frame, 
* call external listener to make any adjustments to the frame and then draw the resulting 
* frame to the screen. 
* The clients shall implement CvCameraViewListener. 
*/ 
public abstract class CameraBridgeViewBaseExtended extends SurfaceView implements SurfaceHolder.Callback { 

    private static final String TAG = "CameraBridge"; 
    private static final int MAX_UNSPECIFIED = -1; 
    private static final int STOPPED = 0; 
    private static final int STARTED = 1; 

    private int mState = STOPPED; 
    private Bitmap mCacheBitmap; 
    private CvCameraViewListener2 mListener; 
    private boolean mSurfaceExist; 
    private Object mSyncObject = new Object(); 

    protected int mFrameWidth; 
    protected int mFrameHeight; 
    protected int mMaxHeight; 
    protected int mMaxWidth; 
    protected int mPreviewFormat = Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA; 
    protected int mCameraIndex = -1; 
    protected boolean mEnabled; 
    protected FpsMeterExtended mFpsMeter = null; 

    public CameraBridgeViewBaseExtended(Context context, int cameraId) { 
     super(context); 
     mCameraIndex = cameraId; 
    } 

    public CameraBridgeViewBaseExtended(Context context, AttributeSet attrs) { 
     super(context, attrs); 

     int count = attrs.getAttributeCount(); 
     Log.d(TAG, "Attr count: " + Integer.valueOf(count)); 

     TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase); 
     if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false)) 
      enableFpsMeter(); 

     mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1); 

     getHolder().addCallback(this); 
     mMaxWidth = MAX_UNSPECIFIED; 
     mMaxHeight = MAX_UNSPECIFIED; 
    } 

回答

0

如果您收到錯誤提import org.opencv.R,這意味着有錯誤在你的一些XML視圖頁面。請重新檢查XML


+0

我認爲這個問題可能是在這裏:'TypedArray styledAttrs =的getContext()obtainStyledAttributes(ATTRS,R.styleable.CameraBridgeViewBase);'在OpenCV的res文件夾我有這個attrs文件包含:<?xml version =「1.0」encoding =「utf-8」?> ' –

相關問題