SLAM学习笔记

2023-05-16

编译环境参考之前的笔记

cmake文件

cmake_minimum_required(VERSION 3.0)
project(odometry)

set(CMAKE_BUILD_TYPE "Release")
add_definitions("-DENABLE_SSE")
set(CMKAE_CXX_FLAGS "-std=c++14 -02 ${SSE_FLAGS} -msse4 ")
set(CMAKE_CXX_FLAGS "-mpopcnt")
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(OpenGL_GL_PREFERENCE LEGACY)

find_package(OpenCV REQUIRED)
find_package(g2o REQUIRED)
find_package(Sophus REQUIRED)

include_directories(OpenCV_INCLUDE_DIRS)
include_directories(${G2O_INCLUDE_DIRS})
include_directories(${Sophus_INCLUDE_DIRS})
include_directories("/usr/include/eigen3/")

add_executable(orb orb.cpp)
target_link_libraries(orb ${OpenCV_LIBS})

add_executable(doorb orb_self.cpp)
target_link_libraries(doorb ${OpenCV_LIBS})

add_executable(2d2d 2d2d.cpp)
target_link_libraries(2d2d ${OpenCV_LIBS})



orb使用

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <chrono>
#include "opencv2/imgcodecs/legacy/constants_c.h"
using namespace std;
using namespace cv;

int main (int argc,char** argv)
{
    if(argc !=3)                                                                        //读图没啥好说的
    {
        cout<<"usage: feature_extraction img1 img2"<<endl;
        return 1;
    }

    Mat img1 = imread(argv[1],CV_LOAD_IMAGE_COLOR);
    Mat img2 = imread(argv[2],CV_LOAD_IMAGE_COLOR);
    assert(img1.data != nullptr && img2.data != nullptr);

    std::vector<KeyPoint> keypoints_1,keypoints_2;                                      //声明关键点和描述子     
    Mat descriptors_1,descriptors_2;
    Ptr<FeatureDetector> detector = ORB::create();                                      //创建检测器                          
    Ptr<DescriptorExtractor> descriptor = ORB::create();                                //描述子
    Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-Hamming");   //匹配规则:暴力匹配、汉明距离

    chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
    detector->detect(img1,keypoints_1);                                                 //检测orientFAST角点位置
    detector->detect(img2,keypoints_2);

    descriptor->compute(img1,keypoints_1,descriptors_1);                                //计算BRIEF描述子
    descriptor->compute(img2,keypoints_2,descriptors_2);
    chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
    chrono::duration<double> time_used = chrono::duration_cast<chrono::duration<double>>(t2-t1);
    cout<<"extract ORB cost = "<<time_used.count()<<" seconds."<<endl;

    Mat outimg1;
    drawKeypoints(img1,keypoints_1,outimg1,Scalar::all(-1),DrawMatchesFlags::DEFAULT);
    imshow("ORB features",outimg1);

    vector<DMatch> matches;                                                             //特征点匹配
    t1 = chrono::steady_clock::now();
    matcher->match(descriptors_1,descriptors_2,matches);
    t2 = chrono::steady_clock::now();
    time_used = chrono::duration_cast<chrono::duration<double>>(t2-t1);
    cout<<"match ORB cost = "<<time_used.count()<<" seconds."<<endl;

    auto min_max = minmax_element(matches.begin(),matches.end(),[](const DMatch &m1,const DMatch &m2)
    {
        return m1.distance < m2.distance;                                               //计算最小距离和最大距离
    });                                                                                 
    double min_dist = min_max.first->distance;
    double max_dist = min_max.second->distance;

    printf("--Max dist : %f \n",max_dist);
    printf("--Min dist : %f \n",min_dist);

    std::vector<DMatch> good_matches;                                                   //对匹配点进行筛选
    for (int i = 0; i < descriptors_1.rows; i++)
    {
        if (matches[i].distance <= max(2*min_dist,30.0))                                //描述子间距在两倍最小距离和30之间
        {                                                                               //30是经验值,可以自己手动调整
            good_matches.push_back(matches[i]);
        }
    }

    Mat img_match;
    Mat img_goodmatch;
    drawMatches(img1,keypoints_1,img2,keypoints_2,matches,img_match);
    drawMatches(img1,keypoints_1,img2,keypoints_2,good_matches,img_goodmatch);
    imshow("all matches",img_match);
    imshow("good matches",img_goodmatch);
    waitKey(0);
    destroyAllWindows();
    
    return 0;
}

手写orb

#include <string>
#include <nmmintrin.h>
#include <chrono>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;

string img1_file = "/home/martin/桌面/code/odometry/1.png";
string img2_file = "/home/martin/桌面/code/odometry/2.png";

typedef vector<uint32_t> DescType;                                                                                  //描述子类型

void ComputeORB(const cv::Mat &img,vector<cv::KeyPoint> &keypoints,vector<DescType> &descriptors);                  //计算ORB特征

void BfMatch(const vector<DescType> &descriptor1,const vector<DescType> &descriptor2,vector<cv::DMatch> &matches);  //匹配特征点
//主函数和orb.cpp没有多少区别,self主要实现的就是计算特征点检测和匹配
int main(int argc,char** argv)
{
    cv::Mat img1 = cv::imread(img1_file,0);
    cv::Mat img2 = cv::imread(img2_file,0);
    assert(img1.data != nullptr && img2.data != nullptr);

    chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
    vector<cv::KeyPoint> keypoints1;
    cv::FAST(img1,keypoints1,40);
    vector<DescType> descriptor1;
    ComputeORB(img1,keypoints1,descriptor1);

    vector<cv::KeyPoint> keypoints2;
    cv::FAST(img2,keypoints2,40);
    vector<DescType> descriptor2;
    ComputeORB(img2,keypoints2,descriptor2);
    chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
    chrono::duration<double> time_used = chrono::duration_cast<chrono::duration<double>>(t2-t1);
    cout<<"extract ORB cost = "<<time_used.count()<<" seconds."<< endl;

    vector<cv::DMatch> matches;
    t1 = chrono::steady_clock::now();
    BfMatch(descriptor1,descriptor2,matches);
    t2 = chrono::steady_clock::now();
    time_used = chrono::duration_cast<chrono::duration<double>>(t2-t1);
    cout<<"match ORB cost = "<<time_used.count()<<" seconds."<<endl;
    cout<<"matches : "<<matches.size();

    cv::Mat image_show;
    cv::drawMatches(img1,keypoints1,img2,keypoints2,matches,image_show);
    cv::imshow("matches",image_show);
    cv::imwrite("matches.png",image_show);
    cv::waitKey(0);
   
    cout<<"done !"<<endl;
    return 0;    
} 
//orb图像(x1,y1,x2,y2),不用管
int ORB_pattern[256 * 4] = {
  8, -3, 9, 5/*mean (0), correlation (0)*/,
  4, 2, 7, -12/*mean (1.12461e-05), correlation (0.0437584)*/,
  -11, 9, -8, 2/*mean (3.37382e-05), correlation (0.0617409)*/,
  7, -12, 12, -13/*mean (5.62303e-05), correlation (0.0636977)*/,
  2, -13, 2, 12/*mean (0.000134953), correlation (0.085099)*/,
  1, -7, 1, 6/*mean (0.000528565), correlation (0.0857175)*/,
  -2, -10, -2, -4/*mean (0.0188821), correlation (0.0985774)*/,
  -13, -13, -11, -8/*mean (0.0363135), correlation (0.0899616)*/,
  -13, -3, -12, -9/*mean (0.121806), correlation (0.099849)*/,
  10, 4, 11, 9/*mean (0.122065), correlation (0.093285)*/,
  -13, -8, -8, -9/*mean (0.162787), correlation (0.0942748)*/,
  -11, 7, -9, 12/*mean (0.21561), correlation (0.0974438)*/,
  7, 7, 12, 6/*mean (0.160583), correlation (0.130064)*/,
  -4, -5, -3, 0/*mean (0.228171), correlation (0.132998)*/,
  -13, 2, -12, -3/*mean (0.00997526), correlation (0.145926)*/,
  -9, 0, -7, 5/*mean (0.198234), correlation (0.143636)*/,
  12, -6, 12, -1/*mean (0.0676226), correlation (0.16689)*/,
  -3, 6, -2, 12/*mean (0.166847), correlation (0.171682)*/,
  -6, -13, -4, -8/*mean (0.101215), correlation (0.179716)*/,
  11, -13, 12, -8/*mean (0.200641), correlation (0.192279)*/,
  4, 7, 5, 1/*mean (0.205106), correlation (0.186848)*/,
  5, -3, 10, -3/*mean (0.234908), correlation (0.192319)*/,
  3, -7, 6, 12/*mean (0.0709964), correlation (0.210872)*/,
  -8, -7, -6, -2/*mean (0.0939834), correlation (0.212589)*/,
  -2, 11, -1, -10/*mean (0.127778), correlation (0.20866)*/,
  -13, 12, -8, 10/*mean (0.14783), correlation (0.206356)*/,
  -7, 3, -5, -3/*mean (0.182141), correlation (0.198942)*/,
  -4, 2, -3, 7/*mean (0.188237), correlation (0.21384)*/,
  -10, -12, -6, 11/*mean (0.14865), correlation (0.23571)*/,
  5, -12, 6, -7/*mean (0.222312), correlation (0.23324)*/,
  5, -6, 7, -1/*mean (0.229082), correlation (0.23389)*/,
  1, 0, 4, -5/*mean (0.241577), correlation (0.215286)*/,
  9, 11, 11, -13/*mean (0.00338507), correlation (0.251373)*/,
  4, 7, 4, 12/*mean (0.131005), correlation (0.257622)*/,
  2, -1, 4, 4/*mean (0.152755), correlation (0.255205)*/,
  -4, -12, -2, 7/*mean (0.182771), correlation (0.244867)*/,
  -8, -5, -7, -10/*mean (0.186898), correlation (0.23901)*/,
  4, 11, 9, 12/*mean (0.226226), correlation (0.258255)*/,
  0, -8, 1, -13/*mean (0.0897886), correlation (0.274827)*/,
  -13, -2, -8, 2/*mean (0.148774), correlation (0.28065)*/,
  -3, -2, -2, 3/*mean (0.153048), correlation (0.283063)*/,
  -6, 9, -4, -9/*mean (0.169523), correlation (0.278248)*/,
  8, 12, 10, 7/*mean (0.225337), correlation (0.282851)*/,
  0, 9, 1, 3/*mean (0.226687), correlation (0.278734)*/,
  7, -5, 11, -10/*mean (0.00693882), correlation (0.305161)*/,
  -13, -6, -11, 0/*mean (0.0227283), correlation (0.300181)*/,
  10, 7, 12, 1/*mean (0.125517), correlation (0.31089)*/,
  -6, -3, -6, 12/*mean (0.131748), correlation (0.312779)*/,
  10, -9, 12, -4/*mean (0.144827), correlation (0.292797)*/,
  -13, 8, -8, -12/*mean (0.149202), correlation (0.308918)*/,
  -13, 0, -8, -4/*mean (0.160909), correlation (0.310013)*/,
  3, 3, 7, 8/*mean (0.177755), correlation (0.309394)*/,
  5, 7, 10, -7/*mean (0.212337), correlation (0.310315)*/,
  -1, 7, 1, -12/*mean (0.214429), correlation (0.311933)*/,
  3, -10, 5, 6/*mean (0.235807), correlation (0.313104)*/,
  2, -4, 3, -10/*mean (0.00494827), correlation (0.344948)*/,
  -13, 0, -13, 5/*mean (0.0549145), correlation (0.344675)*/,
  -13, -7, -12, 12/*mean (0.103385), correlation (0.342715)*/,
  -13, 3, -11, 8/*mean (0.134222), correlation (0.322922)*/,
  -7, 12, -4, 7/*mean (0.153284), correlation (0.337061)*/,
  6, -10, 12, 8/*mean (0.154881), correlation (0.329257)*/,
  -9, -1, -7, -6/*mean (0.200967), correlation (0.33312)*/,
  -2, -5, 0, 12/*mean (0.201518), correlation (0.340635)*/,
  -12, 5, -7, 5/*mean (0.207805), correlation (0.335631)*/,
  3, -10, 8, -13/*mean (0.224438), correlation (0.34504)*/,
  -7, -7, -4, 5/*mean (0.239361), correlation (0.338053)*/,
  -3, -2, -1, -7/*mean (0.240744), correlation (0.344322)*/,
  2, 9, 5, -11/*mean (0.242949), correlation (0.34145)*/,
  -11, -13, -5, -13/*mean (0.244028), correlation (0.336861)*/,
  -1, 6, 0, -1/*mean (0.247571), correlation (0.343684)*/,
  5, -3, 5, 2/*mean (0.000697256), correlation (0.357265)*/,
  -4, -13, -4, 12/*mean (0.00213675), correlation (0.373827)*/,
  -9, -6, -9, 6/*mean (0.0126856), correlation (0.373938)*/,
  -12, -10, -8, -4/*mean (0.0152497), correlation (0.364237)*/,
  10, 2, 12, -3/*mean (0.0299933), correlation (0.345292)*/,
  7, 12, 12, 12/*mean (0.0307242), correlation (0.366299)*/,
  -7, -13, -6, 5/*mean (0.0534975), correlation (0.368357)*/,
  -4, 9, -3, 4/*mean (0.099865), correlation (0.372276)*/,
  7, -1, 12, 2/*mean (0.117083), correlation (0.364529)*/,
  -7, 6, -5, 1/*mean (0.126125), correlation (0.369606)*/,
  -13, 11, -12, 5/*mean (0.130364), correlation (0.358502)*/,
  -3, 7, -2, -6/*mean (0.131691), correlation (0.375531)*/,
  7, -8, 12, -7/*mean (0.160166), correlation (0.379508)*/,
  -13, -7, -11, -12/*mean (0.167848), correlation (0.353343)*/,
  1, -3, 12, 12/*mean (0.183378), correlation (0.371916)*/,
  2, -6, 3, 0/*mean (0.228711), correlation (0.371761)*/,
  -4, 3, -2, -13/*mean (0.247211), correlation (0.364063)*/,
  -1, -13, 1, 9/*mean (0.249325), correlation (0.378139)*/,
  7, 1, 8, -6/*mean (0.000652272), correlation (0.411682)*/,
  1, -1, 3, 12/*mean (0.00248538), correlation (0.392988)*/,
  9, 1, 12, 6/*mean (0.0206815), correlation (0.386106)*/,
  -1, -9, -1, 3/*mean (0.0364485), correlation (0.410752)*/,
  -13, -13, -10, 5/*mean (0.0376068), correlation (0.398374)*/,
  7, 7, 10, 12/*mean (0.0424202), correlation (0.405663)*/,
  12, -5, 12, 9/*mean (0.0942645), correlation (0.410422)*/,
  6, 3, 7, 11/*mean (0.1074), correlation (0.413224)*/,
  5, -13, 6, 10/*mean (0.109256), correlation (0.408646)*/,
  2, -12, 2, 3/*mean (0.131691), correlation (0.416076)*/,
  3, 8, 4, -6/*mean (0.165081), correlation (0.417569)*/,
  2, 6, 12, -13/*mean (0.171874), correlation (0.408471)*/,
  9, -12, 10, 3/*mean (0.175146), correlation (0.41296)*/,
  -8, 4, -7, 9/*mean (0.183682), correlation (0.402956)*/,
  -11, 12, -4, -6/*mean (0.184672), correlation (0.416125)*/,
  1, 12, 2, -8/*mean (0.191487), correlation (0.386696)*/,
  6, -9, 7, -4/*mean (0.192668), correlation (0.394771)*/,
  2, 3, 3, -2/*mean (0.200157), correlation (0.408303)*/,
  6, 3, 11, 0/*mean (0.204588), correlation (0.411762)*/,
  3, -3, 8, -8/*mean (0.205904), correlation (0.416294)*/,
  7, 8, 9, 3/*mean (0.213237), correlation (0.409306)*/,
  -11, -5, -6, -4/*mean (0.243444), correlation (0.395069)*/,
  -10, 11, -5, 10/*mean (0.247672), correlation (0.413392)*/,
  -5, -8, -3, 12/*mean (0.24774), correlation (0.411416)*/,
  -10, 5, -9, 0/*mean (0.00213675), correlation (0.454003)*/,
  8, -1, 12, -6/*mean (0.0293635), correlation (0.455368)*/,
  4, -6, 6, -11/*mean (0.0404971), correlation (0.457393)*/,
  -10, 12, -8, 7/*mean (0.0481107), correlation (0.448364)*/,
  4, -2, 6, 7/*mean (0.050641), correlation (0.455019)*/,
  -2, 0, -2, 12/*mean (0.0525978), correlation (0.44338)*/,
  -5, -8, -5, 2/*mean (0.0629667), correlation (0.457096)*/,
  7, -6, 10, 12/*mean (0.0653846), correlation (0.445623)*/,
  -9, -13, -8, -8/*mean (0.0858749), correlation (0.449789)*/,
  -5, -13, -5, -2/*mean (0.122402), correlation (0.450201)*/,
  8, -8, 9, -13/*mean (0.125416), correlation (0.453224)*/,
  -9, -11, -9, 0/*mean (0.130128), correlation (0.458724)*/,
  1, -8, 1, -2/*mean (0.132467), correlation (0.440133)*/,
  7, -4, 9, 1/*mean (0.132692), correlation (0.454)*/,
  -2, 1, -1, -4/*mean (0.135695), correlation (0.455739)*/,
  11, -6, 12, -11/*mean (0.142904), correlation (0.446114)*/,
  -12, -9, -6, 4/*mean (0.146165), correlation (0.451473)*/,
  3, 7, 7, 12/*mean (0.147627), correlation (0.456643)*/,
  5, 5, 10, 8/*mean (0.152901), correlation (0.455036)*/,
  0, -4, 2, 8/*mean (0.167083), correlation (0.459315)*/,
  -9, 12, -5, -13/*mean (0.173234), correlation (0.454706)*/,
  0, 7, 2, 12/*mean (0.18312), correlation (0.433855)*/,
  -1, 2, 1, 7/*mean (0.185504), correlation (0.443838)*/,
  5, 11, 7, -9/*mean (0.185706), correlation (0.451123)*/,
  3, 5, 6, -8/*mean (0.188968), correlation (0.455808)*/,
  -13, -4, -8, 9/*mean (0.191667), correlation (0.459128)*/,
  -5, 9, -3, -3/*mean (0.193196), correlation (0.458364)*/,
  -4, -7, -3, -12/*mean (0.196536), correlation (0.455782)*/,
  6, 5, 8, 0/*mean (0.1972), correlation (0.450481)*/,
  -7, 6, -6, 12/*mean (0.199438), correlation (0.458156)*/,
  -13, 6, -5, -2/*mean (0.211224), correlation (0.449548)*/,
  1, -10, 3, 10/*mean (0.211718), correlation (0.440606)*/,
  4, 1, 8, -4/*mean (0.213034), correlation (0.443177)*/,
  -2, -2, 2, -13/*mean (0.234334), correlation (0.455304)*/,
  2, -12, 12, 12/*mean (0.235684), correlation (0.443436)*/,
  -2, -13, 0, -6/*mean (0.237674), correlation (0.452525)*/,
  4, 1, 9, 3/*mean (0.23962), correlation (0.444824)*/,
  -6, -10, -3, -5/*mean (0.248459), correlation (0.439621)*/,
  -3, -13, -1, 1/*mean (0.249505), correlation (0.456666)*/,
  7, 5, 12, -11/*mean (0.00119208), correlation (0.495466)*/,
  4, -2, 5, -7/*mean (0.00372245), correlation (0.484214)*/,
  -13, 9, -9, -5/*mean (0.00741116), correlation (0.499854)*/,
  7, 1, 8, 6/*mean (0.0208952), correlation (0.499773)*/,
  7, -8, 7, 6/*mean (0.0220085), correlation (0.501609)*/,
  -7, -4, -7, 1/*mean (0.0233806), correlation (0.496568)*/,
  -8, 11, -7, -8/*mean (0.0236505), correlation (0.489719)*/,
  -13, 6, -12, -8/*mean (0.0268781), correlation (0.503487)*/,
  2, 4, 3, 9/*mean (0.0323324), correlation (0.501938)*/,
  10, -5, 12, 3/*mean (0.0399235), correlation (0.494029)*/,
  -6, -5, -6, 7/*mean (0.0420153), correlation (0.486579)*/,
  8, -3, 9, -8/*mean (0.0548021), correlation (0.484237)*/,
  2, -12, 2, 8/*mean (0.0616622), correlation (0.496642)*/,
  -11, -2, -10, 3/*mean (0.0627755), correlation (0.498563)*/,
  -12, -13, -7, -9/*mean (0.0829622), correlation (0.495491)*/,
  -11, 0, -10, -5/*mean (0.0843342), correlation (0.487146)*/,
  5, -3, 11, 8/*mean (0.0929937), correlation (0.502315)*/,
  -2, -13, -1, 12/*mean (0.113327), correlation (0.48941)*/,
  -1, -8, 0, 9/*mean (0.132119), correlation (0.467268)*/,
  -13, -11, -12, -5/*mean (0.136269), correlation (0.498771)*/,
  -10, -2, -10, 11/*mean (0.142173), correlation (0.498714)*/,
  -3, 9, -2, -13/*mean (0.144141), correlation (0.491973)*/,
  2, -3, 3, 2/*mean (0.14892), correlation (0.500782)*/,
  -9, -13, -4, 0/*mean (0.150371), correlation (0.498211)*/,
  -4, 6, -3, -10/*mean (0.152159), correlation (0.495547)*/,
  -4, 12, -2, -7/*mean (0.156152), correlation (0.496925)*/,
  -6, -11, -4, 9/*mean (0.15749), correlation (0.499222)*/,
  6, -3, 6, 11/*mean (0.159211), correlation (0.503821)*/,
  -13, 11, -5, 5/*mean (0.162427), correlation (0.501907)*/,
  11, 11, 12, 6/*mean (0.16652), correlation (0.497632)*/,
  7, -5, 12, -2/*mean (0.169141), correlation (0.484474)*/,
  -1, 12, 0, 7/*mean (0.169456), correlation (0.495339)*/,
  -4, -8, -3, -2/*mean (0.171457), correlation (0.487251)*/,
  -7, 1, -6, 7/*mean (0.175), correlation (0.500024)*/,
  -13, -12, -8, -13/*mean (0.175866), correlation (0.497523)*/,
  -7, -2, -6, -8/*mean (0.178273), correlation (0.501854)*/,
  -8, 5, -6, -9/*mean (0.181107), correlation (0.494888)*/,
  -5, -1, -4, 5/*mean (0.190227), correlation (0.482557)*/,
  -13, 7, -8, 10/*mean (0.196739), correlation (0.496503)*/,
  1, 5, 5, -13/*mean (0.19973), correlation (0.499759)*/,
  1, 0, 10, -13/*mean (0.204465), correlation (0.49873)*/,
  9, 12, 10, -1/*mean (0.209334), correlation (0.49063)*/,
  5, -8, 10, -9/*mean (0.211134), correlation (0.503011)*/,
  -1, 11, 1, -13/*mean (0.212), correlation (0.499414)*/,
  -9, -3, -6, 2/*mean (0.212168), correlation (0.480739)*/,
  -1, -10, 1, 12/*mean (0.212731), correlation (0.502523)*/,
  -13, 1, -8, -10/*mean (0.21327), correlation (0.489786)*/,
  8, -11, 10, -6/*mean (0.214159), correlation (0.488246)*/,
  2, -13, 3, -6/*mean (0.216993), correlation (0.50287)*/,
  7, -13, 12, -9/*mean (0.223639), correlation (0.470502)*/,
  -10, -10, -5, -7/*mean (0.224089), correlation (0.500852)*/,
  -10, -8, -8, -13/*mean (0.228666), correlation (0.502629)*/,
  4, -6, 8, 5/*mean (0.22906), correlation (0.498305)*/,
  3, 12, 8, -13/*mean (0.233378), correlation (0.503825)*/,
  -4, 2, -3, -3/*mean (0.234323), correlation (0.476692)*/,
  5, -13, 10, -12/*mean (0.236392), correlation (0.475462)*/,
  4, -13, 5, -1/*mean (0.236842), correlation (0.504132)*/,
  -9, 9, -4, 3/*mean (0.236977), correlation (0.497739)*/,
  0, 3, 3, -9/*mean (0.24314), correlation (0.499398)*/,
  -12, 1, -6, 1/*mean (0.243297), correlation (0.489447)*/,
  3, 2, 4, -8/*mean (0.00155196), correlation (0.553496)*/,
  -10, -10, -10, 9/*mean (0.00239541), correlation (0.54297)*/,
  8, -13, 12, 12/*mean (0.0034413), correlation (0.544361)*/,
  -8, -12, -6, -5/*mean (0.003565), correlation (0.551225)*/,
  2, 2, 3, 7/*mean (0.00835583), correlation (0.55285)*/,
  10, 6, 11, -8/*mean (0.00885065), correlation (0.540913)*/,
  6, 8, 8, -12/*mean (0.0101552), correlation (0.551085)*/,
  -7, 10, -6, 5/*mean (0.0102227), correlation (0.533635)*/,
  -3, -9, -3, 9/*mean (0.0110211), correlation (0.543121)*/,
  -1, -13, -1, 5/*mean (0.0113473), correlation (0.550173)*/,
  -3, -7, -3, 4/*mean (0.0140913), correlation (0.554774)*/,
  -8, -2, -8, 3/*mean (0.017049), correlation (0.55461)*/,
  4, 2, 12, 12/*mean (0.01778), correlation (0.546921)*/,
  2, -5, 3, 11/*mean (0.0224022), correlation (0.549667)*/,
  6, -9, 11, -13/*mean (0.029161), correlation (0.546295)*/,
  3, -1, 7, 12/*mean (0.0303081), correlation (0.548599)*/,
  11, -1, 12, 4/*mean (0.0355151), correlation (0.523943)*/,
  -3, 0, -3, 6/*mean (0.0417904), correlation (0.543395)*/,
  4, -11, 4, 12/*mean (0.0487292), correlation (0.542818)*/,
  2, -4, 2, 1/*mean (0.0575124), correlation (0.554888)*/,
  -10, -6, -8, 1/*mean (0.0594242), correlation (0.544026)*/,
  -13, 7, -11, 1/*mean (0.0597391), correlation (0.550524)*/,
  -13, 12, -11, -13/*mean (0.0608974), correlation (0.55383)*/,
  6, 0, 11, -13/*mean (0.065126), correlation (0.552006)*/,
  0, -1, 1, 4/*mean (0.074224), correlation (0.546372)*/,
  -13, 3, -9, -2/*mean (0.0808592), correlation (0.554875)*/,
  -9, 8, -6, -3/*mean (0.0883378), correlation (0.551178)*/,
  -13, -6, -8, -2/*mean (0.0901035), correlation (0.548446)*/,
  5, -9, 8, 10/*mean (0.0949843), correlation (0.554694)*/,
  2, 7, 3, -9/*mean (0.0994152), correlation (0.550979)*/,
  -1, -6, -1, -1/*mean (0.10045), correlation (0.552714)*/,
  9, 5, 11, -2/*mean (0.100686), correlation (0.552594)*/,
  11, -3, 12, -8/*mean (0.101091), correlation (0.532394)*/,
  3, 0, 3, 5/*mean (0.101147), correlation (0.525576)*/,
  -1, 4, 0, 10/*mean (0.105263), correlation (0.531498)*/,
  3, -6, 4, 5/*mean (0.110785), correlation (0.540491)*/,
  -13, 0, -10, 5/*mean (0.112798), correlation (0.536582)*/,
  5, 8, 12, 11/*mean (0.114181), correlation (0.555793)*/,
  8, 9, 9, -6/*mean (0.117431), correlation (0.553763)*/,
  7, -4, 8, -12/*mean (0.118522), correlation (0.553452)*/,
  -10, 4, -10, 9/*mean (0.12094), correlation (0.554785)*/,
  7, 3, 12, 4/*mean (0.122582), correlation (0.555825)*/,
  9, -7, 10, -2/*mean (0.124978), correlation (0.549846)*/,
  7, 0, 12, -2/*mean (0.127002), correlation (0.537452)*/,
  -1, -6, 0, -11/*mean (0.127148), correlation (0.547401)*/
};

