gpt4 book ai didi

android - SURF 和 SIFT 特征检测器 OpenCV android

转载 作者:太空宇宙 更新时间:2023-11-03 22:29:47 26 4
gpt4 key购买 nike

我想检测图像关键点。我使用 OpenCV 库中的不同特征检测器尝试了以下代码。

它适用于 ORB 、 BRISK 、 FAST 等。但不适用于 SURF/SIFT 甚至 MSER 检测器!

 public class ReadImaageActivity extends ActionBarActivity {

Mat image ; File fileimage ;
TimePicker time ;
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i("activity", "OpenCV loaded successfully");

fileimage = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/7.jpg");

if (fileimage.exists())

image = Highgui.imread(fileimage.getAbsolutePath() ,Highgui.CV_LOAD_IMAGE_COLOR);

else Log.i("activity","dont exit") ;


//

long startTime = System.nanoTime();

FeatureDetector fd= FeatureDetector.create(FeatureDetector.SURF);

MatOfKeyPoint keypoints= new MatOfKeyPoint();
try
{

fd.detect(image, keypoints);

} catch (Exception e) {
e.printStackTrace();
}

long endTime = System.nanoTime();

long duration = (endTime - startTime)/1000000; //divide by 1000000 to get milliseconds.



if (!keypoints.empty())
{

Log.i("Keypoints", "is not empty");


System.out.println("duration"+""+duration);


System.out.println("size"+""+keypoints.size());
}
else
Log.i("Keypoints", "is not empty");
/*
Mat descriptors=new Mat();
DescriptorExtractor dex =DescriptorExtractor.create(DescriptorExtractor.SURF);


{


dex.compute(image, keypoints, descriptors);

long endTime = System.nanoTime();

long duration = (endTime - startTime)/1000000; //divide by 1000000 to get milliseconds.
System.out.println(descriptors.size());
System.out.println("duration"+duration);
}
else System.out.println("a3");

*/










} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
@SuppressLint("NewApi") @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_read_imaage);


}

@Override
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this, mLoaderCallback);
}

}

是因为不支持SURF和SIFT算法?

最佳答案

对于 C++ 版本,我们使用 cv::initModule_nonfree()

这是因为在新版本的 OpenCV 中,SURF/SIFT 算法遗憾地位于单独的库中,需要在创建这些特征检测器之前对其进行初始化。

关于android - SURF 和 SIFT 特征检测器 OpenCV android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28503060/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com