
java版的Open CV4.4.0代码,使用SIFT特征值进行图像匹配,网上找了很久,发现基本都是Py和C++的代码。后面自己参考了一些,结合自己思考的一些,提供给大家参考。
注意,4.4.0版本里面自带SIFT算法,不需要大家进行编译的!
Open CV的安装就不在本篇里面介绍了,大家直接搜索一下,一大把的教程。
先贴上图片的转化代码:
public static BufferedImage toBufferedImageOfType(BufferedImage original, int type) {
if (original == null) {
throw new IllegalArgumentException("original为空!");
}
if (original.getType() == type) {
return original;
}
BufferedImage image = new BufferedImage(original.getWidth(), original.getHeight(), type);
Graphics2D g = image.createGraphics();
try {
g.setComposite(AlphaComposite.Src);
g.drawImage(original, 0, 0, null);
} finally {
g.dispose();
}
return image;
}
引入需要使用的依赖包: