Ask Your Question

Read keyfeatures on Android without saving image file

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

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



there are converters for this :

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

1 answer

Sort by ยป oldest newest most voted

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

Anthea gravatar image

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

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
Login/Signup to Answer

Question Tools

1 follower


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

Seen: 58 times

Last updated: Nov 20 '15