1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

cleanupFinal

This commit is contained in:
Agrim Rai
2026-06-17 13:15:57 +05:30
parent 72b3fea7dd
commit 08077a00a1
28 changed files with 2453 additions and 400 deletions
+2
View File
@@ -23,6 +23,7 @@ endif()
add_subdirectory(cpp)
add_subdirectory(java/tutorial_code)
add_subdirectory(dnn)
add_subdirectory(slam)
add_subdirectory(gpu)
add_subdirectory(tapi)
add_subdirectory(opencl)
@@ -124,6 +125,7 @@ if(WIN32)
add_subdirectory(directx)
endif()
add_subdirectory(dnn)
add_subdirectory(slam)
# add_subdirectory(gpu)
add_subdirectory(opencl)
add_subdirectory(sycl)
+22
View File
@@ -0,0 +1,22 @@
ocv_install_example_src(slam *.cpp *.hpp CMakeLists.txt)
set(OPENCV_SLAM_SAMPLES_REQUIRED_DEPS
opencv_core
opencv_dnn
opencv_features
opencv_slam)
ocv_check_dependencies(${OPENCV_SLAM_SAMPLES_REQUIRED_DEPS})
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
return()
endif()
project(slam_samples)
ocv_include_modules_recurse(${OPENCV_SLAM_SAMPLES_REQUIRED_DEPS})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../dnn")
file(GLOB_RECURSE slam_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
foreach(sample_filename ${slam_samples})
ocv_define_sample(tgt ${sample_filename} slam)
ocv_target_link_libraries(${tgt} PRIVATE ${OPENCV_LINKER_LIBS} ${OPENCV_SLAM_SAMPLES_REQUIRED_DEPS})
endforeach()
+63
View File
@@ -0,0 +1,63 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2026, BigVision LLC, all rights reserved.
// Third party copyrights are property of their respective owners.
#include <opencv2/slam.hpp>
#include <opencv2/features.hpp>
#include <opencv2/dnn.hpp>
#include <opencv2/core.hpp>
#include <iostream>
using namespace cv;
static const char* ALIKED_MODEL = "/media/user/path/to/models/aliked-n16rot-top1k-640.onnx";
static const char* LIGHTGLUE_MODEL = "/media/user/path/to/models/aliked_lightglue.onnx";
static const char* IMAGES_DIR = "/media/user/path/to/dataset";
static const char* OUTPUT_DIR = "vo_out";
// KITTI-00: fx, fy, cx, cy
static const Matx33d K(718.856, 0., 607.1928,
0., 718.856, 185.2157,
0., 0., 1.);
// k1, k2, p1, p2, k3
static const std::vector<double> DIST = { -0.2811, 0.0723, -0.0003, 0.0001, 0.0 };
static Ptr<Feature2D> makeDetector()
{
ALIKED::Params p;
p.inputSize = Size(640, 640);
p.engine = dnn::ENGINE_NEW;
return ALIKED::create(ALIKED_MODEL, p);
}
static Ptr<DescriptorMatcher> makeMatcher()
{
return LightGlueMatcher::create(LIGHTGLUE_MODEL, 0.0f,
dnn::DNN_BACKEND_DEFAULT,
dnn::DNN_TARGET_CPU);
}
int main()
{
slam::OdometryParams params;
params.minInitParallaxDeg = 1.5;
params.minInitPoints = 50;
auto vo = slam::VisualOdometry::create(
makeDetector(), makeMatcher(),
IMAGES_DIR, OUTPUT_DIR,
Mat(K), Mat(DIST), params);
const int64 t0 = getTickCount();
const bool ok = vo->run();
const double elapsed = (getTickCount() - t0) / getTickFrequency();
std::cout << "run=" << (ok ? "ok" : "FAILED")
<< " frames=" << vo->getTrajectory().size()
<< " elapsed=" << elapsed << "s\n"
<< "output -> " << OUTPUT_DIR << "\n";
return ok ? 0 : 1;
}
+56
View File
@@ -0,0 +1,56 @@
'''
Monocular visual odometry with cv.slam.VisualOdometry (ALIKED + LightGlue).
'''
import time
import numpy as np
import cv2 as cv
ALIKED_MODEL = '/media/user/path/to/models/aliked-n16rot-top1k-640.onnx'
LIGHTGLUE_MODEL = '/media/user/path/to/models/aliked_lightglue.onnx'
IMAGES_DIR = '/media/user/path/to/dataset'
OUTPUT_DIR = 'vo_out'
# KITTI-00: fx, fy, cx, cy
K = np.array([[718.856, 0., 607.1928],
[0., 718.856, 185.2157],
[0., 0., 1. ]], dtype=np.float64)
# k1, k2, p1, p2, k3
DIST = np.array([-0.2811, 0.0723, -0.0003, 0.0001, 0.0], dtype=np.float64)
def make_detector():
p = cv.ALIKED.Params()
p.inputSize = (640, 640)
p.engine = cv.dnn.ENGINE_NEW
return cv.ALIKED.create(ALIKED_MODEL, p)
def make_matcher():
return cv.LightGlueMatcher.create(
LIGHTGLUE_MODEL, 0.0,
cv.dnn.DNN_BACKEND_DEFAULT,
cv.dnn.DNN_TARGET_CPU)
def main():
params = cv.slam.OdometryParams()
params.minInitParallaxDeg = 1.5
params.minInitPoints = 50
vo = cv.slam.VisualOdometry.create(
make_detector(), make_matcher(),
IMAGES_DIR, OUTPUT_DIR,
K, DIST, params)
t0 = time.perf_counter()
ok = vo.run()
elapsed = time.perf_counter() - t0
print(f"run={'ok' if ok else 'FAILED'} frames={len(vo.getTrajectory())} elapsed={elapsed:.2f}s")
print(f"output -> {OUTPUT_DIR}")
if __name__ == '__main__':
main()