boofcv.abst.sfm.d3.WrapVisOdomQuadPnP Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of boofcv-sfm Show documentation
Show all versions of boofcv-sfm Show documentation
BoofCV is an open source Java library for real-time computer vision and robotics applications.
/*
* Copyright (c) 2011-2017, 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.abst.sfm.d3;
import boofcv.abst.sfm.AccessPointTracks3D;
import boofcv.alg.feature.associate.AssociateStereo2D;
import boofcv.alg.geo.DistanceModelMonoPixels;
import boofcv.alg.geo.pose.PnPStereoDistanceReprojectionSq;
import boofcv.alg.geo.pose.RefinePnPStereo;
import boofcv.alg.sfm.d3.VisOdomQuadPnP;
import boofcv.struct.calib.CameraPinholeRadial;
import boofcv.struct.calib.StereoParameters;
import boofcv.struct.feature.TupleDesc;
import boofcv.struct.geo.Point2D3D;
import boofcv.struct.image.ImageGray;
import boofcv.struct.image.ImageType;
import boofcv.struct.sfm.Stereo2D3D;
import georegression.struct.point.Point2D_F64;
import georegression.struct.point.Point3D_F64;
import georegression.struct.se.Se3_F64;
import org.ddogleg.fitting.modelset.ModelMatcher;
import org.ddogleg.struct.FastQueue;
import java.util.ArrayList;
import java.util.List;
/**
* Wrapper around {@link VisOdomQuadPnP} for {@link StereoVisualOdometry}.
*
* @author Peter Abeles
*/
public class WrapVisOdomQuadPnP,TD extends TupleDesc>
implements StereoVisualOdometry, AccessPointTracks3D
{
VisOdomQuadPnP alg;
RefinePnPStereo refine;
AssociateStereo2D associateStereo;
PnPStereoDistanceReprojectionSq distance;
DistanceModelMonoPixels distanceMono;
Class imageType;
public WrapVisOdomQuadPnP(VisOdomQuadPnP alg,
RefinePnPStereo refine,
AssociateStereo2D associateStereo,
PnPStereoDistanceReprojectionSq distance,
DistanceModelMonoPixels distanceMono,
Class imageType)
{
this.alg = alg;
this.refine = refine;
this.associateStereo = associateStereo;
this.distance = distance;
this.distanceMono = distanceMono;
this.imageType = imageType;
}
@Override
public Point3D_F64 getTrackLocation(int index) {
FastQueue features = alg.getQuadViews();
return features.get(index).X;
}
@Override
public long getTrackId(int index) {
return 0;
}
@Override
public List getAllTracks() {
FastQueue features = alg.getQuadViews();
List ret = new ArrayList<>();
for( VisOdomQuadPnP.QuadView v : features.toList() )
ret.add(v.v2); // new left camera
return ret;
}
@Override
public boolean isInlier(int index) {
ModelMatcher matcher = alg.getMatcher();
int N = matcher.getMatchSet().size();
for( int i = 0; i < N; i++ ) {
if( matcher.getInputIndex(i) == index )
return true;
}
return false;
}
@Override
public boolean isNew(int index) {
return false;// its always new
}
@Override
public void setCalibration(StereoParameters parameters) {
Se3_F64 leftToRight = parameters.getRightToLeft().invert(null);
alg.setCalibration(parameters);
associateStereo.setCalibration(parameters);
distance.setStereoParameters(parameters);
CameraPinholeRadial left = parameters.left;
distanceMono.setIntrinsic(left.fx,left.fy,left.skew);
if( refine != null )
refine.setLeftToRight(leftToRight);
}
@Override
public void reset() {
alg.reset();
}
@Override
public Se3_F64 getCameraToWorld() {
return alg.getLeftToWorld();
}
@Override
public boolean process(T leftImage, T rightImage) {
return alg.process(leftImage,rightImage);
}
@Override
public boolean isFault() {
return false;
}
@Override
public ImageType getImageType() {
return ImageType.single(imageType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy