Java 支持网络摄像头的图片大小
我正在尝试检索我的网络摄像头支持的可用图片大小分辨率;使用OpenCV库。我尝试过使用类似的Android问答系统,但没有效果。(例如)。这是我的密码:Java 支持网络摄像头的图片大小,java,android,opencv,Java,Android,Opencv,我正在尝试检索我的网络摄像头支持的可用图片大小分辨率;使用OpenCV库。我尝试过使用类似的Android问答系统,但没有效果。(例如)。这是我的密码: import org.opencv.highgui.VideoCapture; import org.opencv.core.Size; public class MyCameraCaptureClass { public static void main(String[] args) { System.out.println("H
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)
衷心感谢您的帮助。如评论中所述,这是一个报告的错误,已被列为2.4.9的更正:
- 在VideoCapture.cpp文件中:
return env->NewStringUTF(u.name);
// VideoCapture::get can return 0.0 or -1.0 if it doesn't support
// CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING
if (u.prop != 0.0 && u.prop != -1.0)
return env->NewStringUTF(u.name);
与:
return env->NewStringUTF(u.name);
// VideoCapture::get can return 0.0 or -1.0 if it doesn't support
// CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING
if (u.prop != 0.0 && u.prop != -1.0)
return env->NewStringUTF(u.name);
你能提供异常的堆栈跟踪吗?@Eugene Evdokimov-只为你:))这似乎是OpenCV中的一个bug,最近已经修复了:我检查了另一个链接,它说他们应该用v2.4.9发布修复程序。现在我可以休息了,非常感谢:)对于500rep悬赏来说太糟糕了:)