ここでは説明しませんが、画像から抽出された SURF 特徴記述子 (Mat オブジェクトに格納されている) を、OpenImaj キーポイントがキーポイント記述子を格納する形式である byte[] に変換する必要があります。私はこれを正しい方法で行っていますか?
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;
}