Kamerabilder Auswertung in Echtzeit

KlinCh

Mitglied
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?
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
 

AmunRa

Gesperrter Benutzer
Najo hallo hatte vor circa 2 Monaten das Selbe Problem, hab aber auch nacher aufgegeben, weil man die Fotos die man Bekommt dann auch noch in Jpeg komprimiert bekommt naja und die Zeit auch zulange ist.

Es gibt aber einen Kleinen Umweg mit dem man dann sehr viel schneller an die Fotos kommt.

Such dazu einfach auf Google die Klasse SnapshotControl.mit der kannst du mehrer Bilder hintereinander machen. hat aber wieder ein großes Problem die Bilder werden direkt auf die Speicherkarte geschrieben und du musst sie daher von dort wieder laden. Andere Lösungen hab ich keine gefunden.

Und auch diese Bilder sind wieder JPEG komprimiert.
 
Ähnliche Java Themen

Ähnliche Java Themen

Neue Themen


Oben