1
我正在關注的OpenIMAJ教程,當我運行下面的代碼:OpenIMAJ和圖像讀取異常
import java.io.IOException;
import java.net.URL;
import org.openimaj.image.ImageUtilities;
import org.openimaj.image.MBFImage;
import org.openimaj.image.colour.ColourSpace;
import org.openimaj.image.colour.RGBColour;
public class App {
public static void main(String[] args) throws IOException {
MBFImage image = ImageUtilities.readMBF(new URL("http://dl.dropbox.com/u/8705593/sinaface.jpg"));
System.out.println(image.colourSpace);
}
}
我得到以下異常:
Exception in thread "main" java.io.IOException: org.apache.sanselan.ImageReadException: Can't parse this format.
at org.openimaj.image.ExtendedImageIO.read(ExtendedImageIO.java:189)
at org.openimaj.image.ExtendedImageIO.read(ExtendedImageIO.java:238)
at org.openimaj.image.ImageUtilities.readMBF(ImageUtilities.java:381)
at somefolder.App.main(App.java:37)
Caused by: org.apache.sanselan.ImageReadException: Can't parse this format.
at org.apache.sanselan.Sanselan.getImageParser(Sanselan.java:621)
at org.apache.sanselan.Sanselan.getBufferedImage(Sanselan.java:1260)
at org.apache.sanselan.Sanselan.getBufferedImage(Sanselan.java:1163)
at org.apache.sanselan.Sanselan.getBufferedImage(Sanselan.java:1136)
at org.openimaj.image.ExtendedImageIO.read(ExtendedImageIO.java:187)
... 3 more
有誰知道我可以解決這個問題?謝謝。
編輯:如果我下載圖像並從文件系統中讀取它,它的工作原理。不過,我想了解爲什麼從URL中讀取不起作用。
非常感謝。 – jgloves