Given the set of active tracks, estimate the cameras motion robustly
@return
5440
private boolean estimateMotion() {
		// organize the data
		List<Stereo2D3D> data = new ArrayList<>();

		for( PointTrack l : candidates ) {
			LeftTrackInfo info = l.getCookie();
			PointTrack r = info.right;

			Stereo2D3D stereo = info.location;
			// compute normalized image coordinate for track in left and right image
			leftImageToNorm.compute(l.x,l.y,info.location.leftObs);
			rightImageToNorm.compute(r.x,r.y,info.location.rightObs);

			data.add(stereo);
		}

		// Robustly estimate left camera motion
		if( !matcher.process(data) )
			return false;

		Se3_F64 keyToCurr = matcher.getModelParameters();
		keyToCurr.invert(currToKey);

		// mark tracks that are in the inlier set
		int N = matcher.getMatchSet().size();
		for( int i = 0; i < N; i++ ) {
			int index = matcher.getInputIndex(i);
			LeftTrackInfo info = candidates.get(index).getCookie();
			info.lastInlier = tick;
		}

//		System.out.println("Inlier set size: "+N);

		return true;
	}
1341757
public int getUnknownCameraParameterCount() {
		int total = 0;
		for (int i = 0; i < cameras.length; i++) {
			if( !cameras[i].known) {
				total += cameras[i].model.getIntrinsicCount();
			}
		}
		return total;
	}
687035
public boolean process( T left , T right ) {
//		System.out.println("----------- Process --------------");

		this.inputLeft = left;
		this.inputRight = right;

		tick++;
		trackerLeft.process(left);
		trackerRight.process(right);

		if( first ) {
			addNewTracks();
			first = false;
		} else {
			mutualTrackDrop();
			selectCandidateTracks();
			boolean failed = !estimateMotion();
			dropUnusedTracks();

			if( failed )
				return false;

			int N = matcher.getMatchSet().size();

			if( modelRefiner != null )
				refineMotionEstimate();

			if( thresholdAdd <= 0 || N < thresholdAdd ) {
				changePoseToReference();
				addNewTracks();
			}
		}
		return true;
	}
479833
public double[] calculateDrift(ArrayList<T> tracks){
		double[] result = new double[3];
		
		double sumX =0;
		double sumY = 0;
		double sumZ = 0;
		int N=0;
		for(int i = 0; i < tracks.size(); i++){
			T t = tracks.get(i);
			TrajectoryValidIndexTimelagIterator it = new TrajectoryValidIndexTimelagIterator(t,1);
	
			//for(int j = 1; j < t.size(); j++){
			while(it.hasNext()) {
				int j = it.next();
				sumX += t.get(j+1).x - t.get(j).x;
				sumY += t.get(j+1).y - t.get(j).y;
				sumZ += t.get(j+1).z - t.get(j).z;
				N++;
			}
		}
		result[0] = sumX/N;
		result[1] = sumY/N;
		result[2] = sumZ/N;
		return result;
	}
938137
public boolean process( T image ) {
		tracker.process(image);

		tick++;
		inlierTracks.clear();

		if( first ) {
			addNewTracks();
			first = false;
		} else {
			if( !estimateMotion() ) {
				return false;
			}

			dropUnusedTracks();
			int N = motionEstimator.getMatchSet().size();

			if( thresholdAdd <= 0 || N < thresholdAdd ) {
				changePoseToReference();
				addNewTracks();
			}

//			System.out.println("  num inliers = "+N+"  num dropped "+numDropped+" total active "+tracker.getActivePairs().size());
		}

		return true;
	}
1356745
@Override
	public void spawnTracks() {
		for (int setIndex = 0; setIndex < sets.length; setIndex++) {
			SetTrackInfo<Desc> info = sets[setIndex];

			// setup data structures
			if( info.isAssociated.length < info.featDst.size ) {
				info.isAssociated = new boolean[ info.featDst.size ];
			}

			// see which features are associated in the dst list
			for( int i = 0; i < info.featDst.size; i++ ) {
				info.isAssociated[i] = false;
			}

			for( int i = 0; i < info.matches.size; i++ ) {
				info.isAssociated[info.matches.data[i].dst] = true;
			}

			// create new tracks from latest unassociated detected features
			for( int i = 0; i < info.featDst.size; i++ ) {
				if( info.isAssociated[i] )
					continue;

				Point2D_F64 loc = info.locDst.get(i);
				addNewTrack(setIndex, loc.x,loc.y,info.featDst.get(i));
			}
		}

	}
686009
public synchronized Collection<TaskTrackerStatus> taskTrackers() {
    Collection<TaskTrackerStatus> ttStatuses;
    synchronized (taskTrackers) {
      ttStatuses =
        new ArrayList<TaskTrackerStatus>(taskTrackers.values().size());
      for (TaskTracker tt : taskTrackers.values()) {
        ttStatuses.add(tt.getStatus());
      }
    }
    return ttStatuses;
  }
1070926
public List<Motion> findCameraMotions(Camera target , @Nullable List<Motion> storage ) {
		if( storage == null )
			storage = new ArrayList<>();

		for (int i = 0; i < edges.size(); i++) {
			Motion m = edges.get(i);
			if( m.viewSrc.camera == target && m.viewDst.camera == target ) {
				storage.add(m);
			}
		}

		return storage;
	}
