Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java OpenImaj和OpenCV-SURF特性描述符到字节数组_Java_Opencv_Openimaj - Fatal编程技术网

Java OpenImaj和OpenCV-SURF特性描述符到字节数组

Java OpenImaj和OpenCV-SURF特性描述符到字节数组,java,opencv,openimaj,Java,Opencv,Openimaj,出于我不想深入讨论的原因,我需要将从图像中提取的冲浪特征描述符(存储在Mat对象中)转换为字节[],字节[]是存储关键点描述符的OpenImaj关键点格式。我这样做对吗 public LocalFeatureList<Keypoint> findFeatures(FImage image) { BufferedImage bimg = ImageUtilities.createBufferedImage(image); byte[] pixelsfalt = ((D

出于我不想深入讨论的原因,我需要将从图像中提取的冲浪特征描述符(存储在Mat对象中)转换为字节[],字节[]是存储关键点描述符的OpenImaj关键点格式。我这样做对吗

public LocalFeatureList<Keypoint> findFeatures(FImage image) {
    BufferedImage bimg = ImageUtilities.createBufferedImage(image);
     byte[] pixelsfalt = ((DataBufferByte)     bimg.getRaster().getDataBuffer()).getData();

    Mat matimage = new Mat(bimg.getWidth(),bimg.getHeight(),CvType.CV_8UC(1));
    matimage.put(0, 0, pixelsfalt);

    MatOfKeyPoint keypoints = new MatOfKeyPoint();
    Mat descriptor = new Mat();

    fd.detect(matimage, keypoints);
    surfExtractor.compute(matimage, keypoints, descriptor);

    //this is wrong as far as I know
    float [] desc = new float[descriptor.height()*descriptor.width()];
    descriptor.get(0,0,desc);

    LocalFeatureList<Keypoint> toReturn = new MemoryLocalFeatureList<Keypoint>();
    org.opencv.features2d.KeyPoint[] matkeys = keypoints.toArray();


    for(org.opencv.features2d.KeyPoint k : matkeys){

        Keypoint toAdd = new Keypoint();
        toAdd.x = (float) k.pt.x;
        toAdd.y = (float) k.pt.y;

        toAdd.scale = k.size;
        toAdd.ori = (float) Math.toRadians(k.angle);
        //so is this
        toAdd.ivec = new byte[128];
        toReturn.add(toAdd);
    }

    return toReturn;
}
public LocalFeatureList findFeatures(FImage图像){
BuffereImage bimg=ImageUtilities.createBuffereImage(图像);
字节[]像素值=((数据缓冲字节)bimg.getRaster().getDataBuffer()).getData();
Mat matimage=新Mat(bimg.getWidth()、bimg.getHeight()、CvType.CV_8UC(1));
matimage.put(0,0,像素值);
MatOfKeyPoint关键点=新的MatOfKeyPoint();
Mat描述符=新Mat();
fd.检测(图像、关键点);
计算(图像、关键点、描述符);
//据我所知,这是错误的
float[]desc=新的float[descriptor.height()*descriptor.width()];
描述符.get(0,0,desc);
LocalFeatureList toReturn=新的MemoryLocalFeatureList();
org.opencv.features2d.KeyPoint[]matkeys=keypoints.toArray();
对于(org.opencv.features2d.KeyPoint k:matkeys){
Keypoint toAdd=新的Keypoint();
toAdd.x=(float)k.pt.x;
toAdd.y=(浮动)k.pt.y;
toAdd.scale=k.size;
toAdd.ori=(浮点)数学托拉迪安(k角);
//这也是
toAdd.ivec=新字节[128];
toReturn.add(toAdd);
}
回归回归;
}