void ComputeORB(const cv::Mat &img,vector<cv::KeyPoint> &keypoints,vector<DescType> &descriptors)
{
    const int half_patch_size = 8;                 //检测关键点时选取的图像块边长
    const int half_boundary = 16;                  //计算描述子时选取的图像块边长
    int bad_points = 0;                            //这个bad_point在图像检测超过图像区域的时候计数
    for (auto &kp : keypoints)                     //keypoint是图像中心当图像中心到边界的距离小于上面定义的时候就是错误计算了
    {
        if(kp.pt.x<half_boundary ||kp.pt.y<half_boundary ||
           kp.pt.x>= img.cols - half_boundary||kp.pt.y >= img.rows - half_boundary)
           {
               bad_points++;
               descriptors.push_back({});
               continue;
           }
        
        float m01 = 0 ,m10 = 0;                    //计算图像块的矩                 
        for (int dx = -half_patch_size;dx < half_patch_size;++dx)
        {
            for (int dy = -half_patch_size; dy < half_patch_size; ++dy)
            {
                uchar pixel = img.at<uchar>(kp.pt.y+dy,kp.pt.x+dx);
                m10 += dx*pixel;
                m01 = dy*pixel;
            }
        
        }
        
        float m_sqrt = sqrt(m01*m01+m10*m10)+ 1e-18;   //特征点方向
        float sin_theta = m01 / m_sqrt;
        float cos_theta = m10 / m_sqrt;

        DescType descriptor(8,0);
        for (int i = 0; i < 8; i++)
        {
            uint32_t d = 0 ;
            for (int k = 0; k < 32; k++)
            {
                int idx_pq = i*32+k;
                cv::Point2f p(ORB_pattern[idx_pq * 4],ORB_pattern[idx_pq * 4 + 1]);
                cv::Point2f q(ORB_pattern[idx_pq * 4 +2],ORB_pattern[idx_pq * 4 +3]);
                //坐标旋转1绕2旋转theta
                //x= (x1 - x2)* cos(θ) - (y1 - y2)* sin(θ) + x2 = x1* cos(θ) - y1* sin(θ)
                //y= (x1 - x2)* sin(θ) + (y1 - y2)* cos(θ) + y2 = x1* sin(θ) + y1* cos(θ) 
                cv::Point2f pp = cv::Point2f(cos_theta * p.x - sin_theta * p.y, sin_theta * p.x + cos_theta * p.y)+ kp.pt;
                cv::Point2f qq = cv::Point2f(cos_theta * q.x - sin_theta * q.y, sin_theta * q.x + cos_theta * q.y)+ kp.pt;
                if (img.at<uchar>(pp.y, pp.x) < img.at<uchar>(qq.y, qq.x)) 
                {
                    d |= 1 << k;
                }
            }
            descriptor[i]=d;                //uint32_t d = 0; |= 是位操作运算符,a |= b 代表 a = a|b , 即把a和b做按位或(|)操作,结果赋值给a
        }
        descriptors.push_back(descriptor);
    }
    
    cout << "bad/total: " << bad_points << "/" << keypoints.size() << endl;
}

