Capture d'image à partir d'une vidéo sur J2ME

fleurette - Modifié par jee pee le 2/11/2013 à 18:34
KX Messages postés 16739 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 19 mai 2024 - 2 nov. 2013 à 18:38
Bonjour,
j'ai un programme sur J2ME qui prend des captures d'images à partir d'une vidéo en cours de lecture
ça marchait au début, sur le pc de l'école mais sur mon pc ça tourne pas.
voici le code

package CameraMIDlet;

import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.media.control.VideoControl;

public class CameraMIDlet extends MIDlet implements CommandListener {

private Display display;
private Form form,form2;
private Command exit,back,capture,camera;
private Player player;
private VideoControl videoControl;
private Video video;

public CameraMIDlet() {

exit = new Command("Exit", Command.EXIT, 0);
camera = new Command("Camera", Command.SCREEN, 0);
back = new Command("Back", Command.BACK, 0);
capture = new Command("Capture", Command.SCREEN, 0);
form2 = new Form("Play video");

form = new Form("Capture Video");
form.addCommand(camera);
form.setCommandListener(this);
}

public void startApp() {
display = Display.getDisplay(this);
Process process = new Process(this);
process.start();
}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command c, Displayable s) {
if (c == exit) {
destroyApp(true);
notifyDestroyed();
} else if (c == camera) {
display.setCurrent(form2);
} else if (c == back)
display.setCurrent(form);
else if (c == capture) {
video = new Video(this);
video.start();
}
}
class Process implements Runnable {
private CameraMIDlet MIDlet;

public Process(CameraMIDlet MIDlet) {
this.MIDlet = MIDlet;
}

public void run() {
try {
player = Manager.createPlayer("http://localhost/midp/shark.mpg"); // "capture://video" is used for S60 devices
//player = Manager.createPlayer("capture://image"); // "capture://image" is used for Series 40 devices
player.realize();

videoControl = (VideoControl)player.getControl("VideoControl");

form2.addCommand(back);
form2.addCommand(capture);
form2.setCommandListener(MIDlet);

if ( videoControl != null) {
form2.append((Item) videoControl.initDisplayMode( videoControl.USE_GUI_PRIMITIVE, null));

display.setCurrent(form2);
}

player.start();
} catch (IOException ioe) {} catch (MediaException me) {}
}

public void start() {
Thread thread = new Thread(this);
try {
thread.start();
} catch (Exception error) {
}
}


}



class Video extends Thread {
CameraMIDlet midlet;
public Video(CameraMIDlet midlet) {
this.midlet = midlet;
}

public void run() {
captureVideo();

}

public void captureVideo() {
try {
byte[] raw = videoControl.getSnapshot("encoding=jpeg");
Image image = Image.createImage(raw, 0, raw.length);
form.append(new ImageItem(null, image, ImageItem.LAYOUT_CENTER, null));
display.setCurrent(form);


} catch (MediaException me) { }
}
};
}

1 réponse

ça me génère une erreur
" Unable to create MIDlet CameraMIDlet
java.lang.ClassNotFoundException: CameraMIDlet
at com.sun.midp.midlet.MIDletState.createMIDlet(+14)
at com.sun.midp.midlet.Selector.run(+22)
"
est ce qu'il ya quelqu'un qui puisse m'aider ?
merci
0
KX Messages postés 16739 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 19 mai 2024 127
2 nov. 2013 à 18:38
Le package com.sun.midp.midlet.* ne fait pas partie des bibliothèques standards, tu dois l'ajouter explicitement pour que cela fonctionne. Il faut donc que tu récupères le même jar que celui configuré sur ton pc à l'école.
0
Rejoignez-nous