How to capture video from webcam(in java)? [duplicate]

南笙酒味 提交于 2019-12-01 08:54:38

Check out David's solution using JMF: http://www.mutong.com/fischer/java/usbcam/

I would recommend using webcam-capture project (I'm the author). There is a example of how to record video from webcam device - you can find it here. This project can handle embedded camera device as well as those connected to USB or IP cameras. It is working on most operating systems (Windows XP, Vista, 7, 8, Linux, Mac OS, Raspbian, etc) and you don't have to install any additional software to run it. The choice is yours.

I would not recommend using JMF - is completely outdated and you have to install it on your PC first, so if you consider your application to be portable, you have to have this in your mind too.

I found that the best way is by using the JMyron library with a USB webcam. You will have to mess around with the dll's though because it uses native code... there's a working example somewhere if you google for it (I don't know exactly where) but I know that you need the dll's in your path. Download the Processing library and find the dll's and the jar.

import JMyron.JMyron;

//initializer
int width=100;//insert your numbers here
int height=100;
JMyron jmyron = new JMyron();
jmyron.start(width,height);
//in a loop
jmyron.update();
int[] image = jmyron.image();

image will be an int[] with length width*height. it stores the pixels row-by-row, so the first width pixels will be the first row, the second width pixels will be the second row, and so on.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!