diff --git a/src/main/java/org/myrobotlab/service/OpenCV.java b/src/main/java/org/myrobotlab/service/OpenCV.java index 7abc45de8b..ba1edc8f93 100644 --- a/src/main/java/org/myrobotlab/service/OpenCV.java +++ b/src/main/java/org/myrobotlab/service/OpenCV.java @@ -55,6 +55,8 @@ import javax.imageio.ImageIO; import javax.imageio.stream.MemoryCacheImageOutputStream; +import org.bytedeco.ffmpeg.global.avcodec; +import org.bytedeco.javacpp.avutil; import org.bytedeco.javacv.CanvasFrame; import org.bytedeco.javacv.FFmpegFrameRecorder; import org.bytedeco.javacv.Frame; @@ -148,6 +150,8 @@ public class OpenCV extends AbstractComputerVision implements Imag int vpId = 0; transient CanvasFrame canvasFrame = null; + + transient FFmpegFrameRecorder recorder = null; class VideoProcessor implements Runnable { @@ -168,6 +172,44 @@ synchronized public void run() { lengthInTime = grabber.getLengthInTime(); log.info("grabber {} started - length time {} length frames {}", grabberType, lengthInTime, lengthInFrames); + // create recorder + recorder = new FFmpegFrameRecorder("output.flv", grabber.getImageWidth(), grabber.getImageHeight()); + // recorder.setFormat("mp4"); + recorder.setFormat("flv"); + +// recorder.setFormat("ogg"); // Set the output format to Ogg +// recorder.setVideoCodec(avcodec.AV_CODEC_ID_THEORA); // Set the video codec to Theora +// recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); // Set pixel format +// +// recorder.setVideoCodec(avcodec.AV_CODEC_ID_THEORA); // Set the video codec to Theora +// recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); // Set pixel format +// recorder.start(); +// +// recorder.start(); + +// h264 +// recorder.setFormat("mp4"); +// recorder.setVideoQuality(10); +// recorder.setFrameRate(grabber1.getFrameRate()); +// recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264); + + + + + // webm +// recorder.setVideoCodecName("libvpx-vp9"); +// recorder.setFormat("webm"); +// recorder.setPixelFormat(org.bytedeco.javacv.Frame.DEPTH_UBYTE); + // recorder.setFrameRate(frameRate); + + + // not sure what this is .. but it works + // recorder.setFormat("ffm"); + + + recorder.start(); + + // Wait for the Kinect to heat up. int loops = 0; while (grabber.getClass() == OpenKinectFrameGrabber.class && lengthInFrames == 0 && loops < 200) { @@ -197,6 +239,8 @@ synchronized public void run() { ++frameIndex; data = new OpenCVData(getName(), frameStartTs, frameIndex, newFrame); + + recorder.record(newFrame); if (grabber.getClass().equals(OpenKinectFrameGrabber.class)) { // by default this framegrabber returns video @@ -1214,6 +1258,7 @@ private void processVideo(OpenCVData data) throws org.bytedeco.javacv.FrameGrabb BufferedImage b = data.getDisplay(); SerializableImage si = new SerializableImage(b, displayFilter, frameIndex); invoke("publishDisplay", si); + // sleep(1000); if (webViewer) { // broadcast(???) @@ -2085,8 +2130,8 @@ public static void main(String[] args) throws Exception { // Runtime.start("python", "Python"); OpenCV cv = (OpenCV) Runtime.start("cv", "OpenCV"); - OpenCVFilter fr = new OpenCVFilterFaceRecognizer("fr"); - cv.addFilter(fr); +// OpenCVFilter fr = new OpenCVFilterFaceRecognizer("fr"); +// cv.addFilter(fr); // OpenCVFilterTracker tracker = new OpenCVFilterTracker("tracker"); // cv.addFilter(tracker); // OpenCVFilterLKOpticalTrack lk = new OpenCVFilterLKOpticalTrack("lk"); diff --git a/src/main/java/org/myrobotlab/service/ServoMixer.java b/src/main/java/org/myrobotlab/service/ServoMixer.java index dc6c3f7127..03395f6cc6 100755 --- a/src/main/java/org/myrobotlab/service/ServoMixer.java +++ b/src/main/java/org/myrobotlab/service/ServoMixer.java @@ -676,14 +676,24 @@ public void stopService() { public static void main(String[] args) throws Exception { try { + LoggingFactory.init("WARN"); + + WebGui webgui = (WebGui) Runtime.create("webgui", "WebGui"); + webgui.autoStartBrowser(false); + webgui.startService(); + + + boolean done = true; + if (done) { + return; + } + + Runtime.main(new String[] { "--id", "admin"}); LoggingFactory.init("INFO"); Runtime.start("i01.head.rothead", "Servo"); Runtime.start("i01.head.neck", "Servo"); - WebGui webgui = (WebGui) Runtime.create("webgui", "WebGui"); - webgui.autoStartBrowser(false); - webgui.startService(); Python python = (Python) Runtime.start("python", "Python"); ServoMixer mixer = (ServoMixer) Runtime.start("mixer", "ServoMixer"); } catch (Exception e) { diff --git a/src/main/java/org/myrobotlab/service/config/InMoov2Config.java b/src/main/java/org/myrobotlab/service/config/InMoov2Config.java index 3082aa2819..d48554891b 100644 --- a/src/main/java/org/myrobotlab/service/config/InMoov2Config.java +++ b/src/main/java/org/myrobotlab/service/config/InMoov2Config.java @@ -536,11 +536,11 @@ public Plan getDefault(Plan plan, String name) { listeners.add(new Listener("publishPlayAudioFile", getPeerName("audioPlayer"))); - // service --to--> service + // service --to--> service ServoMixerConfig servoMixer = (ServoMixerConfig) plan.get(getPeerName("servoMixer")); servoMixer.listeners = new ArrayList<>(); - servoMixer.listeners.add(new Listener("publishText", name + ".mouth", "onText")); - + servoMixer.listeners.add(new Listener("publishText", getPeerName("mouth"), "onText")); + // remove the auto-added starts in the plan's runtime RuntimConfig.registry