void BfMatch(const vector<DescType> &descriptor1,const vector<DescType> &descriptor2,vector<cv::DMatch> &matches)
{
  const int d_max = 40;

  for (int i = 0; i < descriptor1.size(); ++i) 
  {
      if (descriptor1[i].empty()) continue;
      cv::DMatch m{i, 0, 256};                                                //这个0和下面的trainIdx一样的意思
      for (int j = 0; j < descriptor2.size(); ++j)                            //256是两个描述子的汉明距离,也就是下面的distance
      {
          if (descriptor2[j].empty()) continue;
          int distance = 0;
          for (int k = 0; k < 8; k++) {                                       //_mm_popcnt计算1的个数
            distance += _mm_popcnt_u32(descriptor1[i][k] ^ descriptor2[j][k]);//a^b表示a与b按位异或
      }
      if (distance < d_max && distance < m.distance) 
      {
        m.distance = distance;                                                //两个特征点之间的距离
        m.trainIdx = j;                                                       //产生距离的下标
      }
    }
    if (m.distance < d_max)                                                   //筛选
    {
      matches.push_back(m);
    }
  }
}

位姿估计2d2d

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include "opencv2/imgcodecs/legacy/constants_c.h"

using namespace std;
using namespace cv;

void find_feature_matches                           //特征匹配
(
    const Mat &img_1, const Mat &img_2,
    std::vector<KeyPoint> &keypoints_1,
    std::vector<KeyPoint> &keypoints_2,
    std::vector<DMatch> &matches
);

