How to detect and capture video from webcam in java? - java

I tried programming a application that detects and captures video from webcam. I use JMF 2.1 and JDK 1.7u5 but when I compile and run my application, it couldn't detect any devices. And then, I tried with JMyron but it is not supported in x64 (My OS is Win 7 x64).
Can you tell me why? and how to capture video from webcam in my java application?
Thanks for your help!

JMF 2.1.1e works with a 64 bit JDK/JRE. I tested it on Windows 7 x64. Assuming the webcam drivers are installed properly and you could also test it with an alternative application such as Skype just to make sure it works, then you are set to verify your JMF installation.
Start JMStudio and go to the 'File->Preferences' menu. That brings up the JMF registry editor. Go to the 'Capture Devices' tab and click on 'Detect Capture Devices'. That should bring up your webcam in the list. It would be listed as 'WDM Image Capture' or something similar. Please note that if you want to commit something then you should have launched JMStudio with administrative privileges.
You can capture videos or take snapshots using your webcam by selecting the 'File->Capture' menu (Ctrl-P).
Your application should be able to use JMF and work with your webcam if the above works unless you forget to include the correct libraries or miss something in your code.

I know you might not want this, but I would recommend using HTML5 instead for capturing, recording or streaming videos. Have a look at http://www.html5rocks.com/en/tutorials/getusermedia/intro/ and hopefully you could make it out iff your requirement allows.
HTML5 has a lot of things to offer which can easily be achievable.

Related

Can't get VLCJ CaptureTest to work

I need to be able to record from my webcam in the Java application I'm programming. I've tried JMF but couldn't get the Capture Device (it only saw the audio devices). Right now I'm trying with VLCJ and it just doesn't work. If I open the VLC Player I can access the camera with no problem at all, so I know my webcam works because and that I should be able to make it work through VLCJ. I just don't know how.
The code is the same in the CaptureTest.java file available here:
http://code.google.com/p/vlcj/wiki/SimpleExamples
all I did was try it with a String "dshow://" as mrl.
Im on Windows 7, JDK 1.6, VLC 2.1 and Netbeans 7.1
Any ideas?
Thank you very much to anyone who can help me out here.
Are all of the components 32-bit? (Windows, Java 6, & VLC). It should also work if all components are 64-bit, but this user was only able to get things working after after switching everything to 32-bit:
Device Capture with VLCJ

Which Java library to use for record a video from a connected camera?

You would have thought that tere is a simple solution to this but there isn't :(
My application needs to capture a stream from a USB/firewire (or whatever is the connection) connected camera (result would be a file like output.flv). I would prefer that I can detect all connected cameras and choose which one to use (one or more at the same time --> one or more output files). Application has to be cross platform.
Found libraries:
Xuggle - not very good camera support. Good for manipulating over images and video.
JMF - an old API but if I can use it, I will. I don't see a MAC OS X link on downloads page.
FMJ - looks like a better version of JMF but a can't find a way of installing it.
LTI-CIVIL - FMJ uses it. It looks like it only captures images from camera (not video). I could use Xuggle to create a video from images taken from LTI-CIVIL. And like FMJ, it is difficult to install.
What are your suggestions on this one?
I'd recommend VLCj for this - it should be able to stream from webcams onto a Java canvas without any difficulties. It uses native code so you need to provide libvlc.so / dll but from there on it should work on all the major platforms (Windows, Mac, Linux).
You may need to look at out of process players for complete reliability which is a bit more complex (see here for my efforts so far) but once you've got that in place it should work fine.
There really is no good camera support for Java. You will have to use native code, tailored for each platform, through JNI to get video capture for your project.
There's a related question here. Basically they're suggesting OpenCV wrapped with JNI.

Java video cross platform is a nightmare, is there any freedom for this?

