gpt4 book ai didi

java捕获网络摄像头图像的macbook

转载 作者:行者123 更新时间:2023-11-29 05:30:39 25 4
gpt4 key购买 nike

我目前正在开始一个项目,我想从我的网络摄像头捕获和操作数据流,以便开始我想从我的网络摄像头拍摄一些照片并将这些照片显示给用户。然而,这给出了一个错误。

public class quicktest  implements Runnable {
public static void main(String[] args){
Thread t=new Thread(new quicktest());
t.start();
}

IplImage image;
CanvasFrame canvas = new CanvasFrame("Web Cam");
public quicktest() {
canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
}
@Override
public void run() {
FrameGrabber grabber = new VideoInputFrameGrabber(0);

int i=0;
try {
grabber.start();
IplImage img;
while (true) {
img = grabber.grab();
if (img != null) {
cvFlip(img, img, 1);// l-r = 90_degrees_steps_anti_clockwise
// show image on window
canvas.showImage(img);
}
Thread.sleep(1000);
}
} catch (Exception e) {
}
}

这给出了以下异常:

Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: no jnivideoInputLib in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1764)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1044)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
at com.googlecode.javacpp.Loader.load(Loader.java:586)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.videoInputLib.<clinit>(videoInputLib.java:81)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
at com.googlecode.javacpp.Loader.load(Loader.java:561)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.videoInputLib$videoInput.<clinit>(videoInputLib.java:193)
at com.googlecode.javacv.VideoInputFrameGrabber.start(VideoInputFrameGrabber.java:101)
at com.googlecode.javacv.VideoInputFrameGrabber.start(VideoInputFrameGrabber.java:98)
at quicktest.run(quicktest.java:27)
at java.lang.Thread.run(Thread.java:695)

我已经搜索并尝试了建议的内容 here ,但是这给了我另一个错误:

at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
at com.googlecode.javacpp.Loader.load(Loader.java:561)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.videoInputLib$videoInput.<clinit>(videoInputLib.java:193)
at Main.main(Main.java:5)

有人知道怎么解决吗?顺便说一句,这发生在 macbook pro 10.7.5 上并尝试使用内置网络摄像头。虽然这绝对不重要,但也有一个 ocules 裂口。使用 OpenCVFrameGrabber给了我一个 java.lang.UnsatisfiedLinkError: no jniopencv_highgui in java.library.path 异常。

顺便说一句,如果有人知道另一种从我的网络摄像头获取图像到 java 中的简单方法,那将会有所帮助。

按照 benny.la 所说的去做,我不会得到一个

线程“Thread-3”中的异常 java.lang.UnsatisfiedLinkError:java.library.path 中没有 jnivideoInputLib

at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1764)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1044)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
at com.googlecode.javacpp.Loader.load(Loader.java:586)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.videoInputLib.<clinit>(videoInputLib.java:81)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
at com.googlecode.javacpp.Loader.load(Loader.java:561)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.videoInputLib$videoInput.<clinit>(videoInputLib.java:193)
at com.googlecode.javacv.VideoInputFrameGrabber.start(VideoInputFrameGrabber.java:101)
at com.googlecode.javacv.VideoInputFrameGrabber.start(VideoInputFrameGrabber.java:98)
at quicktest.run(quicktest.java:29)
at java.lang.Thread.run(Thread.java:695)

异常。

最佳答案

By the way if anyone knows another easy way to get images from my webcam into java that would be helpful to.

因为你在 macbook 上,你可以这样做:

Runtime.getRuntime().exec("screencapture tempfile.jpg");
InputStream in = new FileInputStream("tempfile.jpg");

关于java捕获网络摄像头图像的macbook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21186550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com