void pose_estimation_2d2d                          //姿态估计
(
    std::vector<KeyPoint> keypoints_1,
    std::vector<KeyPoint> keypoints_2,
    std::vector<DMatch> matches,
    Mat &R, Mat &t
);

Point2d pixel2cam(const Point2d &p,const Mat &K);  //像素坐标转相机坐标

int main (int argc,char** argv)
{
    Mat img_1 = imread("/home/martin/桌面/code/odometry/1.png",CV_LOAD_IMAGE_COLOR);
    Mat img_2 = imread("/home/martin/桌面/code/odometry/2.png",CV_LOAD_IMAGE_COLOR);

    vector<KeyPoint> keypoints_1,keypoints_2;
    vector<DMatch> matches;
    find_feature_matches(img_1,img_2,keypoints_1,keypoints_2,matches);
    cout<<"totally found :"<<matches.size()<<" pairs of points"<<endl;

    Mat R,t;
    pose_estimation_2d2d(keypoints_1,keypoints_2,matches,R,t);

    Mat t_x = 
    (                                                      //应该是t.hat
        Mat_<double>(3,3)<<0,-t.at<double>(2,0),t.at<double>(1,0),
        t.at<double>(2,0),0,-t.at<double>(0,0),
        -t.at<double>(1,0),t.at<double>(0,0),0
    );
    cout<<"t_x"<<endl<<t_x*t<<endl;
    cout<<"t^R = "<<endl<<t_x*R<<endl;                     //本质矩阵

    Mat K = (Mat_<double>(3,3)<< 520.9, 0, 325.1, 0, 521.0, 249.7, 0, 0, 1);
    for (DMatch m:matches)
    {
        Point2d pt1 = pixel2cam(keypoints_1[m.queryIdx].pt,K); //queryIdx是前一个的下标
        Mat y1 = (Mat_<double>(3,1) << pt1.x,pt1.y,1);
        Point2d pt2 = pixel2cam(keypoints_2[m.trainIdx].pt,K);
        Mat y2 = (Mat_<double>(3,1) << pt2.x,pt2.y,1);
        Mat d = y2.t() * t_x * R * y1;
        cout<<"epipolar constraint = "<<d<<endl;          //对极约束
    }
    return 0;
}

void find_feature_matches
(   const Mat &img_1, const Mat &img_2,
    std::vector<KeyPoint> &keypoints_1,
    std::vector<KeyPoint> &keypoints_2,
    std::vector<DMatch> &matches)
{
    //同ORB调用
    Mat descriptors_1,descriptors_2;
    Ptr<FeatureDetector> detector = ORB::create();
    Ptr<DescriptorExtractor> descriptor = ORB::create();
    Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-Hamming");
    
    detector->detect(img_1,keypoints_1);
    detector->detect(img_2,keypoints_2);
    
    descriptor->compute(img_1,keypoints_1,descriptors_1);
    descriptor->compute(img_2,keypoints_2,descriptors_2);

    vector<DMatch> match;

    matcher->match(descriptors_1,descriptors_2,match);

    double min_dist = 10000, max_dist = 0;                //匹配点筛选

    for(int i= 0;i<descriptors_1.rows;i++)                //找出所有匹配对之间的最小和最大距离
    {                                                     //就是最相似的和最不相似的点之间的距离
        double dist = match[i].distance;
        if(dist < min_dist)
            min_dist = dist;        
        if(dist > max_dist)
            max_dist = dist;  
    }
    
    printf("--MAX dist : %f \n",max_dist);
    printf("--MIN dist : %f \n",min_dist);

    for (int i = 0; i < descriptors_1.rows; i++)
    {
        if(match[i].distance <= max(2 * min_dist,30.0))  //同之前的筛选
        {
            matches.push_back(match[i]);
        }
    }
    
}

Point2d pixel2cam(const Point2d &p, const Mat &K)        //坐标变换
{
    return Point2d
    (
        (p.x-K.at<double>(0,2))/K.at<double>(0,0),
        (p.y-K.at<double>(1,2))/K.at<double>(1,1)
    );
}
void pose_estimation_2d2d
(
    std::vector<KeyPoint> keypoints_1,
    std::vector<KeyPoint> keypoints_2,
    std::vector<DMatch> matches,
    Mat &R, Mat &t
)
{
    //相机内参
    Mat K = (Mat_<double>(3, 3) << 520.9, 0, 325.1, 0, 521.0, 249.7, 0, 0, 1);

    vector<Point2d> points1;
    vector<Point2d> points2;

    for (int i = 0; i < (int)matches.size(); i++)
    {
        points1.push_back(keypoints_1[matches[i].queryIdx].pt);
        points2.push_back(keypoints_2[matches[i].trainIdx].pt);
    }
    //基础矩阵
    Mat fundamental_matrix;
    fundamental_matrix = findFundamentalMat(points1 ,points2, FM_8POINT); //八点法计算
    cout<<"fundamental_matrix is "<<endl<<fundamental_matrix<<endl;
    
    //本质矩阵
    Point2d principal_point(325.1,249.7);           //相机光心
    double focal_length = 521;                      //相机焦距
    Mat essential_matrix;
    essential_matrix = findEssentialMat(points1,points2,focal_length,principal_point);
    cout<< "essential_matrix is "<<endl<<essential_matrix<<endl;

    //单应矩阵(平面用处大)
    Mat homography_matrix;
    homography_matrix = findHomography(points1,points2,RANSAC,3);
    cout<<"homography_matrix is "<<endl<<homography_matrix<<endl;

    recoverPose(essential_matrix,points1,points2,R,t,focal_length,principal_point);
    cout<<"R is "<<endl<<R<<endl;
    cout<<"t is "<<endl<<t<<endl;

}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SLAM学习笔记 的相关文章

  • 备赛电赛学习STM32(十四):MPU6050

    一 MPU6050的简介 6轴是3轴加速度 3轴角速度 9轴就是3轴加速度 3轴角速度 3轴磁场强度 10轴就是3轴加速度 3轴角速度 3轴磁场强度 气场强度 这么多的数据 经过融合之后可进一步得到姿态角或者叫欧拉角 以我们这个飞机为例 欧
  • 【STM32】STM32单片机结构及部件原理

    STM32是目前比较常见并且多功能的单片机 xff0c 要想学习STM32 xff0c 首先要去了解它的基本构成部分以及各部分的原理 单片机型号 xff1a 正点原子STM32F103ZET6 目录 STM32内部结构总览图 xff1a 2
  • hadoop伪分布模式搭建(详细步骤)

    一 前期准备 1 关闭防火墙 2 安装好JDK 3 准备hadoop安装包 二 安装hadoop伪分布模式 1 在home hadoop software 路径下创建hadooptmp目录 2 解压hadoop 3 3 0 tar gz 3
  • ZooKeeper does not recover

    ZooKeeper does not recover from crash when disk was full Description The disk that ZooKeeper was using filled up During
  • FreeRTOS基础知识学习笔记

    先说RTOS xff0c 在以前单片机中要执行完上一个程序才会执行下一个程序 xff08 当然有中断来临会先执行中断程序 xff09 xff0c 在RTOS中会将两个程序交叉进行 比如 xff0c 写作业和锻炼在单片机中写作业时锻炼是没有执
  • cmake使用教程(十,带你全面掌握高级知识点

    执行该脚本后 xff1a Stepfile git master cmake P write cmake Stepfile git master tree test test txt test txt write cmake 1 direc
  • 【回溯法】八皇后问题

    问题描述 在国际象棋棋盘 8 8 8 times8 8 8 上放置八个皇后 xff0c 要求每两个皇后之间不能直接吃掉对方 皇后
  • java——spring boot集成kafka——kafka线上问题优化——如何实现延迟消费

  • FreeRTOS入门笔记(任务管理,消息队列,信号量)

    FreeRTOS 一 任务 FreeRTOS操作系统支持多任务并发执行 xff0c 可以看成每个任务可以写一个 main 函数 xff0c 在死循环里执行 1 任务创建与删除 创建 xff08 1 xff09 任务可以在CubeMx中创建
  • java数组中删除元素或一个数组元素

    java数组中删除元素或一个数组元素 删除数组中单个元素删除数组中多个元素 xff08 数组表示 xff09 这里直接介绍两种情况 xff1a 1 删除数组中单个元素 2 删除数组中多个元素 xff08 数组表示 xff09 删除数组中单个
  • 大数据工具Maxwell的使用

    1 Maxwell简介 Maxwell 是由美国Zendesk公司开源 xff0c 用Java编写的MySQL变更数据抓取软件 它会实时监控Mysql数据库的数据变更操作 xff08 包括insert update delete xff09
  • YOLOV4-pytorch环境配置

    YOLOV4 pytorch环境配置 环境配置过程 xff1a 创建环境安装pytorch安装包遇到的坑 xff1a 1 scikit image2 opencv python 训练过程 xff1a 数据集格式转换 xff1a 训练过程中遇
  • 嵌入式服务器boa移植

    移植嵌入式服务器boa的过程 xff0c 在论坛里面可以搜到好多 xff0c 其中也会有出现错误时对应的解决方法 xff0c 在这里就不赘述了 在这里我介绍一下我移植过程中出现的问题 xff1a boa not found 总结一下这个问题
  • 数据架构简介

    01 数据架构的起源 追根溯源是一个数据人的底层思维逻辑 xff0c 因此 xff0c 我们先说一说数据架构的起源 xff08 来源也行 xff0c 一个意思 xff09 其实 xff0c 我们现在IT行业经常说的软件架构 系统架构 XX架
  • 【Python基础教程】print语法的使用

    大家好 xff0c 这里是万瑞科技 今天我们来学习一下Python中最基础的语法 print语法 首先我们来看一下print语法该怎样写 xff1a print 34 34 上面的语法是输出 打印某段文字的语法 但要注意 xff1a 语法中
  • STM32驱动步进电机 梯形算法库函数版

    关于梯形算法的原理查看 xff1a AVR446 Linear speed control of stepper motor 里面有原理和代码 xff08 库函数版F4 xff09 废话不多说直接上链接 xff1a 梯形算法驱动步进电机 z
  • VC6.0下载和安装教程

    Microsoft Visual C 43 43 xff0c xff08 简称Visual C 43 43 MSVC VC 43 43 或VC xff09 是Microsoft公司推出的以C 43 43 语言为基础的开发Windows环境程
  • Code::Blocks使用教程

    使用之前我们先准备一段代码 include lt stdio h gt include lt stdlib h gt int main printf 34 欢迎进入www dotcpp com编程网站 xff01 34 system 34
  • Dev-C++下载和安装教程

    Dev C 43 43 是一个Windows环境下的一个适合于初学者使用的轻量级 C C 43 43 集成开发环境 xff08 IDE xff09 它是一款自由软件 xff0c 遵守GPL许可协议分发源代码 它集合了MinGW中的GCC编译
  • Dev C++使用教程

    我们在使用之前先准备一段C语言代码 include lt stdio h gt int main printf 34 欢迎进入C语言网 xff01 34 return 0 初步使用这款软件 xff0c 我们先选择源文件进行创建 xff0c

随机推荐

  • Altium Designer安装教程

    Altium Designer 21软件简介 xff1a Altium Designer 21是一款由Altium开发团队全新推出的简单易用 xff0c 与时俱进 xff0c 功能强大的PCB设计软件 xff0c 可以方便用户快速完成各类原
  • Matlab 2021b安装教程-Matlab分析软件下载方法

    MATLAB是美国MathWorks公司出品的商业数学软件 xff0c 用于算法开发 数据可视化 数据分析以及数值计算的高级技术计算语言和交互式环境 xff0c 主要包括MATLAB和Simulink两大部分 下载方法 https docs
  • STM32嵌入式面试知识点总结

    一 STM32F1和F4的区别 xff1f 解答 xff1a 参看 xff1a STM32开发 STM32初识 内核不同 xff1a F1是Cortex M3内核 xff0c F4是Cortex M4内核 xff1b 主频不同 xff1a
  • Keil系列教程01_Keil介绍、下载、安装与注册

    1写在前面 对于学习单片机和嵌入式开发的朋友来说 xff0c 掌握Keil这款软件可以说是必备的技能 鉴于目前网上没有完整的Keil教程 xff0c 因此我打算整理一套完整的Keil系列教程 目前Keil有四种产品 xff08 软件 xff
  • Keil系列教程02_新建基础软件工程

    1写在前面 目前Keil的四款产品 xff08 软件 xff09 xff1a MDK ARM C51 C251 C166 xff0c 在用法上极为相似 xff0c 包括本文讲述的新建软件工程 本文以目前 xff08 2018年10月 xff
  • 机器学习多分类器有哪些

    常见的有 xff1a 决策树分类器 xff08 Decision Tree Classifier xff09 支持向量机分类器 xff08 Support Vector Machine Classifier xff09 朴素贝叶斯分类器 x
  • Keil系列教程03_主窗口和工具栏详细说明

    1写在前面 本文先让大家简单认识一下Keil的主窗口界面 xff0c 然后再进一步认识Keil的文件 编译和调试工具栏 Toolbars工具栏就是在菜单下面的两行快捷图标按钮 xff0c 这些快捷按钮之所以在工具栏里面 xff0c 在于它们
  • 【Linux驱动】Linux--V4L2视频驱动框架

    Linux V4L2视频驱动框架 Linux V4L2驱动框架一 V4L2 框架二 V4L2驱动主要数据结构三 V4L2提供的外部接口四 V4L2驱动框架模板五 虚拟摄像头驱动 参考资料 Linux V4L2驱动框架 一 V4L2 框架 v
  • PostMan——安装使用教程(图文详解)

    为了验证接口能否被正常访问 xff0c 我们常常需要使用测试工具 xff0c 来对数据接口进行检测 好处 xff1a 接口测试工具能让我们在不写任何代码的情况下 xff0c 对接口进行调用和调试 下载并安装PostMan 首先 xff0c
  • c++中::和:的区别

    在 C 43 43 中 xff0c 34 34 和 34 34 都是类成员初始化的运算符 34 34 是域运算符 xff0c 用于访问类的静态成员 xff0c 如静态变量和静态函数 在这里我们给出一个例子 xff1a class A pub
  • 程序=算法+数据结构

    JAVA 数据结构 及 基础算法 算法 xff1a 解决问题的流程 步骤 xff08 分支 循环 顺序 xff09 数据结构 xff1a 将数据按照某种特定的结构来保存 设计良好的数据结构会导致好的算法 凭借一句话获得图灵奖的Pascal之
  • 【嵌入式】stm32+freeRTOS移植与应用

    freeRTOS 源码移植 手动移植 xff1a freeRTOS官网 点击Download FreeRTOS点击Download解压zip文件 FreeRTOS是内核文件夹 xff0c 只需关注这个 FreeRTOS Demo 示例程序
  • benchmark

    一 定义 xff1a benchmark译为基准测试 xff0c 基准测试是指通过设计科学的测试方法 测试工具和测试系统 xff0c 实现对一类测试对象的某项性能指标进行定量的和可对比的测试 二 基准的特征 xff1a 相关性 基准应该度量
  • 在 Linux Ubuntu / Windows 10配置 RealSense 开发环境 开发预处理以及了解树莓派3

    Linux Ubuntu 首先 xff0c 打开Intel Realsense 官网 Intel RealSense Computer Vision Depth and Tracking cameras intelrealsense com
  • Docker的安装(基于windows的安装)

    在安装windows前需要有几个准备工作 1 启用Hyper V以在 Windows 10上创建虚拟机 xff1a a 使用 PowerShell 启用 Hyper V 在windows中搜索powerShell 使用管理员身份打开控制台
  • 提交代码前未拉取代码,导致冲突及解决办法

    前提 xff1a 和同事协作开发代码 xff0c 用git管理的项目 xff0c 在vscode可视化工具里面拉取项目代码 xff0c 没有反应 xff0c 然后在git里git pull xff0c 也没拉到远端的代码 xff0c 就提交
  • static 静态成员变量 静态成员函数 类中使用

    关于在类中使用static的一些情况 xff1a 静态成员函数和静态成员变量的调用格式 xff0c 尽量采用类名 成员的格式 xff0c 不要以对象来调用 1 static func静态成员函数 1 其地址可以直接由函数指针来存储 xff0
  • ucosii消息队列学习

    近期在学习ucosii的内容使用的平台为STM32F103C8T6最小系统板 今日关于消息队列的使用遇到了一些问题 基本情况 xff1a 移植代码为正点原子ucosiii消息队列 信号量集和软件定时器例程 主要新建两个任务post task
  • day41—编程题

    文章目录 1 第一题1 1题目1 2思路1 3解题 2 第二题2 1题目2 2思路2 3解题 1 第一题 1 1题目 描述 xff1a Emacs号称神的编辑器 xff0c 它自带了一个计算器 与其他计算器不同 xff0c 它是基于后缀表达
  • SLAM学习笔记

    编译环境参考之前的笔记 cmake文件 cmake minimum required VERSION 3 0 project odometry set CMAKE BUILD TYPE 34 Release 34 add definitio