001/*
002 * Copyright (C) Photon Vision.
003 *
004 * This program is free software: you can redistribute it and/or modify
005 * it under the terms of the GNU General Public License as published by
006 * the Free Software Foundation, either version 3 of the License, or
007 * (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
016 */
017
018package org.photonvision.vision.frame;
019
020import java.awt.Color;
021import org.opencv.core.CvType;
022import org.opencv.core.Mat;
023import org.opencv.core.Point;
024import org.opencv.core.Rect;
025import org.opencv.imgproc.Imgproc;
026import org.photonvision.common.util.ColorHelper;
027
028public class StaticFrames {
029    public static final Mat LOST_MAT = new Mat(60, 15 * 7, CvType.CV_8UC3);
030    public static final Mat EMPTY_MAT = new Mat(60, 15 * 7, CvType.CV_8UC3);
031
032    static {
033        EMPTY_MAT.setTo(ColorHelper.colorToScalar(Color.BLACK));
034        var col = 0;
035        Imgproc.rectangle(
036                EMPTY_MAT,
037                new Rect(col, 0, 15, EMPTY_MAT.height()),
038                ColorHelper.colorToScalar(new Color(0xa2a2a2)),
039                -1);
040        col += 15;
041        Imgproc.rectangle(
042                EMPTY_MAT,
043                new Rect(col, 0, 15, EMPTY_MAT.height()),
044                ColorHelper.colorToScalar(new Color(0xa2a300)),
045                -1);
046        col += 15;
047        Imgproc.rectangle(
048                EMPTY_MAT,
049                new Rect(col, 0, 15, EMPTY_MAT.height()),
050                ColorHelper.colorToScalar(new Color(0x00a3a2)),
051                -1);
052        col += 15;
053        Imgproc.rectangle(
054                EMPTY_MAT,
055                new Rect(col, 0, 15, EMPTY_MAT.height()),
056                ColorHelper.colorToScalar(new Color(0x00a200)),
057                -1);
058        col += 15;
059        Imgproc.rectangle(
060                EMPTY_MAT,
061                new Rect(col, 0, 15, EMPTY_MAT.height()),
062                ColorHelper.colorToScalar(new Color(0x440045)),
063                -1);
064        col += 15;
065        Imgproc.rectangle(
066                EMPTY_MAT,
067                new Rect(col, 0, 15, EMPTY_MAT.height()),
068                ColorHelper.colorToScalar(new Color(0x0000a2)),
069                -1);
070        col += 15;
071        Imgproc.rectangle(
072                EMPTY_MAT,
073                new Rect(col, 0, 15, EMPTY_MAT.height()),
074                ColorHelper.colorToScalar(new Color(0)),
075                -1);
076        Imgproc.rectangle(
077                EMPTY_MAT,
078                new Rect(0, 50, EMPTY_MAT.width(), 10),
079                ColorHelper.colorToScalar(new Color(0)),
080                -1);
081        Imgproc.rectangle(
082                EMPTY_MAT, new Rect(15, 50, 30, 10), ColorHelper.colorToScalar(Color.WHITE), -1);
083
084        EMPTY_MAT.copyTo(LOST_MAT);
085
086        Imgproc.putText(
087                EMPTY_MAT, "Stream", new Point(14, 20), 0, 0.6, ColorHelper.colorToScalar(Color.white), 2);
088        Imgproc.putText(
089                EMPTY_MAT,
090                "Disabled",
091                new Point(14, 45),
092                0,
093                0.6,
094                ColorHelper.colorToScalar(Color.white),
095                2);
096
097        Imgproc.putText(
098                EMPTY_MAT, "Stream", new Point(14, 20), 0, 0.6, ColorHelper.colorToScalar(Color.RED), 1);
099        Imgproc.putText(
100                EMPTY_MAT, "Disabled", new Point(14, 45), 0, 0.6, ColorHelper.colorToScalar(Color.RED), 1);
101
102        Imgproc.putText(
103                LOST_MAT, "Camera", new Point(14, 20), 0, 0.6, ColorHelper.colorToScalar(Color.white), 2);
104        Imgproc.putText(
105                LOST_MAT, "Lost", new Point(14, 45), 0, 0.6, ColorHelper.colorToScalar(Color.white), 2);
106        Imgproc.putText(
107                LOST_MAT, "Camera", new Point(14, 20), 0, 0.6, ColorHelper.colorToScalar(Color.RED), 1);
108        Imgproc.putText(
109                LOST_MAT, "Lost", new Point(14, 45), 0, 0.6, ColorHelper.colorToScalar(Color.RED), 1);
110    }
111
112    public StaticFrames() {}
113}