// Path: src/main/java/com/wind/common/Constants.java
// public interface Constants {
// 
//     /**********************************************分隔符常量************************************************/
// 
//     String POINT_STR = ".";
// 
//     String BLANK_STR = "";
// 
//     String SPACE_STR = " ";
// 
//     String NEWLINE_STR = "\n";
// 
//     String SYS_SEPARATOR = File.separator;
// 
//     String FILE_SEPARATOR = "/";
// 
//     String BRACKET_LEFT = "[";
// 
//     String BRACKET_RIGHT = "]";
// 
//     String UNDERLINE = "_";
// 
//     String MINUS_STR = "-";
// 
// 
// 
//     /**********************************************编码格式************************************************/
// 
//     String UTF8 = "UTF-8";
// 
// 
//     /**********************************************文件后缀************************************************/
// 
//     String EXCEL_XLS = ".xls";
// 
//     String EXCEL_XLSX = ".xlsx";
// 
//     String IMAGE_PNG = "png";
// 
//     String IMAGE_JPG = "jpg";
// 
//     String FILE_ZIP = ".zip";
//     String FILE_GZ = ".gz";
// 
// 
//     /**********************************************io流************************************************/
// 
//     int BUFFER_1024 = 1024;
// 
//     int BUFFER_512 = 512;
// 
//     String USER_DIR = "user.dir";
// 
//     /**********************************************tesseract for java语言字库************************************************/
// 
//     String ENG = "eng";
// 
//     String CHI_SIM = "chi_sim";
// 
// 
//     /**********************************************opencv************************************************/
//     String OPENCV_LIB_NAME_246 = "libs/x64/opencv_java246";
// 
//     String OPENCV_LIB_NAME_330 = "libs/x64/opencv_java330";
// }


import com.wind.common.Constants;
import javax.imageio.ImageIO;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
package com.wind.media;



/**
 * opencv图像处理工具类
 * @author wind
 */
public class ImageUtil {
    /**
     * 读取图片，获取BufferedImage对象
     * @param fileName
     * @return
     */
    public static BufferedImage getImage(String fileName){
        File picture = new File(fileName);
        BufferedImage sourceImg = null;
        try {
            sourceImg = ImageIO.read(new FileInputStream(picture));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sourceImg;
    }

    /**
     * 读取图片，获取ImageReader对象
     * @param fileName
     * @return
     */
    public static ImageReader getImageReader(String fileName){
        if(fileName != null){
            String suffix = "";
            for(String str : ImageIO.getReaderFormatNames()){
// Path: src/main/java/com/wind/common/Constants.java
// public interface Constants {
// 
//     /**********************************************分隔符常量************************************************/
// 
//     String POINT_STR = ".";
// 
//     String BLANK_STR = "";
// 
//     String SPACE_STR = " ";
// 
//     String NEWLINE_STR = "\n";
// 
//     String SYS_SEPARATOR = File.separator;
// 
//     String FILE_SEPARATOR = "/";
// 
//     String BRACKET_LEFT = "[";
// 
//     String BRACKET_RIGHT = "]";
// 
//     String UNDERLINE = "_";
// 
//     String MINUS_STR = "-";
// 
// 
// 
//     /**********************************************编码格式************************************************/
// 
//     String UTF8 = "UTF-8";
// 
// 
//     /**********************************************文件后缀************************************************/
// 
//     String EXCEL_XLS = ".xls";
// 
//     String EXCEL_XLSX = ".xlsx";
// 
//     String IMAGE_PNG = "png";
// 
//     String IMAGE_JPG = "jpg";
// 
//     String FILE_ZIP = ".zip";
//     String FILE_GZ = ".gz";
// 
// 
//     /**********************************************io流************************************************/
// 
//     int BUFFER_1024 = 1024;
// 
//     int BUFFER_512 = 512;
// 
//     String USER_DIR = "user.dir";
// 
//     /**********************************************tesseract for java语言字库************************************************/
// 
//     String ENG = "eng";
// 
//     String CHI_SIM = "chi_sim";
// 
// 
//     /**********************************************opencv************************************************/
//     String OPENCV_LIB_NAME_246 = "libs/x64/opencv_java246";
// 
//     String OPENCV_LIB_NAME_330 = "libs/x64/opencv_java330";
// }


// Path: src/main/java/com/wind/media/ImageUtil.java
import com.wind.common.Constants;
import javax.imageio.ImageIO;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;

package com.wind.media;



/**
 * opencv图像处理工具类
 * @author wind
 */
public class ImageUtil {
    /**
     * 读取图片，获取BufferedImage对象
     * @param fileName
     * @return
     */
    public static BufferedImage getImage(String fileName){
        File picture = new File(fileName);
        BufferedImage sourceImg = null;
        try {
            sourceImg = ImageIO.read(new FileInputStream(picture));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sourceImg;
    }

    /**
     * 读取图片，获取ImageReader对象
     * @param fileName
     * @return
     */
    public static ImageReader getImageReader(String fileName){
        if(fileName != null){
            String suffix = "";
            for(String str : ImageIO.getReaderFormatNames()){
                if(fileName.lastIndexOf(Constants.POINT_STR + str) > 0){