本文整理匯總了Java中boofcv.struct.geo.AssociatedPair類的典型用法代碼示例。如果您正苦於以下問題:Java AssociatedPair類的具體用法?Java AssociatedPair怎麽用?Java AssociatedPair使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AssociatedPair類屬於boofcv.struct.geo包,在下文中一共展示了AssociatedPair類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: stitch
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
/**
* Given two input images create and display an image where the two have been overlayed on top of each other.
*/
public static <T extends ImageSingleBand>
void stitch( BufferedImage imageA , BufferedImage imageB , Class<T> imageType )
{
T inputA = ConvertBufferedImage.convertFromSingle(imageA, null, imageType);
T inputB = ConvertBufferedImage.convertFromSingle(imageB, null, imageType);
// Detect using the standard SURF feature descriptor and describer
DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable(
new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null,null, ImageDataType.single(imageType));
ScoreAssociation<SurfFeature> scorer = FactoryAssociation.scoreEuclidean(SurfFeature.class,true);
AssociateDescription<SurfFeature> associate = FactoryAssociation.greedy(scorer,2,true);
// fit the images using a homography. This works well for rotations and distant objects.
GenerateHomographyLinear modelFitter = new GenerateHomographyLinear(true);
DistanceHomographySq distance = new DistanceHomographySq();
ModelMatcher<Homography2D_F64,AssociatedPair> modelMatcher =
new Ransac<Homography2D_F64,AssociatedPair>(123,modelFitter,distance,60,9);
Homography2D_F64 H = computeTransform(inputA, inputB, detDesc, associate, modelMatcher);
renderStitching(imageA,imageB,H);
}
示例2: process
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
/**
* <p>
* Computes the homography matrix given a set of observed points in two images. A set of {@link AssociatedPair}
* is passed in. The computed homography 'H' is found such that the attributes 'keyLoc' and 'currLoc' in {@link AssociatedPair}
* refers to x1 and x2, respectively, in the equation below:<br>
* x<sub>2</sub> = H*x<sub>1</sub>
* </p>
*
* @param points A set of observed image points that are generated from a planar object. Minimum of 4 pairs required.
* @param foundH Output: Storage for the found solution. 3x3 matrix.
* @return true if the calculation was a success.
*/
public boolean process( List<AssociatedPair> points , DenseMatrix64F foundH ) {
if( points.size() < 4 )
throw new IllegalArgumentException("Must be at least 4 points.");
if( normalize ) {
LowLevelMultiViewOps.computeNormalization(points, N1, N2);
createANormalized(points, A);
} else {
createA(points,A);
}
// compute the homograph matrix up to a scale factor
if (computeH(A,foundH))
return false;
if( normalize )
undoNormalizationH(foundH,N1,N2);
// pick a good scale and sign for H
adjust.adjust(foundH,points.get(0));
return true;
}
示例3: process
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
/**
* Computes the homography based on a line and point on the plane
* @param line Line on the plane
* @param point Point on the plane
*/
public void process(PairLineNorm line, AssociatedPair point) {
// t0 = (F*x) cross l'
GeometryMath_F64.mult(F,point.p1,Fx);
GeometryMath_F64.cross(Fx,line.getL2(),t0);
// t1 = x' cross ((f*x) cross l')
GeometryMath_F64.cross(point.p2, t0, t1);
// t0 = x' cross e'
GeometryMath_F64.cross(point.p2,e2,t0);
double top = GeometryMath_F64.dot(t0,t1);
double bottom = t0.normSq()*(line.l1.x*point.p1.x + line.l1.y*point.p1.y + line.l1.z);
// e' * l^T
GeometryMath_F64.outerProd(e2, line.l1, el);
// cross(l')*F
GeometryMath_F64.multCrossA(line.l2, F, lf);
CommonOps.add(lf,top/bottom,el,H);
// pick a good scale and sign for H
adjust.adjust(H, point);
}
示例4: computeResidual
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
@Override
public double computeResidual(AssociatedPair observation) {
double bottom = 0;
GeometryMath_F64.mult(F, observation.p1, temp);
bottom += temp.x*temp.x + temp.y*temp.y;
GeometryMath_F64.multTran(F, observation.p2, temp);
bottom += temp.x*temp.x + temp.y*temp.y;
bottom = Math.sqrt(bottom);
if( bottom <= UtilEjml.EPS) {
return Double.MAX_VALUE;
} else {
GeometryMath_F64.multTran(F,observation.p2,temp);
return (temp.x*observation.p1.x + temp.y*observation.p1.y + temp.z)/bottom;
}
}
示例5: process
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
@Override
public boolean process(DenseMatrix64F F, List<AssociatedPair> obs, DenseMatrix64F refinedF ) {
func.setObservations(obs);
minimizer.setFunction(func,null);
minimizer.initialize(F.data,0,convergenceTol*obs.size());
for( int i = 0; i < maxIterations; i++ ) {
if( minimizer.iterate() )
break;
}
System.arraycopy(minimizer.getParameters(),0,refinedF.data,0,9);
return true;
}
示例6: multiple
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
@Test
public void multiple() {
ScaleTranslate2D model = new ScaleTranslate2D(1.5,-2,3);
AssociatedPair a = apply(-5,4,model);
a.p2.x += 3.5;
AssociatedPair b = apply(2.15,2,model);
List<AssociatedPair> obs = new ArrayList<AssociatedPair>();
obs.add(a);
obs.add(b);
DistanceScaleTranslate2DSq alg = new DistanceScaleTranslate2DSq();
alg.setModel(model);
double found[] = new double[2];
alg.computeDistance(obs,found);
assertEquals(3.5*3.5,found[0],1e-8);
assertEquals(0,found[1],1e-8);
}
示例7: computeContainment
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
/**
* Computes an axis-aligned rectangle that contains all the inliers. It then computes the area contained in
* that rectangle to the total area of the image
*
* @param imageArea width*height
*/
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;
}
示例8: LeastSquaresFundamental
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
public LeastSquaresFundamental(ModelCodec<DenseMatrix64F> paramModel,
double convergenceTol,
int maxIterations,
boolean useSampson) {
this.paramModel = paramModel;
this.maxIterations = maxIterations;
this.convergenceTol = convergenceTol;
param = new double[paramModel.getParamLength()];
ModelObservationResidual<DenseMatrix64F,AssociatedPair> residual;
if( useSampson )
residual = new FundamentalResidualSampson();
else
residual = new FundamentalResidualSimple();
func = new ResidualsEpipolarMatrix(paramModel,residual);
minimizer = FactoryOptimization.leastSquareLevenberg(1e-3);
}
示例9: alignY
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
/**
* See if the transform align an observation to the same y-axis
*/
@Test
public void alignY() {
createScene();
RectifyFundamental alg = new RectifyFundamental();
alg.process(F,pairs,500,520);
// unrectified observations
AssociatedPair unrect = pairs.get(0);
// rectified observations
Point2D_F64 r1 = new Point2D_F64();
Point2D_F64 r2 = new Point2D_F64();
GeometryMath_F64.mult(alg.getRect1(),unrect.p1,r1);
GeometryMath_F64.mult(alg.getRect2(),unrect.p2,r2);
assertEquals(r1.y,r2.y,1e-8);
}
示例10: setAssociation
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
public synchronized void setAssociation( List<AssociatedPair> matches ) {
List<Point2D_F64> leftPts = new ArrayList<Point2D_F64>();
List<Point2D_F64> rightPts = new ArrayList<Point2D_F64>();
for( AssociatedPair p : matches ) {
leftPts.add(p.p1);
rightPts.add(p.p2);
}
setLocation(leftPts,rightPts);
assocLeft = new int[ leftPts.size() ];
assocRight = new int[ rightPts.size() ];
for( int i = 0; i < assocLeft.length; i++ ) {
assocLeft[i] = i;
assocRight[i] = i;
}
Random rand = new Random(234);
colors = new Color[ leftPts.size() ];
for( int i = 0; i < colors.length; i++ ) {
colors[i] = new Color(rand.nextInt() | 0xFF000000 );
}
}
示例11: createCommonChecks
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
private CommonFundamentalChecks createCommonChecks() {
return new CommonFundamentalChecks() {
EssentialNister5 alg = new EssentialNister5();
{
// use a more relaxed tolerance
// in practice the bad hypotheses seem to get thrown out. The robustness benchmark
// also provides a better idea of what's going on and seems to be similar to what
// papers show
zeroTol = 0.0001;
}
@Override
public void computeFundamental(List<AssociatedPair> pairs , FastQueue<DenseMatrix64F> solutions ) {
assertTrue(alg.process(pairs,solutions));
}
};
}
示例12: checkScaleInvariance
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
/**
* Scale the input and see if that changes the error
*/
@Test
public void checkScaleInvariance() {
DistanceEpipolarConstraint alg = new DistanceEpipolarConstraint();
alg.setModel(F);
p1.x += 0.2;
p1.y += 0.2;
double orig = alg.computeDistance(new AssociatedPair(p1,p2));
// rescale the matrix and see if that changes the results
CommonOps.scale(5,F);
alg.setModel(F);
double after = alg.computeDistance(new AssociatedPair(p1,p2));
assertEquals(orig,after,1e-8);
}
示例13: splitAssociated_pair
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
@Test
public void splitAssociated_pair() {
List<AssociatedPair> list = new ArrayList<AssociatedPair>();
for( int i = 0; i < 12; i++ ) {
AssociatedPair p = new AssociatedPair();
p.p2.set(rand.nextDouble()*5, rand.nextDouble()*5);
p.p1.set(rand.nextDouble()*5, rand.nextDouble()*5);
list.add(p);
}
List<Point2D_F64> list1 = new ArrayList<Point2D_F64>();
List<Point2D_F64> list2 = new ArrayList<Point2D_F64>();
PerspectiveOps.splitAssociated(list,list1,list2);
assertEquals(list.size(),list1.size());
assertEquals(list.size(),list2.size());
for( int i = 0; i < list.size(); i++ ) {
assertTrue(list.get(i).p1 == list1.get(i));
assertTrue(list.get(i).p2 == list2.get(i));
}
}
示例14: perfectInput
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
@Test
public void perfectInput() {
createScene(30,false);
// use the linear algorithm to compute the homography
HomographyLinear4 estimator = new HomographyLinear4(true);
estimator.process(pairs,H);
GeoModelRefine<DenseMatrix64F,AssociatedPair> alg = createAlgorithm();
//give it the perfect matrix and see if it screwed it up
assertTrue(alg.process(H, pairs, found));
// normalize so that they are the same
CommonOps.divide(H.get(2, 2), H);
CommonOps.divide(found.get(2, 2), found);
assertTrue(MatrixFeatures.isEquals(H, found, 1e-8));
}
示例15: testPerfect
import boofcv.struct.geo.AssociatedPair; //導入依賴的package包/類
@Test
public void testPerfect() {
Se3_F64 keyToCurr = new Se3_F64();
keyToCurr.getR().set(RotationMatrixGenerator.eulerArbitrary(0, 1, 2, 0.05, -0.03, 0.02));
keyToCurr.getT().set(0.1,-0.1,0.01);
Point3D_F64 X = new Point3D_F64(0.1,-0.05,3);
AssociatedPair obs = new AssociatedPair();
obs.p1.x = X.x/X.z;
obs.p1.y = X.y/X.z;
SePointOps_F64.transform(keyToCurr,X,X);
obs.p2.x = X.x/X.z;
obs.p2.y = X.y/X.z;
alg.setModel(keyToCurr);
assertEquals(0, alg.computeDistance(obs), 1e-8);
}