reloc: VisualVerifier (ORB + PnP bang depth anh ban do) + vslam_pnp_eval -- trung khop ban Python 2430/2430 cap
This commit is contained in:
65
libs/vslam_slam/include/vslam/visual_verifier.h
Normal file
65
libs/vslam_slam/include/vslam/visual_verifier.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef VSLAM_VISUAL_VERIFIER_H
|
||||
#define VSLAM_VISUAL_VERIFIER_H
|
||||
|
||||
// Xac minh ung vien VPR bang ANH: so khop diem dac trung (ORB) giua anh hoi va anh ban do,
|
||||
// nang diem ban do len 3D bang depth cua chinh anh do, roi PnP RANSAC -> pose robot.
|
||||
//
|
||||
// Ban C++ cua tools/reloc_pnp_eval.py -- CUNG tham so. Do 2026-09-30 (camera + LiDAR, chot
|
||||
// khi pose PnP trung khop LiDAR cuc bo quanh node anh VPR): 25/09 85 -> 159 dung, 28/09
|
||||
// 29 -> 40 dung, 0 chot SAI ca hai. Diem dac trung nho (goc cua, poster) nhin NGUOC lai thi
|
||||
// khac han -> pha duoc doi xung hanh lang ma LiDAR va hinh khoi depth deu bi lua.
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/features2d.hpp>
|
||||
|
||||
namespace vslam {
|
||||
|
||||
struct VisualVerifierConfig {
|
||||
int orb_features = 1500;
|
||||
int fast_threshold = 7;
|
||||
double clahe_clip = 3.0; // anh IR toi: CLAHE cho x2.7 diem ORB
|
||||
int clahe_grid = 8;
|
||||
double ratio = 0.8; // ratio test Lowe
|
||||
double depth_min_m = 0.3;
|
||||
double depth_max_m = 5.0;
|
||||
int ransac_iters = 300;
|
||||
double reproj_px = 4.0;
|
||||
double confidence = 0.999;
|
||||
int min_points = 8;
|
||||
};
|
||||
|
||||
// Mot anh da trich dac trung, kem hinh hoc camera.
|
||||
struct VisualFrame {
|
||||
std::vector<cv::KeyPoint> kp;
|
||||
cv::Mat des;
|
||||
cv::Mat depth; // CV_16UC1 (mm) hoac CV_32FC1 (m); rong neu khong can
|
||||
cv::Matx33d K;
|
||||
cv::Matx44d T_base_optical; // base (z tinh tu san) <- optical
|
||||
};
|
||||
|
||||
struct PnpResult {
|
||||
int matches = 0; // cap qua ratio test
|
||||
int inliers = 0; // inlier PnP RANSAC; 0 = khong ra nghiem
|
||||
double x = 0.0, y = 0.0, yaw = 0.0; // base cua anh hoi trong map
|
||||
double dz = 0.0, tilt_deg = 0.0; // robot tren san: phai ~0 (lech = nghiem suy bien)
|
||||
};
|
||||
|
||||
class VisualVerifier {
|
||||
public:
|
||||
explicit VisualVerifier(const VisualVerifierConfig& cfg = VisualVerifierConfig());
|
||||
// CLAHE + ORB. `depth`, `K`, `T_base_optical` nguoi goi dien sau.
|
||||
VisualFrame Extract(const cv::Mat& gray) const;
|
||||
// Pose base cua anh hoi `q` trong map, tu diem khop voi anh ban do `m` (can depth) co pose
|
||||
// map <- base `T_map_base_m`.
|
||||
PnpResult Solve(const VisualFrame& q, const VisualFrame& m, const cv::Matx44d& T_map_base_m) const;
|
||||
|
||||
private:
|
||||
VisualVerifierConfig cfg_;
|
||||
cv::Ptr<cv::ORB> orb_;
|
||||
};
|
||||
|
||||
} // namespace vslam
|
||||
|
||||
#endif // VSLAM_VISUAL_VERIFIER_H
|
||||
Reference in New Issue
Block a user