Hallo,
ich hoffe ihr könnt mir weiterhelfen,
ich möchte gerne die bilder der kamera in (nahezu) echtzeit auswerten,
dazu hab ich mir eine funktion geschrieben, die mir die bilder von der kamera holt,
leider braucht diese funktion für ein Bild über 1s, geplant waren aber etwa 15-30fps.
Hier ist die Funktion,
wie krieg ich das hin?
Achja, irgendwie glaub ich das diese Funktion irgendwie die Handyfunktion für das Standbildmachen verwendet, weil ich etwa im sekundentakt dieses verschluss-imitations-geräusch höre.
mfg,
-KlinCh
ich hoffe ihr könnt mir weiterhelfen,
ich möchte gerne die bilder der kamera in (nahezu) echtzeit auswerten,
dazu hab ich mir eine funktion geschrieben, die mir die bilder von der kamera holt,
leider braucht diese funktion für ein Bild über 1s, geplant waren aber etwa 15-30fps.
Hier ist die Funktion,
wie krieg ich das hin?
Java:
public class Util {
static Image image = null;
static Player player = null;
static VideoControl videoControl = null;
//static CameraControl cameraControl = null;
static Canvas canvasForControls=null;
static boolean isInitalized =false;
//Initialize the camera
public static void init(Canvas canvas) {
isInitalized=true;
canvasForControls = canvas;
try {
// Start and initialize a player to get a image
player = Manager.createPlayer("capture://video");
player.addPlayerListener(null);
player.start();
player.prefetch();
player.realize();
} catch (MediaException me) {
me.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("ok, player created");
Control[] supportedControls = player.getControls();
//Find the necessary Controls
for (int i = 0; i < supportedControls.length; i++) {
// if (supportedControls[i] instanceof CameraControl) {
// cameraControl = (CameraControl) supportedControls[i];}
if (supportedControls[i] instanceof VideoControl) {
videoControl = (VideoControl) supportedControls[i];
}
}
System.out.println("ok, found the nece. controls");
//cameraControl.setStillResolution(cameraControl.getSupportedStillResolutions()[0]);
videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, canvasForControls);
}
public static Image getSnapshot() {
try {
//System.out.println(System.getProperty("video.snapshot.encodings"));
//176 x 144
byte[] raw = videoControl.getSnapshot(null);
image = Image.createImage(raw, 0, raw.length);
} catch (MediaException ex) {
ex.printStackTrace();
}
return image;
}
}
Achja, irgendwie glaub ich das diese Funktion irgendwie die Handyfunktion für das Standbildmachen verwendet, weil ich etwa im sekundentakt dieses verschluss-imitations-geräusch höre.
mfg,
-KlinCh