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

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章