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.camera.USBCameras;
019
020import edu.wpi.first.cscore.UsbCamera;
021import org.photonvision.common.configuration.CameraConfiguration;
022
023public class PsEyeCameraSettables extends GenericUSBCameraSettables {
024    public PsEyeCameraSettables(CameraConfiguration configuration, UsbCamera camera) {
025        super(configuration, camera);
026    }
027
028    @Override
029    public void setAutoExposure(boolean cameraAutoExposure) {
030        logger.debug("Setting auto exposure to " + cameraAutoExposure);
031
032        // PS Eye uses inverted 1=Disabled, 0=Enabled for auto exposure
033        if (!cameraAutoExposure) {
034            autoExposureProp.set(1);
035
036            // Most cameras leave exposure time absolute at the last value
037            // from their auto exposure algorithm.
038            // Set it back to the exposure slider value
039            setExposureRaw(this.lastExposureRaw);
040
041        } else {
042            autoExposureProp.set(0);
043        }
044    }
045
046    @Override
047    public void setAllCamDefaults() {
048        // Common settings for all cameras to attempt to get their image
049        // as close as possible to what we want for image processing
050        softSet("raw_hue", 0);
051        softSet("raw_contrast", 32);
052        softSet("raw_saturation", 100);
053        softSet("raw_hue", -10);
054        softSet("raw_sharpness", 0);
055        softSet("white_balance_automatic", 0);
056        softSet("gain_automatic", 0);
057    }
058}