Ask Your Question
0

Read keyfeatures on Android without saving image file

asked 2015-11-20 03:02:21 -0600

Anthea gravatar image

Hey folks,

I am taking a picture that is internally saved as Bitmap. It's not automatically saved to file system since it should be only tempoary. Currently I am saving that Bitmap as .png to the internal stoarage to pass it to opencv. Actually that step is kind of redundant and takes additional time. Is it possible to directly create a Mat from a byte array or bitmap?

Here is my code for the feature extraction:

public static String extractKeypoints(String location){
    Mat image = Imgcodecs.imread(location);
    DescriptorExtractor descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);

    FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
    MatOfKeyPoint keypoints = new MatOfKeyPoint();
    detector.detect(image, keypoints);

    Mat finalMatrix = new Mat();
    descriptor.compute(image, keypoints, finalMatrix);

    StringBuilder builder = new StringBuilder();

    double[] temp;
    for (int i = 0; i < finalMatrix.rows(); i++) {
        for (int j = 0; j < finalMatrix.cols(); j++) {
            temp = finalMatrix.get(i, j);
            builder.append(String.valueOf(temp[0]) + " ");
        }
    }
    return builder.toString();
}
edit retag flag offensive close merge delete

Comments

1

there are converters for this : http://docs.opencv.org/java/2.4.11/or...

berak gravatar imageberak ( 2015-11-20 03:05:47 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-11-20 03:13:18 -0600

Anthea gravatar image

updated 2015-11-20 04:01:11 -0600

berak gravatar image

Thanks a lot , I wasn't aware of that. This works like a charme! >>

 Mat image = new Mat(); 
 Utils.bitmapToMat(bitmap, image);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-20 03:02:21 -0600

Seen: 144 times

Last updated: Nov 20 '15