My question is exactly as the title states. I've spent some time googling and all I can find are recommendations to use external libraries. However, I'd like to do this without using any external libraries and documentation is lacking on how to go about this.
I'm afraid it is not possible. The two main approaches in java is to use either JMF or openCV. JavaFX has no plan to develop a Webcam API so it is not going to change soon.
You should look at this question: How can I take image at webcam with javaFX at win7 64bit?
Here is a link to javafx + opencv integration: http://ladstatt.blogspot.fr/2013/04/using-isight-camera-with-javafx.html
JavaFX + JMF does not seem to work now: Webcam access from JavaFx
But there is hope with JavaFX 8: https://github.com/carldea/WebcamFX
Not possible without external libs unless you depend on JNI. Period.
In the past I got good results using JTwain-based solutions.
Related
i need to implement crop operation over a Video,is there any builtin class or third party library available or is there any alternate approach. I already had a walkthrough from android developer to Mr.Google !
As far as I know android has no built in API's for those video manipulations. I recommend FFMPEG. Go through this tutorial once. I have used xuggler with java swing. It served well and I think it might help you.
i am trying to capture video from my /dev/video1 usb camera using java, i was wondering as to how to actually do this? my project is supposed to capture the video and stream it to another computer. is it also possible to set up an avconv server using java?
Java does not have an extensive support for media. You can use GStreamer JNI bindings for this or switch to QT or native C/C++ GStreamer.
It's already been done for you so you might take a look into the existing projects.
v4l4j wouble be a great place to start.
update
As Andy Ross commented the library I linked is very low level and you may be looking into something more easy to use as gstreamer-java.
There are many questions on SO on how to read images from webcams in Java, but judging by the answers there does not seem to be a library which is actively developed and maintained.
My question is if it would make any difference if I limited the OS to Linux only? I know there's a device representing video, /dev/video0, can that be used for reading image data from a webcam using java.io somehow?
Thanks in advance!
EDIT:
If you want to do something with the image, get opencv and its bindings, http://ubaa.net/shared/processing/opencv/
The page also has a link for Java example programs.
OLD_ANSWER:
You can use vlc, it has webcam support.
As far a Java is concerned, take a look the VLCJ project for the bindings.
http://code.google.com/p/vlcj/
For the OS bit of your question, on Linux webcam is implemented via v4l (video for linux) , but as far as I think, it won't be an issue for having it cross platform.
You could run a command (external program, started from your Java code) which is handling the video reading of the webcam. But what do you want to do with the video stream?
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.
How can I get video and audio streams from web cameras with Java (in a cross-platform way)?
For example, we have a computer with 3-4 USB web cameras; we want to get their streams and make them visible in the user interface. How can we perform such a thing? I need code for a simple app which would find ALL cameras on the computer and let us select camera to wach. Can any one, please share such one?
With java media framework JMF or FMJ
Here is an example with JVM
I see your comment about the solution needing to be "pure" java, but this is really "nearly" impossible. You will need to use some sort of native library for accessing the devices, with that being stated; I suggest that you look at Xuggler as your solution. Xuggler supports Windows, Mac, and Linux and they also offer example code for handling audio and video. Lastly the library is FREE.
Webcam capture example: http://xuggle.googlecode.com/svn/trunk/java/xuggle-xuggler/src/com/xuggle/xuggler/demos/DisplayWebcamVideo.java
While Xuggle does not have an example of microphone capture, you can find samples on the mailing list or you could use code written by the packet-mulitbroadcaster project found here: https://code.google.com/p/packet-multibroadcaster/
You can try my solution. It uses OpenCV to capture the image and jetty server to transmit it via WebSocket. The example has three classes and it will be easy to understand.
Now I can send only video, but I'm working on audio aswell.
I'd use flex. It can be relatively easily integrated with java backend.
UPD:
Pure Java needed
Then you should consider JavaFX solutions. I'm not a big expert in javafx, I've only written some basic test applications, but I'm sure it's a modern way of solving described problem with pure java.