10
我正在嘗試檢索我的網絡攝像頭支持的可用圖片尺寸分辨率;使用OpenCV庫。我曾嘗試使用類似的Android問題/答案,但無濟於事。 (例如Android camera supported picture sizes)。這裏是我的代碼:網絡攝像頭支持的圖片尺寸
import org.opencv.highgui.VideoCapture;
import org.opencv.core.Size;
public class MyCameraCaptureClass {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
System.out.println("This program will display the webcam's supported sizes");
System.loadLibrary("opencv_java248"); //load .dll for the jar
VideoCapture vidCap0 = new VideoCapture(0);
if (vidCap0.isOpened()) {
System.out.println("Camera found, and it works so far...");
for (Size aSize : vidCap0.getSupportedPreviewSizes()) {
System.out.println("Doesn't print this at all");
System.out.println("Height:" + aSize.height + "Width:" + aSize.width);
}
}
vidCap0.release();
}
}
而且堆棧跟蹤是:
Exception in thread "main" java.lang.Exception: unknown exception
at org.opencv.highgui.VideoCapture.getSupportedPreviewSizes_0(Native Method)
at org.opencv.highgui.VideoCapture.getSupportedPreviewSizes(VideoCapture.java:478)
at webcam.MyCameraCaptureClass.main(MyCameraCaptureClass.java:19)
所有幫助將衷心感謝。
您能否提供異常的堆棧跟蹤? –
@Eugene Evdokimov - 只爲你:)) – Koffy
看來這是OpenCV中的一個bug,最近已經修復:http://code.opencv.org/issues/3387 –