特征提取与匹配案例代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

特征提取与匹配案例代码、

环境:Android studio + opencv for Android

MainActivity.java

package com.packtpub.masteringopencvandroid.chapter3;

import android.app.Activity;

import android.content.Intent;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import .Uri;

import android.os.AsyncTask;

import android.os.Bundle;

import android.os.Environment;

import android.util.Log;

import android.view.Menu;

import android.view.MenuItem;

import android.widget.ImageView;

import android.widget.TextView;

import android.widget.Toast;

import org.opencv.android.BaseLoaderCallback;

import org.opencv.android.LoaderCallbackInterface;

import org.opencv.android.OpenCVLoader;

import org.opencv.android.Utils;

import org.opencv.core.Core;

import org.opencv.core.CvType;

import org.opencv.core.Mat;

import org.opencv.core.MatOfDMatch;

import org.opencv.core.MatOfKeyPoint;

import org.opencv.core.Point;

import org.opencv.core.Scalar;

import org.opencv.features2d.DMatch;

import org.opencv.features2d.DescriptorExtractor;

import org.opencv.features2d.DescriptorMatcher;

import org.opencv.features2d.FeatureDetector;

import org.opencv.features2d.Features2d;

import org.opencv.highgui.Highgui;

import org.opencv.imgproc.Imgproc;

import java.io.FileNotFoundException;

import java.io.InputStream;

import java.util.Collections;

import parator;

import java.util.Date;

import java.util.List;

public class MainActivity extends Activity {

private final int SELECT_PHOTO_1 = 1;

private final int SELECT_PHOTO_2 = 2;

private final int MAX_MATCHES = 50;

private ImageView ivImage1;

private TextView tvKeyPointsObject1, tvKeyPointsObject2, tvKeyPointsMatches, tvTime;

private int keypointsObject1, keypointsObject2, keypointMatches;

Mat src1, src2;

static int ACTION_MODE = 0;

private boolean src1Selected = false, src2Selected = false;

private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) { @Override

public void onManagerConnected(int status) {

switch (status) {

case LoaderCallbackInterface.SUCCESS:

//DO YOUR WORK/STUFF HERE

System.loadLibrary("nonfree");

break;

default:

super.onManagerConnected(status);

break;

}

}

};

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(yout.activity_main);

getActionBar().setDisplayHomeAsUpEnabled(true);

ivImage1 = (ImageView)findViewById(R.id.ivImage1);

tvKeyPointsObject1 = (TextView) findViewById(KeyPointsObject1);

tvKeyPointsObject2 = (TextView) findViewById(KeyPointsObject2);

tvKeyPointsMatches = (TextView) findViewById(KeyPointsMatches);

keypointsObject1 = keypointsObject2 = keypointMatches = -1;

相关文档
最新文档