opencv 通过Imgcodecs.imwrite()直接保存带有中文路径的图片会失败,需要转换为byteArray 再写入到路径中去
public static void imgWrite(final String imageName, final Mat mat) {
MatOfByte matOfByte = new MatOfByte();
Imgcodecs.imencode(".png", mat, matOfByte);
byte[] byteArray = matOfByte.toArray();
try {
FileOutputStream inputStream = new FileOutputStream(imageName);
inputStream.write(byteArray);
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}