Created
April 7, 2013 19:04
-
-
Save rladstaetter/5331985 to your computer and use it in GitHub Desktop.
A small JavaFX application which shows an image taken by the isight camera using imagesnap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package net.ladstatt.apps.isight | |
| import java.io.InputStream | |
| import javafx.application.Application | |
| import javafx.scene.Group | |
| import javafx.scene.Scene | |
| import javafx.scene.image.Image | |
| import javafx.scene.image.ImageView | |
| import javafx.stage.Stage | |
| object HelloIsight { | |
| def main(args: Array[String]): Unit = { | |
| Application.launch(classOf[HelloIsight], args: _*) | |
| } | |
| } | |
| class HelloIsight extends javafx.application.Application { | |
| // this can get more complicated if you use a "native" approach | |
| // using a jni based solution | |
| // see http://iharder.sourceforge.net/current/macosx/imagesnap/ | |
| def snapIt: InputStream = { | |
| val runtime = Runtime.getRuntime() | |
| val process = runtime.exec(Array("/opt/local/bin/imagesnap", "-")) | |
| process.getInputStream() | |
| } | |
| override def start(stage: Stage): Unit = { | |
| stage.setTitle("Webcam snapshot") | |
| val group = new Group | |
| val imageView = new ImageView(new Image(snapIt)) | |
| group.getChildren.add(imageView) | |
| val scene = new Scene(group) | |
| stage.setScene(scene) | |
| stage.show() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment