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.pipeline;
019
020import com.fasterxml.jackson.annotation.JsonTypeName;
021import java.util.Objects;
022import org.photonvision.common.util.numbers.DoubleCouple;
023import org.photonvision.common.util.numbers.IntegerCouple;
024import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
025import org.photonvision.vision.opencv.ContourShape;
026
027@JsonTypeName("ColoredShapePipelineSettings")
028public class ColoredShapePipelineSettings extends AdvancedPipelineSettings {
029    public ContourShape contourShape = ContourShape.Triangle;
030    public DoubleCouple contourPerimeter = new DoubleCouple(0, Double.MAX_VALUE);
031    public double accuracyPercentage = 10.0;
032    // Circle detection
033    public int circleDetectThreshold = 5;
034    public IntegerCouple contourRadius = new IntegerCouple(0, 100);
035    public int minDist = 20;
036    public int maxCannyThresh = 90;
037    public int circleAccuracy = 20;
038
039    // 3d settings
040    public CameraCalibrationCoefficients cameraCalibration;
041
042    public ColoredShapePipelineSettings() {
043        super();
044        pipelineType = PipelineType.ColoredShape;
045        cameraExposureRaw = 20;
046    }
047
048    @Override
049    public boolean equals(Object o) {
050        if (this == o) return true;
051        if (o == null || getClass() != o.getClass()) return false;
052        if (!super.equals(o)) return false;
053        ColoredShapePipelineSettings that = (ColoredShapePipelineSettings) o;
054        return Double.compare(that.accuracyPercentage, accuracyPercentage) == 0
055                && circleDetectThreshold == that.circleDetectThreshold
056                && minDist == that.minDist
057                && maxCannyThresh == that.maxCannyThresh
058                && circleAccuracy == that.circleAccuracy
059                && cornerDetectionUseConvexHulls == that.cornerDetectionUseConvexHulls
060                && cornerDetectionExactSideCount == that.cornerDetectionExactSideCount
061                && cornerDetectionSideCount == that.cornerDetectionSideCount
062                && Double.compare(that.cornerDetectionAccuracyPercentage, cornerDetectionAccuracyPercentage)
063                        == 0
064                && contourShape == that.contourShape
065                && Objects.equals(contourArea, that.contourArea)
066                && Objects.equals(contourPerimeter, that.contourPerimeter)
067                && Objects.equals(contourRadius, that.contourRadius)
068                && contourGroupingMode == that.contourGroupingMode
069                && contourIntersection == that.contourIntersection
070                && Objects.equals(cameraCalibration, that.cameraCalibration)
071                && cornerDetectionStrategy == that.cornerDetectionStrategy;
072    }
073
074    @Override
075    public int hashCode() {
076        return Objects.hash(
077                super.hashCode(),
078                contourShape,
079                contourArea,
080                contourPerimeter,
081                accuracyPercentage,
082                circleDetectThreshold,
083                contourRadius,
084                minDist,
085                maxCannyThresh,
086                circleAccuracy,
087                contourGroupingMode,
088                contourIntersection,
089                cameraCalibration,
090                cornerDetectionStrategy,
091                cornerDetectionUseConvexHulls,
092                cornerDetectionExactSideCount,
093                cornerDetectionSideCount,
094                cornerDetectionAccuracyPercentage);
095    }
096}