开发者

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

This question already has answers here: Capturing image from webcam in java? (16 answers) 开发者_运维知识库 Closed 9 years ago.

I want to develop an application in java to capture video from webcam and store it onto a particular location.Can anyone provide me the working code?

What type(usb,ip etc..) of webcam is the best in order to develop the application.

Please help me. how to proceed?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