Android图片识别错误

时间:2014-07-29 07:08:46

标签: android image image-recognition

我正在开发一个用于识别图像的应用程序,我有一个工作的示例代码..在我执行的代码中,显示错误...我在下面给出了我的代码...并且logcat可以任何人帮帮我......

logcat的

07-29 02:48:30.533: E/AndroidRuntime(1332): FATAL EXCEPTION: main
07-29 02:48:30.533: E/AndroidRuntime(1332): Process: com.example.therefore, PID: 1332
07-29 02:48:30.533: E/AndroidRuntime(1332): java.lang.NoClassDefFoundError: com.example.therefore.ARFromCraftARActivity
07-29 02:48:30.533: E/AndroidRuntime(1332):     at com.example.therefore.LaunchersActivity.onClick(LaunchersActivity.java:99)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at android.view.View.performClick(View.java:4438)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at android.view.View$PerformClick.run(View.java:18422)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at android.os.Handler.handleCallback(Handler.java:733)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at android.os.Handler.dispatchMessage(Handler.java:95)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at android.os.Looper.loop(Looper.java:136)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at android.app.ActivityThread.main(ActivityThread.java:5017)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at java.lang.reflect.Method.invokeNative(Native Method)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at java.lang.reflect.Method.invoke(Method.java:515)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-29 02:48:30.533: E/AndroidRuntime(1332):     at dalvik.system.NativeStart.main(Native Method)

LauncherActivity

public class LaunchersActivity extends Activity implements OnClickListener {

    // Howto links
    private TextView mHowToLink;
    private LinearLayout mAboutArProgrammatically;
    private LinearLayout mAboutArFromCraftAR;
    private LinearLayout mAboutRecognitionOnly;

    // Launch example links
    private LinearLayout mArProgrammatically;
    private LinearLayout mArFromCraftAR;
    private LinearLayout mRecognitionOnly;

    // Bottom links
    private ImageButton mButtonCatchoom;
    private Button mButtonSignUp;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_launchers);

        // Setup howto links
        mHowToLink = (TextView)findViewById(R.id.howto_link);
        mHowToLink.setClickable(true);
        mHowToLink.setOnClickListener(this);
        mAboutArProgrammatically = (LinearLayout)findViewById(R.id.howto_link_ar_programmatically);
        mAboutArProgrammatically.setClickable(true);
        mAboutArProgrammatically.setOnClickListener(this);
        mAboutArFromCraftAR = (LinearLayout)findViewById(R.id.howto_link_ar_from_craftar);
        mAboutArFromCraftAR.setClickable(true);
        mAboutArFromCraftAR.setOnClickListener(this);
        mAboutRecognitionOnly = (LinearLayout)findViewById(R.id.howto_link_recognition_only);
        mAboutRecognitionOnly.setClickable(true);
        mAboutRecognitionOnly.setOnClickListener(this);

        // Setup example links
        mArProgrammatically = (LinearLayout)findViewById(R.id.play_ar_programmatically);
        mArProgrammatically.setClickable(true);
        mArProgrammatically.setOnClickListener(this);
        mArFromCraftAR = (LinearLayout)findViewById(R.id.play_ar_from_craftar);
        mArFromCraftAR.setClickable(true);
        mArFromCraftAR.setOnClickListener(this);
        mRecognitionOnly = (LinearLayout)findViewById(R.id.play_recognition_only);
        mRecognitionOnly.setClickable(true);
        mRecognitionOnly.setOnClickListener(this);


        // Setup bottom Links
        mButtonCatchoom = (ImageButton)findViewById(R.id.imageButton_logo);
        mButtonCatchoom.setOnClickListener(this);
        mButtonSignUp = (Button)findViewById(R.id.button_signUp);
        mButtonSignUp.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {

        // Clicked on title or howto links
        Intent launchHowto = null;
        if (v == mHowToLink) {
            launchHowto = new Intent(this, HowToActivity.class);
            launchHowto.putExtra(HowToActivity.HOWTO_LAYOUT_EXTRA, R.layout.activity_howto);
        } else if (v == mAboutArProgrammatically) {
            launchHowto = new Intent(this, HowToActivity.class);
            launchHowto.putExtra(HowToActivity.HOWTO_LAYOUT_EXTRA, R.layout.activity_howto_ar_programmatically);
        } else if (v == mAboutArFromCraftAR) {
            launchHowto = new Intent(this, HowToActivity.class);
            launchHowto.putExtra(HowToActivity.HOWTO_LAYOUT_EXTRA, R.layout.activity_howto_ar_from_craftar);
        } else if (v == mAboutRecognitionOnly) {
            launchHowto = new Intent(this, HowToActivity.class);
            launchHowto.putExtra(HowToActivity.HOWTO_LAYOUT_EXTRA, R.layout.activity_howto_recognition_only);
        }
        if (launchHowto != null) {
            startActivity(launchHowto);
            return;
        }

        // Clicked on play links
        Intent playExampleIntent = null;
        if (v == mArProgrammatically) {
            playExampleIntent = new Intent(this, ARProgrammaticallyActivity.class);
        } else if (v == mArFromCraftAR) {
            playExampleIntent = new Intent(this, ARFromCraftARActivity.class);
        } else if (v == mRecognitionOnly) {
            playExampleIntent = new Intent(this, RecognitionOnlyActivity.class);

        }
        if (playExampleIntent != null) 
        {
            startActivity(playExampleIntent);
            return;
        }


        // Clicked on bottom links
        if (v == mButtonCatchoom || v == mButtonSignUp) {
            // mButtonCatchoom
            String url = "http://catchoom.com/product/?utm_source=CraftARExamplesApp&utm_medium=Android&utm_campaign=HelpWithAPI";
            if (v == mButtonSignUp) {
                url = "https://crs.catchoom.com/try-free?utm_source=CraftARExamplesApp&utm_medium=Android&utm_campaign=HelpWithAPI";
            }

            Intent launchWebView = new Intent(this, WebActivity.class);
            launchWebView.putExtra(WebActivity.WEB_ACTIVITY_URL, url);
            startActivity(launchWebView);           
            return;
        }
    }

}