What actually exist to solve Java Video ? It does not work in my linux box, JMF cant detect even my webcam. ex: http://i.stack.imgur.com/Vic0o.png
JMF - works in Mac, i guess no ? Cause in CentOS/Fedora it does not detects my Video camera.
FMJ - ? Does those requires native separate installation ?
LTI-civil ? Does those requires native separate installation ?
Xuggler ? Does those requires native separate installation ?
My most important feature is: Can i use other java video libraries to make eye contacts video frame, means 1 screen from (Sender, Receiver, Third party) 3 to 4 participant in 1 video screen.
Follow up:
Java video does not work: http://i.stack.imgur.com/d6f5V.png
I am now wondering so many years Java remains but Video they didnt completed yet.
Where Adobe Flex/Air is just a few lines of code and its done (still experts dont belive in Flex/Air, i must research why, maybe quality issue and restricted raw access).
Cant figure it out in my small brain about Java and its Video solution.
Many more reason ... researching...
Will, Appreciate more advise!
JMF is sadly neglected from Sun, and FMJ was started to rectify this. I would start with FMJ and see how it works for you.
dsj - DirectShow is also a good choice and dont need a separate installation.
http://www.humatic.de/htools/dsj.htm

JMF Registry could not add item (Vista)

I'm using JMF to capture video stream (webcam) on my Java project.
The camera I'm using is recognized by JMF (JFMStudio) and I manage to get the video stream.
However, on JMF Registry Editor - there's a list of available capture devices, when I click "Add" on one of the items (including the one I need) I get a "Could not add item" error.
Therefore this camera is not set in the registry of it (god know where) and later on it is not recognized by my project:
RGBFormat fmt = new RGBFormat(); // could be YUV - doesn't matter
Vector v = CaptureDeviceManager.getDeviceList(fmt);
v is empty (while I know the video source is recognized by Java , since I manage to get video on JMF Studio).
Now, this happens only on Vista (where else) and not on XP.
I have a suspiction that somehow Vista security blocks Java from writing the registry file, but of course, I might be wrong.
One more comments: this is vfw:Microsoft WDM Image Capture(Win32):0 device.
Any idea ?
Directed at anyone else in future who encounters the same issue
i had the same problem and i realized that it was because my Java Media Framework was installed under "C:\Program Files" by default.
When I ran "jmfinit.exe" in \bin, I noticed I couldn't update the "jmf.properties" file
Error replicated below
Found device Microsoft WDM Image Capture (Win32)
Querying device. Please wait...
Exception on commit = java.io.FileNotFoundException: C:\Program Files\JMF2.1.1e\bin..\lib\jmf.properties (Access is denied)
I changed the security settings for the the JMF2.1.1e folder and everything works fine.
I'm pretty sure installing it somewhere else works too
Well I've used JMF on Vista to capture a webcam image, and it worked. I did not use the JMF Studio though, so can't be of much help on there.
I posted some sample code in this post, you might take a look and see if it'll run for you.

What can I use to connect Java to Video4Linux?

I need to talk to Video4Linux (to capture output from a webcam) on a debian system running on an armel system (OpenMoko). JavaMediaFramework won't work in this case as it only have x86 and AMD versions. The linux kernel is 2.6.24 (with the v4l drivers compiled in separatly) and I cannot upgrade it (as it is not available on my hardware.
I have been following closely a project called video4linux4java . I now works with a lot of drivers (therefore a lot of webcams & capture cards), and produces a JPEG-encoded stream of images captured from a video device. Recently, the author has added classes to report information on the video device itself (webcam, TV tuner, ...). It is simple to use and comes with some examples. One of them (used to test v4l4j) displays a video stream in a JFrame. I use v4l4j in my own app to capture frames from my Logitech Quickcam Sphere AF, and control the pan and tilt. Works Great !
Video 4 Linux devices should be accessible through a device file (like /dev/video).
So I think you can open the device you want to access as you would do with a normal file and then read the stream coming from it.
To have more info about the devices, the video format etc... just check V4L web site

Categories

Resources