OpenCV4Android 提取特徵點描述符(Feature Descriptor),opencv4android

來源:互聯網
上載者:User

OpenCV4Android 提取特徵點描述符(Feature Descriptor),opencv4android
OpenCV4Android 提取特徵點描述符(Feature Descriptor)

在得到keypoints之後(參考前面),通過使用相應的FeatureDescriptor就可計算得到關鍵點處的描述子。

Native Code:

JNIEXPORT void JNICALL Java_com_example_test_NativeUtil_computeDescripors(        JNIEnv *env, jclass thiz, jlong mGrayAddr, jlong mRgbaAddr, jlong mOutputAddr) {    Mat* pMatGr=(Mat*)mGrayAddr;    Mat* pMatRgb=(Mat*)mRgbaAddr;    Mat* pMatDesc=(Mat*)mOutputAddr;    vector<KeyPoint> v;    //OrbFeatureDetector detector(50);    OrbFeatureDetector detector;    OrbDescriptorExtractor extractor;    detector.detect(*pMatGr, v);    extractor.compute(*pMatGr, v, *pMatDesc);}

運行效果:


這樣的結果是對的,因為得到的描述子是一個矩陣,每個關鍵點對應一個向量。通過logcat的日誌可以看到關於這個向量的資訊。

06-17 13:25:32.339: I/Feature Descriptor::Activity(2689): Row:490,Col:32,channels:1

說明提取了490個特徵點,特徵點對應的描述子是32維(這裡是ORB,如果是SIFT的話,維度不同)

遇到的錯誤
錯誤1:

06-17 12:53:05.021: E/AndroidRuntime(1532): Caused by: java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.Button

有時候莫名的誤判該錯,通過刪除R.java 來解決。

參考:
Common Interfaces of Descriptor Extractors

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.