Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rladstaetter/javacv-webcam
Display a videostream from your webcam with JavaFX and JavaCV
https://github.com/rladstaetter/javacv-webcam
java java11 javacv javafx maven opencv webcam webcamera
Last synced: 3 months ago
JSON representation
Display a videostream from your webcam with JavaFX and JavaCV
- Host: GitHub
- URL: https://github.com/rladstaetter/javacv-webcam
- Owner: rladstaetter
- License: apache-2.0
- Created: 2020-04-29T19:53:10.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-17T20:14:52.000Z (over 4 years ago)
- Last Synced: 2024-09-29T13:41:00.346Z (4 months ago)
- Topics: java, java11, javacv, javafx, maven, opencv, webcam, webcamera
- Language: Java
- Homepage: https://ladstatt.blogspot.com/2020/05/webcam-image-stream-with-javacv.html
- Size: 38.1 KB
- Stars: 28
- Watchers: 5
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# javacv-webcam
A project which shows how to use JavaFX together with OpenCV / JavaCV bindings.
This project can be used as a starting point for experiments with OpenCV and Java. It showcases the usage of the PixelBuffer API which permits a fast display / rendering of a webcam image stream with JavaFX.Furthermore it uses [javafx-maven-plugin](https://github.com/openjfx/javafx-maven-plugin) to generate a custom java image.
You will need at least [Java11](https://adoptopenjdk.net) and [Maven 3.6.2](https://maven.apache.org/) to build.
## Compile and run with javafx-maven-plugin
For a quick glimpse of what this project does just checkout the code and enter
mvn javafx:run -Djavacpp.platform.custom -Djavacpp.platform.host
Note: Providing javacpp properties is not mandatory, but it reduces download size for bytedeco significantly (only fetches
libs for your platform - remember to always provide those parameters though).
After downloading dependencies and compiling a window should appear with your webcam image stream.If you want to create a custom jre distribution, enter
mvn javafx:jlink -Djavacpp.platform.custom -Djavacpp.platform.host
which creates a custom JDK11 based distribution. You can start the application by entering./target/javacv-webcam/bin/jwebcam
If you peek into the ``javacv-webcam`` directory.Attention: If you are using Windows or Linux you'll have to adapt module-info.java to include native libraries of suitable for those platforms. On MacOsX, you may have problems with permissions to access your webcam from a java application, make sure to allow access in your system preferences.
## Compile and run with client-maven-plugin
This project contains also a configuration for compiling it to a native image using [GraalVM](https://www.graalvm.org/). You have
to download and install GraalVM in a recent version (I tested it with 20.2.0) and then compile and run it with following command:mvn clean client:build client:run -Djavacpp.platform.custom -Djavacpp.platform.host -Dgraalvm.home=/path/to/your/graalvm/distribution
After downloading necessary toolings, dependencies and compiling and linking (takes some time) a JavaFX application which uses
your webcam will start.## Links
- Have a look at [https://openjfx.io](https://openjfx.io) where you can find more information and introductory examples for developing JavaFX applications.
- [https://github.com/bytedeco/javacv](https://github.com/bytedeco/javacv) is the home of JavaCV which enables Java Developers to use native libraries like [OpenCV](https://opencv.org).
- Some posts on [http://ladstatt.blogspot.com/](https://ladstatt.blogspot.com) may be of interest, too.