且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将网络摄像头与java集成?

更新时间:2023-02-07 15:19:34

JMF太糟糕了!它已经过时了,不再维护,而且非常复杂。我能说的唯一好处就是它非常快。



我是开源的作者 网络摄像头捕获 项目可在Github上获得。它的目标是让用户直接从Java代码访问内置或USB连接的网络摄像头,与网络或IP摄像头相同。您不需要实现任何其他软件(如果是JMF必须这样做),它可以独立运行。它非常快 - 在我的情况下,我能够在BufferedImage对象中传输250 FPS。



我在网络摄像头捕获中提供的API非常简单,有很多例子,因此,您可以开始开发您的应用程序,并且不关心它是否适用于Linux,Windows或Mac OS。网络摄像头捕获将在任何地方运行。



这是一个简单的代码。假设您有两台摄像机连接到您的PC(当然,您只能有一台)。



JMF sucks! It's completely outdated, not maintained any more and terribly complicated. The only good thing I can say about it is the fact it is pretty fast.

I'm the author of open source Webcam Capture project available on Github. It s goal is to give users access to build-in or USB connected webcams, same as for network or IP cameras, directly from Java code. You don't need to implement any additional software (as you have to do in case of JMF), it works standalone. It's pretty fast - in my case I was able t stream 250 FPS in BufferedImage objects.

The API I provided in Webcam Capture is really simple, there are many examples, so you can start developing your app and don;t care if it will be working on Linux, Windows, or Mac OS. Webcam Capture will run everywhere.

Here is a simple code. Assume you have two cameras connected to your PC (but of course, you can have only one).

Webcam buildin = Webcam.getWebcams().get(0); // build-in laptop camera
Webcam usb = Webcam.getWebcams().get(1); // usb camera
BufferedImage image1 = buildin.getImage();
BufferedImage image2 = usb.getImage();
// do with image1 and image2 whatever you want


希望 this [ ^ ]会给你一个想法。
Hope this[^] will give you an idea.