-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 21332f5
Showing
8 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(extract_match_line) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
#OpenCV | ||
find_package(OpenCV) | ||
include_directories(OpenCV_INCLUDE_DIRS) | ||
|
||
#glogging | ||
find_package(Glog REQUIRED) | ||
|
||
#line_descriptor_opencvm | ||
include_directories(${PROJECT_SOURCE_DIR}/line_descriptor_opencvm/include) | ||
|
||
add_executable(extract_match_line main.cpp) | ||
target_link_libraries(extract_match_line | ||
${OpenCV_LIBS} | ||
${Glog_LIBRARIES} | ||
${PROJECT_SOURCE_DIR}/line_descriptor_opencvm/lib/liblinedesc.so | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# 目标 | ||
由于OpenCV3.4.6及以后版本将LSD线特征提取算法从代码中剔除,本库通过对OpenCV3.4.2及OpenCV-Contrib3.4.2的源代码中代码提取,提取出单独的LSD线特征提取算法并封装在cvm命名空间中。 | ||
|
||
# 使用方式 | ||
先进入line_descriptor_opencvm文件夹,然后 | ||
``` | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
``` | ||
之后会获得相应编译出的LSD算法的头文件和共享库文件 | ||
然后对main函数进行cmake编译运行即可。就能得到两张图像的线特征提取,匹配的结果。 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <iostream> | ||
#include <vector> | ||
using std::cout; | ||
using std::endl; | ||
using std::vector; | ||
using std::string; | ||
|
||
#include <glog/logging.h> | ||
|
||
#include <opencv2/opencv.hpp> | ||
#include "descriptor_opencvm.hpp" | ||
|
||
#include <Eigen/Core> | ||
#include <Eigen/Geometry> | ||
|
||
int main(int argc, char** argv) { | ||
//读入图像 | ||
google::InitGoogleLogging(argv[0]); | ||
google::InstallFailureSignalHandler(); | ||
FLAGS_logtostderr=true; | ||
|
||
double fx=481.2; | ||
double fy=480; | ||
double cx=319.5; | ||
double cy=239.5; | ||
//读入图像 | ||
cv::Mat color1 = cv::imread("../0.png",-1); //先读入一帧RGB和depth | ||
cv::Mat color2 = cv::imread("../50.png",-1); | ||
if ( color1.data==nullptr || color2.empty()){ | ||
cout<<"wrong input rgb image"<<endl; | ||
} | ||
//初始化 | ||
cv::Ptr<cvm::line_descriptor::LSDDetector> lsd = cvm::line_descriptor::LSDDetector::createLSDDetector(); | ||
cv::Ptr<cvm::line_descriptor::BinaryDescriptor> lbd = cvm::line_descriptor::BinaryDescriptor::createBinaryDescriptor(); | ||
|
||
//提取图1的线特征 | ||
std::vector<cvm::line_descriptor::KeyLine> keylines1; | ||
lsd->detect(color1, keylines1, 1.2, 1); //提取线特征并计算描述子 | ||
LOG(INFO)<<"Extract line1 num = "<<keylines1.size(); | ||
cv::Mat ldesc1; | ||
lbd->compute(color1, keylines1, ldesc1); //计算特征线段的描述子 | ||
cv::Mat outlinesimg1; | ||
cvm::line_descriptor::drawKeylines(color1,keylines1,outlinesimg1); | ||
cv::imwrite("../colorline1.png",outlinesimg1); | ||
|
||
//提取图2的线特征 | ||
std::vector<cvm::line_descriptor::KeyLine> keylines2; | ||
lsd->detect(color2, keylines2, 1.2, 1); //提取线特征并计算描述子 | ||
LOG(INFO)<<"Extract line2 num = "<<keylines2.size(); | ||
cv::Mat ldesc2; | ||
lbd->compute(color2, keylines2, ldesc2); //计算特征线段的描述子 | ||
cv::Mat outlinesimg2; | ||
cvm::line_descriptor::drawKeylines(color2,keylines2,outlinesimg2); | ||
cv::imwrite("../colorline2.png",outlinesimg2); | ||
//匹配 | ||
cv::Ptr<cvm::line_descriptor::BinaryDescriptorMatcher> bdm=cvm::line_descriptor::BinaryDescriptorMatcher::createBinaryDescriptorMatcher(); | ||
std::vector<cv::DMatch> matches; | ||
bdm->match(ldesc1,ldesc2,matches); | ||
cv::Mat out_match_img; | ||
LOG(INFO)<<"match num = "<<matches.size(); | ||
|
||
const std::vector<char> matchesMask(matches.size(),1); | ||
cvm::line_descriptor::drawLineMatches(color1,keylines1,color2,keylines2,matches,out_match_img, | ||
cv::Scalar::all(-1),cv::Scalar::all(-1),matchesMask,cvm::line_descriptor::DrawLinesMatchesFlags::DEFAULT); | ||
cv::imwrite("../match_1_2.png",out_match_img); | ||
|
||
std::cout << "Hello, World!" << std::endl; | ||
return 0; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.