Search in sources :

Example 1 with AKAZE

use of org.bytedeco.javacpp.opencv_features2d.AKAZE in project javacv by bytedeco.

the class OpenCVFeatures2dSerialization method serializeMemory.

private static String serializeMemory(Mat matrix) throws UnsupportedEncodingException {
    try (KeyPointVector keyPointVectorSerialize = new KeyPointVector();
        Mat objectDescriptorsSerialize = new Mat();
        AKAZE akaze = AKAZE.create();
        FileStorage fileStorage = new FileStorage(".xml", FileStorage.WRITE | FileStorage.MEMORY, StandardCharsets.UTF_8.name())) {
        akaze.detectAndCompute(matrix, new Mat(), keyPointVectorSerialize, objectDescriptorsSerialize, false);
        System.out.println("Vector size: " + keyPointVectorSerialize.size());
        System.out.println("Descriptor size: " + objectDescriptorsSerialize.cols());
        write(fileStorage, "keyPoints", keyPointVectorSerialize);
        write(fileStorage, "descriptors", objectDescriptorsSerialize);
        BytePointer bytePointer = fileStorage.releaseAndGetString();
        return bytePointer.getString(StandardCharsets.UTF_8.name());
    }
}
Also used : AKAZE(org.bytedeco.javacpp.opencv_features2d.AKAZE) BytePointer(org.bytedeco.javacpp.BytePointer)

Example 2 with AKAZE

use of org.bytedeco.javacpp.opencv_features2d.AKAZE in project javacv by bytedeco.

the class OpenCVFeatures2dSerialization method serializeFile.

private static void serializeFile(Mat matrix, String fileName) throws UnsupportedEncodingException {
    try (KeyPointVector keyPointVectorSerialize = new KeyPointVector();
        Mat objectDescriptorsSerialize = new Mat();
        AKAZE akaze = AKAZE.create();
        FileStorage fileStorage = new FileStorage(fileName, FileStorage.WRITE, StandardCharsets.UTF_8.name())) {
        akaze.detectAndCompute(matrix, new Mat(), keyPointVectorSerialize, objectDescriptorsSerialize, false);
        System.out.println("Vector size: " + keyPointVectorSerialize.size());
        System.out.println("Descriptor size: " + objectDescriptorsSerialize.cols());
        write(fileStorage, "keyPoints", keyPointVectorSerialize);
        write(fileStorage, "descriptors", objectDescriptorsSerialize);
        fileStorage.release();
    }
}
Also used : AKAZE(org.bytedeco.javacpp.opencv_features2d.AKAZE)

Aggregations

AKAZE (org.bytedeco.javacpp.opencv_features2d.AKAZE)2 BytePointer (org.bytedeco.javacpp.BytePointer)1