Skip to content

Commit

Permalink
Merge pull request #78 from Alex-Beng/dev
Browse files Browse the repository at this point in the history
修复tp不更新的问题and more
  • Loading branch information
GengGode authored Dec 4, 2023
2 parents 32c948d + fcd0a7a commit bd4bbcd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 7 additions & 7 deletions source/algorithms/algorithms.visual.odometer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool control_odometer_calculation(const cv::Mat &giMiniMapRef, cv::Point2d &cont
// use orb match to get the u, aka offset
cv::Point2f offset;
if (orb_match(last_mini_map, curr_mini_map, offset)) {
control = cv::Point2d(offset.x * config.scale, offset.y * config.scale);
control = cv::Point2d(- offset.x * config.scale, -offset.y * config.scale);
last_mini_map = curr_mini_map.clone();
return true;
}
Expand All @@ -51,16 +51,16 @@ bool control_odometer_calculation(const cv::Mat &giMiniMapRef, cv::Point2d &cont
bool orb_match(cv::Mat &img1, cv::Mat &img2, cv::Point2f &offset)
{
// 不crop了,因为上一张会被crop两次。
// img1 = TianLi::Utils::crop_border(img1, 0.15);
// img2 = TianLi::Utils::crop_border(img2, 0.15);
auto img1_cp = TianLi::Utils::crop_border(img1, 0.15);
auto img2_cp = TianLi::Utils::crop_border(img2, 0.15);
// resize 是等比例缩放,就不超了

// 分别计算orb特征点
cv::Ptr<cv::ORB> orb = cv::ORB::create(5000);
std::vector<cv::KeyPoint> kp1, kp2;
cv::Mat desp1, desp2;
orb->detectAndCompute(img1, cv::Mat(), kp1, desp1);
orb->detectAndCompute(img2, cv::Mat(), kp2, desp2);
orb->detectAndCompute(img1_cp, cv::Mat(), kp1, desp1);
orb->detectAndCompute(img2_cp, cv::Mat(), kp2, desp2);

if (desp1.empty() || desp2.empty()) {
return false;
Expand All @@ -85,9 +85,9 @@ bool orb_match(cv::Mat &img1, cv::Mat &img2, cv::Point2f &offset)
return false;
}

auto img2_copy = img2.clone();
// auto img2_copy = img2_cp.clone();
// 画出good matches,然后保存
// cv::drawMatches(img1, kp1, img2, kp2, good_matches, img2_copy);
// cv::drawMatches(img1_cp, kp1, img2_cp, kp2, good_matches, img2_copy);
// cv::imwrite("good_matches.jpg", img2_copy);

// 计算偏移量,直接取平均
Expand Down
3 changes: 2 additions & 1 deletion source/filter/kalman/Kalman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ cv::Point2d Kalman::re_init_filterting(const cv::Point2d& pos)
//!< priori error estimate covariance matrix (P'(k)): P'(k)=A*P(k-1)*At + Q)*/ A代表F: transitionMatrix
//预测估计协方差矩阵;
// 这啥啊,这不计算中的误差协方差
setIdentity(KF.errorCovPost, cv::Scalar::all(1));
// 绑架问题不收敛的罪魁祸首,这个协方差会影响K的计算,从而影响后续的预测和更新
// setIdentity(KF.errorCovPost, cv::Scalar::all(1));

//!< corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k))
//initialize post state of kalman filter at random
Expand Down
1 change: 1 addition & 0 deletions source/genshin/match/position/genshin.match.position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ void TianLi::Genshin::Match::get_avatar_position(const GenshinMinimap& genshin_m
auto od_valid = control_odometer_calculation(genshin_minimap.img_minimap, u_k, odometer_config());
if (!od_valid) {
// TODO:no u_k update
cout << "no u_k update" << endl;
filt_pos = out_genshin_position.config.pos_filter->re_init_filterting(pos);
set_mini_map(genshin_minimap.img_minimap);
}
Expand Down

0 comments on commit bd4bbcd

Please sign in to comment.