Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Get descriptor values in Android

I'm working on an app that uses ORB in order to detect some buildings. The values of the descriptor returned by the following code written in C++ are stored in a MySql database(my DB communicates with an Android app in order to detect the building):

Mat img2 = imread("C:\\Users\\timis\\Desktop\\test4.bmp");

    Mat img1 = img2;
    cvtColor(img2, img1, CV_BGR2GRAY);

    if (!img1.data)
    {
        printf(" --(!) Eroare la citirea imaginii \n");
        return -1;
    }

    std::vector<KeyPoint> keypoints_1, keypoints_2;

    Mat descriptors_1, descriptors_2;

    Ptr<ORB> orb = ORB::create(500, 1.2, 8, 31, 0, 2, ORB::HARRIS_SCORE, 31, 20);

    orb->detectAndCompute(img1, Mat(), keypoints_1, descriptors_1);

    if (test == 1){
    std::cout << "Found " << keypoints_1.size() << " Keypoints " << std::endl;
    std::cout << descriptors_1 << std::endl;

    std::cout << "Numar keypoints: "<<descriptors_1.rows << std::endl;
    std::cout << "Numar caracteristici: "<<descriptors_1.cols << std::endl;
            std::ofstream output("Descriptor.txt");

    output << descriptors_1;

    test -= 1;
    }

and this are the values returned: image description

The problem that I'm facing is that when I try to obtain the values of the image descriptor taken with the phones camera. This is the code I used:

FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
    Mat inputImage=new Mat();
    Utils.bitmapToMat(mOpenCvCameraView.bitmap,inputImage);

    Mat imagineGri=new Mat();
    //convert the photo from color to gray
    Imgproc.cvtColor(inputImage, imagineGri, Imgproc.COLOR_RGB2GRAY);

    MatOfKeyPoint keyPoint= new MatOfKeyPoint();

    detector.detect(imagineGri, keyPoint);

    DescriptorExtractor dExtractor=DescriptorExtractor.create(DescriptorExtractor.ORB);

    Mat descriptor=new Mat();

    dExtractor.compute(imagineGri,keyPoint,descriptor);

but this is what I get:

Mat [ 33532CV_8UC1, isCont=true, isSubmat=false, nativeObj=0x63c8fd70, dataAddr=0x63c984e0 ]

Shouldn't I have all the values like in C++? Or is there some way that allows me to do this?

Please help me solve this problem.