Compute rectification transforms for the stereo pair given a fundamental matrix and its observations.

@param F Fundamental matrix
@param observations Observations used to compute F
@param width Width of first image.
@param height Height of first image.
480917
public void process( DMatrixRMaj F , List<AssociatedPair> observations ,
						 int width , int height ) {

		int centerX = width/2;
		int centerY = height/2;

		MultiViewOps.extractEpipoles(F, epipole1, epipole2);
		checkEpipoleInside(width, height);


		// compute the transform H which will send epipole2 to infinity
		SimpleMatrix R = rotateEpipole(epipole2,centerX,centerY);
		SimpleMatrix T = translateToOrigin(centerX,centerY);
		SimpleMatrix G = computeG(epipole2,centerX,centerY);

		SimpleMatrix H = G.mult(R).mult(T);

		//Find the two matching transforms
		SimpleMatrix Hzero = computeHZero(F,epipole2,H);

		SimpleMatrix Ha = computeAffineH(observations,H.getDDRM(),Hzero.getDDRM());

		rect1.set(Ha.mult(Hzero).getDDRM());
		rect2.set(H.getDDRM());
	}
1261755
private boolean refineWithBundleAdjustment(SceneObservations observations) {
		if( scaleSBA ) {
			scaler.applyScale(structure,observations);
		}

		sba.setVerbose(verbose,verboseLevel);
		sba.setParameters(structure,observations);
		sba.configure(converge.ftol,converge.gtol,converge.maxIterations);

		if( !sba.optimize(structure) ) {
			return false;
		}

		if( scaleSBA ) {
			// only undo scaling on camera matrices since observations are discarded
			for (int i = 0; i < structure.views.length; i++) {
				DMatrixRMaj P = structure.views[i].worldToView;
				scaler.pixelScaling.get(i).remove(P,P);
			}
			scaler.undoScale(structure,observations);
		}
		return true;
	}
454065
private static void adjustUncalibrated(DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight,
										   RectangleLength2D_F64 bound, double scale) {
		// translation
		double deltaX = -bound.x0*scale;
		double deltaY = -bound.y0*scale;

		// adjustment matrix
		SimpleMatrix A = new SimpleMatrix(3,3,true,new double[]{scale,0,deltaX,0,scale,deltaY,0,0,1});
		SimpleMatrix rL = SimpleMatrix.wrap(rectifyLeft);
		SimpleMatrix rR = SimpleMatrix.wrap(rectifyRight);

		rectifyLeft.set(A.mult(rL).getDDRM());
		rectifyRight.set(A.mult(rR).getDDRM());
	}
1028453
private void refineMotionEstimate() {

		// use observations from the inlier set
		List<Stereo2D3D> data = new ArrayList<>();

		int N = matcher.getMatchSet().size();
		for( int i = 0; i < N; i++ ) {
			int index = matcher.getInputIndex(i);

			PointTrack l = candidates.get(index);
			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);
		}

		// refine the motion estimate using non-linear optimization
		Se3_F64 keyToCurr = currToKey.invert(null);
		Se3_F64 found = new Se3_F64();
		if( modelRefiner.fitModel(data,keyToCurr,found) ) {
			found.invert(currToKey);
		}
	}
1073488
public void getImageRelativeToViewAbsoluteTransform(Matrix outMatrix) {
    outMatrix.setRectToRect(IDENTITY_RECT, mTransformedImageBounds, Matrix.ScaleToFit.FILL);
  }
