1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

slam VO sample file refactor

This commit is contained in:
Agrim Rai
2026-07-08 03:14:17 +05:30
parent f552e8ac82
commit 4ef179b4bf
7 changed files with 351 additions and 274 deletions
@@ -27,7 +27,9 @@ namespace slam {
State machine: NOT_INITIALIZED → INITIALIZING (H/F two-view bootstrap) → TRACKING
(per-frame PnP + local-map refinement). Tracking failure rewinds to INITIALIZING.
@ref run writes camera.txt, point3d.txt, and images.txt into `outputFolder`.
Purely in-memory: feed images with @ref processFrame and read back the trajectory
and map with @ref getTrajectory / @ref getMap. See samples/slam for driving this
from a directory of images and writing the result to disk (e.g. COLMAP format).
*/
class CV_EXPORTS_W VisualOdometry
{
@@ -37,15 +39,10 @@ public:
CV_WRAP static Ptr<VisualOdometry> create(
const Ptr<Feature2D>& detector,
const Ptr<DescriptorMatcher>& matcher,
const String& imagesFolder,
const String& outputFolder,
InputArray cameraMatrix,
InputArray distCoeffs = noArray(),
const OdometryParams& params = OdometryParams());
/** @brief Run the pipeline over every image in the configured folder. */
CV_WRAP virtual bool run() = 0;
/** @brief Feed one image. Returns true if a pose was emitted. */
CV_WRAP virtual bool processFrame(InputArray image) = 0;
@@ -58,15 +55,19 @@ public:
//! @note Not exposed to Python: Map holds raw pointers / non-convertible containers.
virtual const Map& getMap() const = 0;
//! @brief Number of keyframes in the map. Convenience for callers (e.g. Python) that
//! can't use @ref getMap directly.
CV_WRAP virtual int getNumKeyframes() const = 0;
//! @brief Number of map points in the map. Convenience for callers (e.g. Python) that
//! can't use @ref getMap directly.
CV_WRAP virtual int getNumMapPoints() const = 0;
CV_WRAP virtual const std::vector<Matx44d>& getTrajectory() const = 0;
CV_WRAP virtual const OdometryParams& getParams() const = 0;
CV_WRAP virtual void setParams(const OdometryParams& params) = 0;
CV_WRAP virtual const String& getImagesFolder() const = 0;
CV_WRAP virtual const String& getOutputFolder() const = 0;
CV_WRAP virtual void setOutputFolder(const String& outputFolder) = 0;
protected:
VisualOdometry();
};