These days I’ve been experimenting with java (though I’ve always tried to avoid it) due to a client request for a development project.
Java development tools are not entirely ugly as I thought, in fact I found it very productive to develop here, quickly made a desktop application that connected to MySQL to query and save records in a couple of days, But my problem started when trying to run the webcam, I thought that a language like java could have many ways to do this and I was right, but many things are outdated or do not work, for example it seemed logical to use the gstreamer project and the java bridge, but the project is outdated since 2011.
After many tests, I have good results using the library opencv, I know, using opencv to handle a webcam is a very simple operation for all the things that makes this library however was where I could get everything working well I thought it easier to implement that would allow me to operate the same in Windows or mac OSX with just installing opencv on that platform (java is really multiplatform?).
I made a demo code and NetBeans project using pieces of code I found on the Internet and making it work as wanted in a swing frame displaying the video on a JLabel and also lets you shoot video with the push of a button, the code can be downloaded here:
To run the code must have opencv installed (available from the official repositories of any linux distribution) and you must load javacv .jar files too to library project path in to Netbeans, don’t worry much about the jar, the code show errors in to Netbeans if you not load the .jar files, this files are needed to you can run the project without errors.
I hope they can help, any doubt please use the comments, otherwise this code is not meant to be more than it is (a demo), so any improvement is welcome but do not think that will be implemented directly in the code.