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 org.photonvision.vision.apriltag.AprilTagFamily;
022import org.photonvision.vision.target.TargetModel;
023
024@JsonTypeName("AprilTagPipelineSettings")
025public class AprilTagPipelineSettings extends AdvancedPipelineSettings {
026    public AprilTagFamily tagFamily = AprilTagFamily.kTag36h11;
027    public int decimate = 1;
028    public double blur = 0;
029    public int threads = 4; // Multiple threads seems to be better performance on most platforms
030    public boolean debug = false;
031    public boolean refineEdges = true;
032    public int numIterations = 40;
033    public int hammingDist = 0;
034    public int decisionMargin = 35;
035    public boolean doMultiTarget = false;
036    public boolean doSingleTargetAlways = false;
037
038    // 3d settings
039
040    public AprilTagPipelineSettings() {
041        super();
042        pipelineType = PipelineType.AprilTag;
043        outputShowMultipleTargets = true;
044        targetModel = TargetModel.kAprilTag6p5in_36h11;
045        cameraExposureRaw = 20;
046        cameraAutoExposure = false;
047        ledMode = false;
048    }
049
050    @Override
051    public int hashCode() {
052        final int prime = 31;
053        int result = super.hashCode();
054        result = prime * result + ((tagFamily == null) ? 0 : tagFamily.hashCode());
055        result = prime * result + decimate;
056        long temp;
057        temp = Double.doubleToLongBits(blur);
058        result = prime * result + (int) (temp ^ (temp >>> 32));
059        result = prime * result + threads;
060        result = prime * result + (debug ? 1231 : 1237);
061        result = prime * result + (refineEdges ? 1231 : 1237);
062        result = prime * result + numIterations;
063        result = prime * result + hammingDist;
064        result = prime * result + decisionMargin;
065        result = prime * result + (doMultiTarget ? 1231 : 1237);
066        result = prime * result + (doSingleTargetAlways ? 1231 : 1237);
067        return result;
068    }
069
070    @Override
071    public boolean equals(Object obj) {
072        if (this == obj) return true;
073        if (!super.equals(obj)) return false;
074        if (getClass() != obj.getClass()) return false;
075        AprilTagPipelineSettings other = (AprilTagPipelineSettings) obj;
076        if (tagFamily != other.tagFamily) return false;
077        if (decimate != other.decimate) return false;
078        if (Double.doubleToLongBits(blur) != Double.doubleToLongBits(other.blur)) return false;
079        if (threads != other.threads) return false;
080        if (debug != other.debug) return false;
081        if (refineEdges != other.refineEdges) return false;
082        if (numIterations != other.numIterations) return false;
083        if (hammingDist != other.hammingDist) return false;
084        if (decisionMargin != other.decisionMargin) return false;
085        if (doMultiTarget != other.doMultiTarget) return false;
086        if (doSingleTargetAlways != other.doSingleTargetAlways) return false;
087        return true;
088    }
089}