How to capture video from webcam(in java)?

37,383

Solution 1

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

Solution 2

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.

Solution 3

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.

Share:
37,383
Ishan
Author by

Ishan

Hello i am into ASP.net C#/ Sharepoint development and constantly learning in order to expertise in the field.

Updated on September 16, 2020

Comments

  • Ishan
    Ishan almost 4 years

    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?