尽管当我使用 HighGUI.imread() 读取时,提供的路径中的图像存在于 HD 上,大小 = 120*80,但返回的图像大小为 0 * 0
代码:
public class ROI {
static final String PATH_0 = [omitted]///A full path to an image actually existing on my machine
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat imgOriginal = Highgui.imread(PATH_0);// this image is 128*80
showInFrame(imgOriginal);
system.out.printlin(imgOriginal.size());// results 0 * 0
}
private static void showInFrame(Mat mat) {
// TODO Auto-generated method stub
JFrame mediaFrame = new JFrame("Media");
mediaFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/*JLabel mediaPanel = new JLabel();
mediaFrame.setContentPane(mediaPanel);*/
Highgui.imwrite("c:/private/img.jpg", mat);
ImageIcon image = new ImageIcon("c:/private/img.jpg");
JLabel label = new JLabel("label", image, JLabel.CENTER);
mat.release();
mediaFrame.setSize(300,300);
mediaFrame.add(label);
mediaFrame.setVisible(true);
mediaFrame.validate();
}