做opencv分类器遇到的问题,老是记不住…
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
String file = "D:\\temp\\image_sign_wood";
img_be_gey(file);
}
public static void img_be_gey(String path) {
File file = new File(path);
LinkedList<File> list = new LinkedList<File>();
if (file.exists()) {
if (null == file.listFiles()) {
return;
}
list.addAll(Arrays.asList(file.listFiles()));
Mat src = new Mat();
Mat dst = new Mat();
if (!list.isEmpty()) {
for (File f : list) {
src = Imgcodecs.imread(f.getAbsolutePath().toString(), Imgcodecs.IMREAD_GRAYSCALE);
Imgproc.resize(src, dst, new Size(20, 20));
Imgcodecs.imwrite(f.getAbsolutePath().toString(),dst);
}
}
}
}
运行前:
运行后: