Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2022, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package boofcv.alg.fiducial.dots;
import boofcv.abst.geo.Estimate1ofEpipolar;
import boofcv.abst.geo.RefineEpipolar;
import boofcv.alg.feature.describe.llah.LlahDocument;
import boofcv.alg.feature.describe.llah.LlahOperations;
import boofcv.factory.geo.EpipolarError;
import boofcv.factory.geo.FactoryMultiView;
import boofcv.struct.geo.AssociatedPair;
import boofcv.struct.geo.PointIndex2D_F64;
import georegression.struct.homography.Homography2D_F64;
import georegression.struct.homography.UtilHomography_F64;
import georegression.struct.point.Point2D_F64;
import georegression.transform.homography.HomographyPointOps_F64;
import gnu.trove.map.hash.TIntIntHashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import lombok.Getter;
import lombok.Setter;
import org.ddogleg.fitting.modelset.ransac.Ransac;
import org.ddogleg.struct.DogArray;
import org.ddogleg.struct.DogArray_I32;
import org.ddogleg.struct.VerbosePrint;
import org.ejml.data.DMatrixRMaj;
import org.jetbrains.annotations.Nullable;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
*
Detector and tracker for Uchiya Markers (a.k.a. Random Dot) see [1].
*
*
All known targets are stored in the "global" dictionary. The documentID in global dictionary are persistent.
* When documents are tracked between two frames they are assigned a temporary track ID. Tracking works by
* taking the most recent observations and computing a new LLAH description from those. This allows the description
* to change with a changing perspective.
*
* When a document is detected a homography is computed from the canonical coordinates (global or previous track)
* to the current image pixels. This homography is then used to recompute the predicted location of all features,
* even ones which were not observed. The new track LLAH description is computed from these predicted landmarks.
*
*
NOTE: See in code comments about attempts to speed up this tracker.
*
* @author Peter Abeles
* @see boofcv.alg.feature.describe.llah.LlahOperations
*
*
*/
public class UchiyaMarkerTracker implements VerbosePrint {
// Optimizing the tracker appears to be more difficult than initially thought. Below are some attempts that failed.
//
// 1) Combining llahOps and llahTrackingOps together and making detection/tracking into a single step.
// The combined detection/tracking step was faster, but track update was slower because it had to undo
// the modification to llahOps when removing the old documents. Net result was about the same.
// 2) Looking up documents only using the feature hashcode and not the invariants since Uchiya doesn't need
// invariants.
// This ended up being slower. This could be because a hashmap was built instead of an inexpensive linked list
// when going from hash code to features.
// 3) Simplifying image processing to use crude dots instead of refined ellipses would speed things up, but the
// bottle neck is detection, tracking, and update steps.
//
// Profiling didn't show any obvious easy to fix inefficient code.
// Stores the "global" dictionary of documents
@Getter @Setter LlahOperations llahOps;
/** Threshold used to filter false positives documents. At least this many landmarks need to be seen. */
@Getter @Setter int minLandmarkDoc = 8;
/** Minimum number of hits a dot needs to a landmark to be considered a pair */
@Getter @Setter int minDotHits = 5;
/** Sets if tracking is turned on or not */
@Getter @Setter boolean tracking = true;
/** Print tracking and debugging messages */
private @Nullable PrintStream verbose = null;
// Storage for documents which have been lookd up
List foundDocs = new ArrayList<>();
// List of tracks which were visible in the most recent frame
@Getter DogArray