674542
public static void triangulatePoints(SceneStructureMetric structure , SceneObservations observations )
	{
		TriangulateNViewsMetric triangulation = FactoryMultiView.
				triangulateNViewCalibrated(ConfigTriangulation.GEOMETRIC);

		List<RemoveBrownPtoN_F64> list_p_to_n = new ArrayList<>();
		for (int i = 0; i < structure.cameras.length; i++) {
			RemoveBrownPtoN_F64 p2n = new RemoveBrownPtoN_F64();
			if( structure.cameras[i].model instanceof BundlePinholeSimplified ) {
				BundlePinholeSimplified cam = (BundlePinholeSimplified) structure.cameras[i].model;
				p2n.setK(cam.f, cam.f, 0, 0, 0).setDistortion(new double[]{cam.k1, cam.k2}, 0, 0);
			} else if( structure.cameras[i].model instanceof BundlePinhole) {
				BundlePinhole cam = (BundlePinhole) structure.cameras[i].model;
				p2n.setK(cam.fx, cam.fy, cam.skew, cam.cx, cam.cy).setDistortion(new double[]{0,0}, 0,0);
			} else if( structure.cameras[i].model instanceof BundlePinholeBrown) {
				BundlePinholeBrown cam = (BundlePinholeBrown) structure.cameras[i].model;
				p2n.setK(cam.fx, cam.fy, cam.skew, cam.cx, cam.cy).setDistortion(cam.radial, cam.t1, cam.t2);
			} else {
				throw new RuntimeException("Unknown camera model!");
			}
			list_p_to_n.add(p2n);
		}

		FastQueue<Point2D_F64> normObs = new FastQueue<>(Point2D_F64.class,true);
		normObs.resize(3);

		Point3D_F64 X = new Point3D_F64();

		List<Se3_F64> worldToViews = new ArrayList<>();
		for (int i = 0; i < structure.points.length; i++) {
			normObs.reset();
			worldToViews.clear();
			SceneStructureMetric.Point sp = structure.points[i];
			for (int j = 0; j < sp.views.size; j++) {
				int viewIdx = sp.views.get(j);
				SceneStructureMetric.View v = structure.views[viewIdx];
				worldToViews.add(v.worldToView);

				// get the observation in pixels
				Point2D_F64 n = normObs.grow();
				int pointidx = observations.views[viewIdx].point.indexOf(i);
				observations.views[viewIdx].get(pointidx,n);
				// convert to normalized image coordinates
				list_p_to_n.get(v.camera).compute(n.x,n.y,n);
			}

			triangulation.triangulate(normObs.toList(),worldToViews,X);
			sp.set(X.x,X.y,X.z);
		}
	}
617763
public void setSize(int width, int height) {
        final float r = width * 0.75f / SIN;
        final float y = COS * r;
        final float h = r - y;
        final float or = height * 0.75f / SIN;
        final float oy = COS * or;
        final float oh = or - oy;

        mRadius = r;
        mBaseGlowScale = h > 0 ? Math.min(oh / h, 1.f) : 1.f;

        mBounds.set(mBounds.left, mBounds.top, width, (int) Math.min(height, h));
    }
726154
public void set(double x, double y, double width, double height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }
1102613
public void addImage( CalibrationObservation observation ) {
		if( imageWidth == 0 ) {
			this.imageWidth = observation.getWidth();
			this.imageHeight = observation.getHeight();
		} else if( observation.getWidth() != this.imageWidth || observation.getHeight() != this.imageHeight) {
			throw new IllegalArgumentException("Image shape miss match");
		}
		observations.add( observation );
	}
365340
private void convertFromARtoVRSpace(float scale) {
        mPose.update(mARPlane.getCenterPose(), scale);
        getTransform().setModelMatrix(mPose.getPoseMatrix());
    }