1090114
public long[] getTrackNumbers() {

        List<TrackFragmentBox> trackBoxes = this.getBoxes(TrackFragmentBox.class, false);
        long[] trackNumbers = new long[trackBoxes.size()];
        for (int trackCounter = 0; trackCounter < trackBoxes.size(); trackCounter++) {
            TrackFragmentBox trackBoxe = trackBoxes.get(trackCounter);
            trackNumbers[trackCounter] = trackBoxe.getTrackFragmentHeaderBox().getTrackId();
        }
        return trackNumbers;
    }
1361773
public ArrayList<String> trackers() {
        string_vector v = p.get_trackers();
        int size = (int) v.size();
        ArrayList<String> l = new ArrayList<>();

        for (int i = 0; i < size; i++) {
            l.add(v.get(i));
        }

        return l;
    }
53385
public RayTraceResult trace()
	{
		if (!(state.getBlock() instanceof IBoundingBox))
			return state.collisionRayTrace(world, pos, ray.origin.toVec3d(), dest.toVec3d());

		IBoundingBox block = (IBoundingBox) state.getBlock();
		AxisAlignedBB[] aabbs = block.getRayTraceBoundingBox(world, pos, world.getBlockState(pos));
		Pair<EnumFacing, Point> closest = super.trace(AABBUtils.offset(pos, aabbs));
		if (closest == null)
			return null;

		return new RayTraceResult(closest.getRight().toVec3d(), closest.getLeft(), pos);
	}
1113026
public Point getMotionCog() {
		Point cog = algorithm.getCog();
		if (cog == null) {
			// detectorAlgorithm hasn't been called so far - get image center
			int w = webcam.getViewSize().width;
			int h = webcam.getViewSize().height;
			cog = new Point(w / 2, h / 2);
		}
		return cog;
	}
690833
@Override
    public Collection<SegmentProperties> getActiveSegments() {
        ensureRunning();
        logRequest("getActiveSegments");

        // To reduce locking in the metadata, we first get the list of Segment Ids, then we fetch their metadata
        // one by one. This only locks the metadata on the first call and, individually, on each call to getStreamSegmentMetadata.
        return this.metadata.getAllStreamSegmentIds()
                .stream()
                .map(this.metadata::getStreamSegmentMetadata)
                .filter(Objects::nonNull)
                .map(SegmentMetadata::getSnapshot)
                .collect(Collectors.toList());
    }
1074064
function () {
            var i,
                len = trackerPoints.length,
                trackPoint,
                gPoint,
                now = $.now(),
                elapsedTime,
                distance,
                speed;

            elapsedTime = now - lastTime;
            lastTime = now;

            for ( i = 0; i < len; i++ ) {
                trackPoint = trackerPoints[ i ];
                gPoint = trackPoint.gPoint;
                // Math.atan2 gives us just what we need for a velocity vector, as we can simply
                //   use cos()/sin() to extract the x/y velocity components.
                gPoint.direction = Math.atan2( gPoint.currentPos.y - trackPoint.lastPos.y, gPoint.currentPos.x - trackPoint.lastPos.x );
                // speed = distance / elapsed time
                distance = trackPoint.lastPos.distanceTo( gPoint.currentPos );
                trackPoint.lastPos = gPoint.currentPos;
                speed = 1000 * distance / ( elapsedTime + 1 );
                // Simple biased average, favors the most recent speed computation. Smooths out erratic gestures a bit.
                gPoint.speed = 0.75 * speed + 0.25 * gPoint.speed;
            }
        }
1241951
public java.util.List<MaintenanceTrack> getMaintenanceTracks() {
        if (maintenanceTracks == null) {
            maintenanceTracks = new com.amazonaws.internal.SdkInternalList<MaintenanceTrack>();
        }
        return maintenanceTracks;
    }
153314
public boolean process(T image) {
		// update feature tracks
		tracker.process(image);

		tick++;

		if (first) {
			// start motion estimation by spawning tracks and estimating their pose
			addNewTracks();
			first = false;
		} else {
			// Use updated tracks to update motion estimate and track states

			// use geometry to prune tracks and perform pre-processing for motion estimation
			sortTracksForEstimation();

			// estimate rotation using points at infinity
			estimateFar();

			// estimate rotation and translation using points on the plane
			if (!estimateClose()) {
				// if this fails it can't do anything
				return false;
			}

			// merge the two motion estimates together
			fuseEstimates();

			// discard tracks which aren't being used
			dropUnusedTracks();

			// see if new tracks need to be added
			if (thresholdAdd <= 0 || closeInlierCount < thresholdAdd) {
				changeCurrToReference();
				addNewTracks();
			}
		}

		return true;
	}
328378
private void computeContainment( int imageArea ) {
		// mark that the track is in the inlier set and compute the containment rectangle
		contRect.x0 = contRect.y0 = Double.MAX_VALUE;
		contRect.x1 = contRect.y1 = -Double.MAX_VALUE;
		for( AssociatedPair p : motion.getModelMatcher().getMatchSet() ) {
			Point2D_F64 t = p.p2;
			if( t.x > contRect.x1 )
				contRect.x1 = t.x;
			if( t.y > contRect.y1 )
				contRect.y1 = t.y;
			if( t.x < contRect.x0 )
				contRect.x0 = t.x;
			if( t.y < contRect.y0 )
				contRect.y0 = t.y;
		}
		containment = contRect.area()/imageArea;
	}