Search in sources :

Example 1 with Range

use of org.opencv.core.Range in project Frankenstein by olir.

the class ProcessingSceneController method updateDuration.

private void updateDuration() {
    Range r = currentRange();
    if (r != null) {
        Platform.runLater(() -> {
            l_durationFrames.setText("" + (r.end - r.start + 1));
            l_durationTime.setText("" + time((r.end - r.start) / fps));
            l_durationTitle.setVisible(true);
            l_durationTime.setVisible(true);
            l_durationFrames.setVisible(true);
        });
    } else {
        Platform.runLater(() -> {
            l_durationTitle.setVisible(false);
            l_durationTime.setVisible(false);
            l_durationFrames.setVisible(false);
        });
    }
}
Also used : Range(org.opencv.core.Range)

Example 2 with Range

use of org.opencv.core.Range in project Frankenstein by olir.

the class ProcessingSceneController method drawEditCanvas.

public void drawEditCanvas() {
    if (frames > 0) {
        GraphicsContext gc = editCanvas.getGraphicsContext2D();
        // Time in seconds at position
        // double t = (position - 1) / fps;
        // Total time in seconds
        double tt = (frames - 1) / fps;
        // Background
        try {
            gc.setFill(rootBorder.getBackground().getFills().get(0).getFill());
        } catch (Exception e) {
            gc.setFill(Color.WHITE);
        }
        gc.fillRect(0, 0, editCanvas.getWidth(), editCanvas.getHeight());
        if (taskErrorMessage != null) {
            gc.setFill(Color.DARKRED);
            gc.fillText(taskErrorMessage, 10, 16, 900);
            return;
        } else if (processingRunning) {
            // Task Progress
            if (taskPosition != -1) {
                int x = (int) ((editCanvas.getWidth() - 1) * taskPosition / ((double) frames - 1) * fps);
                // System.out.println("taskPosition "+taskPosition+" "+x);
                gc.setFill(Color.DARKGREEN);
                gc.fillRect(0, 0, x, 2);
                gc.setFill(Color.BLACK);
                gc.fillText(taskMessage, 10, 16, 900);
            } else {
                // Video Progress
                int x = (int) ((editCanvas.getWidth() - 1) * (position - 1) / (frames - 1));
                gc.setFill(Color.DARKOLIVEGREEN);
                gc.fillRect(0, 0, x, 2);
                gc.setFill(Color.BLACK);
                gc.fillText("Processing Video", 10, 16, 900);
            }
        } else {
            // Show Segments
            // Base color
            gc.setFill(Color.LIGHTGRAY);
            gc.fillRect(0, 3, editCanvas.getWidth(), 6);
            // Visualize Filter ranges
            gc.setFill(Color.CADETBLUE.deriveColor(1.0, 1.0, 1.0, 0.5));
            for (FilterElement fe : filterListData) {
                int x = (int) ((editCanvas.getWidth() - 1) * (fe.r.start - 1) / (frames - 1));
                int w = (int) ((editCanvas.getWidth() - 1) * (fe.r.end - fe.r.start) / (frames - 1));
                if (w < 2)
                    w = 2;
                gc.fillRect(x, 3, w, 6);
            }
            // Visualize selectedFilter
            if (selectedFilter != null) {
                gc.setFill(Color.DODGERBLUE);
                int x = (int) ((editCanvas.getWidth() - 1) * (selectedFilter.r.start - 1) / (frames - 1));
                int w = (int) ((editCanvas.getWidth() - 1) * (selectedFilter.r.end - selectedFilter.r.start) / (frames - 1));
                if (w < 2)
                    w = 2;
                gc.fillRect(x, 3, w, 6);
            }
        }
        if (seeking && seekPos > 0) {
            // Seek running
            int x = (int) ((editCanvas.getWidth() - 1) * (seekPos - 1) / (frames - 1));
            gc.setFill(Color.RED);
            gc.fillRect(0, 0, x, 2);
        }
        // Time Ruler
        double t1off = 1.0;
        double t2off = 0.1;
        int tlevel = 1;
        int ttlevel = 0;
        if (tt >= 10.0) {
            t1off = 10.0;
            t2off = 1.0;
            tlevel++;
        }
        if (tt >= 60.0) {
            t1off = 60.0;
            t2off = 10.0;
            tlevel++;
            ttlevel++;
        }
        if (tt >= 3600.0) {
            t1off = 3600.0;
            t2off = 900.0;
            tlevel++;
            ttlevel++;
        }
        double tm = (((double) editCanvas.getWidth()) - 1.0) / tt;
        gc.setFill(colorByLevel(tlevel));
        for (double tx = 0.0; tx < tt; tx += t1off) gc.fillRect(tx * tm - ttlevel, 0, 1 + ttlevel + ttlevel, tlevel * 2);
        gc.setFill(colorByLevel(tlevel - 1));
        for (double tx = 0.0; tx < tt; tx += t2off) gc.fillRect(tx * tm, 1, 1, tlevel * 2 - 1);
        gc.setFill(Color.BLACK);
        gc.fillRect(0, 2, editCanvas.getWidth(), 1);
        gc.fillRect(0, 2, 1, 16);
        gc.fillRect(editCanvas.getWidth() - 1, 2, 1, 16);
        // Mark to Position
        Range r = clipBoardRange;
        if (r != null) {
            if (markPosition != -1)
                gc.setFill(Color.rgb(64, 64, 192, 0.5));
            else
                gc.setFill(Color.rgb(128, 128, 64, 0.5));
            gc.fillRect(xForPosition(r.start), 7, xForPosition(r.end) - xForPosition(r.start) + 1, 10);
        }
        // Clipboard
        r = currentRange();
        if (r != null) {
            gc.setFill(Color.rgb(128, 128, 64, 0.5));
            gc.fillRect(xForPosition(r.start), 7, xForPosition(r.end) - xForPosition(r.start), 10);
        }
        // Current Position
        int x = xForPosition(position);
        gc.setFill(Color.RED);
        gc.fillRect(x, 0, 1, editCanvas.getHeight());
    }
}
Also used : FilterElement(de.serviceflow.frankenstein.vf.FilterElement) GraphicsContext(javafx.scene.canvas.GraphicsContext) Range(org.opencv.core.Range) CvException(org.opencv.core.CvException) IOException(java.io.IOException) DateTimeParseException(java.time.format.DateTimeParseException)

Example 3 with Range

use of org.opencv.core.Range in project Frankenstein by olir.

the class ProcessingSceneController method videoStarted.

@Override
public void videoStarted(int frames, double fps) {
    this.fps = fps;
    this.frames = frames;
    adjustVideoLengthDisplay();
    Platform.runLater(() -> {
        this.slider.setMin(1);
        this.slider.setValue(1);
        this.currentFrameIndex.setText("1");
        this.currentTime.setText("" + time(0));
        btnMark.setDisable(false);
        currentTime.setDisable(false);
        currentFrameIndex.setDisable(false);
    });
    FilterElement val = new FilterElement(new Range(1, frames), this);
    filterListData.add(val);
    Platform.runLater(() -> {
        drawEditCanvas();
    });
}
Also used : FilterElement(de.serviceflow.frankenstein.vf.FilterElement) Range(org.opencv.core.Range)

Aggregations

Range (org.opencv.core.Range)3 FilterElement (de.serviceflow.frankenstein.vf.FilterElement)2 IOException (java.io.IOException)1 DateTimeParseException (java.time.format.DateTimeParseException)1 GraphicsContext (javafx.scene.canvas.GraphicsContext)1 CvException (org.opencv.core.CvException)1