ARFromCraftActivity

public class ARFromCraftARActivity extends CatchoomActivity implements CatchoomResponseHandler,CatchoomImageHandler {

    private final String TAG = "CatchoomTrackingExample";
    private final static String COLLECTION_TOKEN="craftarexamples1";

    private View mScanningLayout;

    CatchoomCamera mCamera;

    CatchoomCloudRecognition mCloudRecognition;
    CatchoomTracking mCatchoomTracking;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onPostCreate() {

        View mainLayout= (View) getLayoutInflater().inflate(R.layout.activity_ar_programmatically_ar_from_craftar, null);
        CatchoomCameraView cameraView = (CatchoomCameraView) mainLayout.findViewById(R.id.camera_preview);
        super.setCameraView(cameraView);
        setContentView(mainLayout);

        mScanningLayout = findViewById(R.id.layout_scanning);


        //Initialize the SDK. From this SDK, you will be able to retrieve the necessary modules to use the SDK (camera, tracking, and cloud-recgnition)
        CatchoomSDK.init(getApplicationContext(),this);

        //Get the camera to be able to do single-shot (if you just use finder-mode, this is not necessary)
        mCamera= CatchoomSDK.getCamera();
        mCamera.setImageHandler(this); //Tell the camera who will receive the image after takePicture()

        //Setup the finder-mode: Note! PRESERVE THE ORDER OF THIS CALLS
        mCloudRecognition= CatchoomSDK.getCloudRecognition();//Obtain the cloud recognition module
        mCloudRecognition.setResponseHandler(this); //Tell the cloud recognition who will receive the responses from the cloud
        mCloudRecognition.setCollectionToken(COLLECTION_TOKEN); //Tell the cloud-recognition which token to use from the finder mode



        //Start finder mode
        mCloudRecognition.startFinding();

        //Obtain the tracking module
        mCatchoomTracking = CatchoomSDK.getTracking();

        mCloudRecognition.connect(COLLECTION_TOKEN);

    }

    @Override
    public void searchCompleted(ArrayList<CatchoomCloudRecognitionItem> results) {
        if(results.size()==0){
        }else{
            CatchoomCloudRecognitionItem item = results.get(0);
            if (item.isAR()) {
                // Stop Finding
                mCloudRecognition.stopFinding();

                // Cast the found item to an AR item
                CatchoomARItem myARItem = (CatchoomARItem)item;

                // Add content to the tracking SDK and start AR experience
                mCatchoomTracking.addItem(myARItem);
                mCatchoomTracking.startTracking();

                mScanningLayout.setVisibility(View.GONE);
            }

        }
    }

    @Override
    public void connectCompleted(){
        Log.i(TAG,"Collection token is valid");
    }

    @Override
    public void requestFailedResponse(int requestCode,
            CatchoomCloudRecognitionError responseError) {
        Log.d(TAG,"requestFailedResponse"); 

    }

    //Callback received for SINGLE-SHOT only (after takePicture).
    @Override
    public void requestImageReceived(CatchoomImage image) {
        mCloudRecognition.searchWithImage(COLLECTION_TOKEN,image);
    }
    @Override
    public void requestImageError(String error) {
        //Take picture failed
    }



}

Image

1 个答案:

答案 0 :(得分:0)

错误是ClassNotFoundException,这意味着编译器无法找到您的类 ARFromCraftARActivity.java文件

所以你需要完美地提及这个课程,因为我的未来你正在使用这个项目的库,如果是,那么按照下面的步骤来解决&#34;类未找到异常的错误&#34;

1)右键点击项目

2)转到属性

3)转到java构建路径

4)转到订单和导出标签

5)检查您为项目包含的库

6)单击确定应用更改并编译代码