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.util.function.Supplier;
021import org.photonvision.vision.opencv.ImageRotationMode;
022import org.photonvision.vision.opencv.Releasable;
023import org.photonvision.vision.pipe.impl.HSVPipe;
024
025public abstract class FrameProvider implements Supplier<Frame>, Releasable {
026    protected int sequenceID = 0;
027
028    // Escape hatch to allow us to synchronously (from the main vision thread) run
029    // extra
030    // setup/callbacks once cscore connects to our underlying device for the first
031    // time
032    public boolean cameraPropertiesCached = false;
033
034    protected void onCameraConnected() {
035        cameraPropertiesCached = true;
036    }
037
038    public abstract boolean isConnected();
039
040    public abstract boolean checkCameraConnected();
041
042    /**
043     * Returns if the camera has connected at some point. This is not if it is currently connected.
044     */
045    public boolean hasConnected() {
046        return cameraPropertiesCached;
047    }
048
049    public abstract String getName();
050
051    /** Ask the camera to produce a certain kind of processed image (e.g. HSV or greyscale) */
052    public abstract void requestFrameThresholdType(FrameThresholdType type);
053
054    /** Ask the camera to rotate frames it outputs */
055    public abstract void requestFrameRotation(ImageRotationMode rotationMode);
056
057    /** Ask the camera to provide either the input, output, or both frames. */
058    public abstract void requestFrameCopies(boolean copyInput, boolean copyOutput);
059
060    /** Ask the camera to rotate frames it outputs */
061    public abstract void requestHsvSettings(HSVPipe.HSVParams params);
062}