16506
private void rectifyInputImages() {
		// get intrinsic camera calibration matrices
		DMatrixRMaj K1 = PerspectiveOps.pinholeToMatrix(calib.left, (DMatrixRMaj)null);
		DMatrixRMaj K2 = PerspectiveOps.pinholeToMatrix(calib.right, (DMatrixRMaj)null);

		// compute rectification matrices
		rectifyAlg.process(K1,new Se3_F64(),K2,calib.getRightToLeft().invert(null));

		DMatrixRMaj rect1 = rectifyAlg.getRect1();
		DMatrixRMaj rect2 = rectifyAlg.getRect2();
		rectK = rectifyAlg.getCalibrationMatrix();
		rectR = rectifyAlg.getRectifiedRotation();

		// adjust view to maximize viewing area while not including black regions
		RectifyImageOps.allInsideLeft(calib.left, rect1, rect2, rectK);

		// compute transforms to apply rectify the images
		leftRectToPixel = transformRectToPixel(calib.left, rect1);

		ImageType<T> imageType = ImageType.single(activeAlg.getInputType());

		FMatrixRMaj rect1_F32 = new FMatrixRMaj(3,3); // TODO simplify code some how
		FMatrixRMaj rect2_F32 = new FMatrixRMaj(3,3);
		ConvertMatrixData.convert(rect1, rect1_F32);
		ConvertMatrixData.convert(rect2, rect2_F32);

		ImageDistort<T,T> distortRect1 = RectifyImageOps.rectifyImage(
				calib.left, rect1_F32, BorderType.SKIP,imageType);
		ImageDistort<T,T> distortRect2 = RectifyImageOps.rectifyImage(
				calib.right, rect2_F32, BorderType.SKIP, imageType);

		// rectify and undo distortion
		distortRect1.apply(inputLeft, rectLeft);
		distortRect2.apply(inputRight,rectRight);

		rectifiedImages = true;
	}
1373749
public synchronized void setManualFramingRect(int width, int height) {
    if (initialized) {
      Point screenResolution = configManager.getScreenResolution();
      if (width > screenResolution.x) {
        width = screenResolution.x;
      }
      if (height > screenResolution.y) {
        height = screenResolution.y;
      }
      int leftOffset = (screenResolution.x - width) / 2;
      int topOffset = (screenResolution.y - height) / 2;
      framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
      Log.d(TAG, "Calculated manual framing rect: " + framingRect);
      framingRectInPreview = null;
    } else {
      requestedFramingRectWidth = width;
      requestedFramingRectHeight = height;
    }
  }
787292
protected void squareToImageSample(float x, float y, RectangleRotate_F32 region) {
		// -1 because it starts counting at 0.  otherwise width+1 samples are made
		x *= region.width-1;
		y *= region.height-1;

		imageX = x*c - y*s + region.cx;
		imageY = x*s + y*c + region.cy;
	}
333238
public void setCamera1( double fx , double fy , double skew , double cx , double cy ) {
		PerspectiveOps.pinholeToMatrix(fx,fy,skew,cx,cy,K1);
	}
675973
public static void fullViewLeft(int imageWidth,int imageHeight,
									DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight )
	{
		ImplRectifyImageOps_F64.fullViewLeft(imageWidth, imageHeight, rectifyLeft, rectifyRight);
	}
647242
@Override
	public void reshape(int width, int height) {
		if( this.width == width && this.height == height )
			return;
		if( isSubimage() )
			throw new IllegalArgumentException("Can't reshape sub-images");
		
		Object data = _getData();

		if( Array.getLength(data) < width*height ) {
			// declare a new larger image to store the data
			ImageGray a = createNew(width,height);
			_setData(a._getData());
		}

		this.stride = width;
		this.width = width;
		this.height = height;
	}
26148
protected void interpolateFlowScale(int widthNew, int heightNew) {
		// warping isn't done until later so use those images as temporary storage
		GrayF32 enlargedU = warpDeriv2X;
		GrayF32 enlargedV = warpDeriv2Y;

		// use the previous low resolution flow estimate to initialize the new image
		interpolateFlowScale(flowU, enlargedU);
		interpolateFlowScale(flowV, enlargedV);

		flowU.reshape(widthNew, heightNew);
		flowV.reshape(widthNew, heightNew);

		// save the initial flow values
		flowU.setTo(enlargedU);
		flowV.setTo(enlargedV);
	}