Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the code of Lesson3 to support the OpenCV 3.x #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion part III/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
PROJECT( slam )

add_definitions(-std=c++11)
SET(CMAKE_CXX_COMPILER "g++")
SET( CMAKE_BUILD_TYPE Debug )
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
Expand Down
9 changes: 5 additions & 4 deletions part III/src/detectFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
> Mail: [email protected]
> 特征提取与匹配
> Created Time: 2015年07月18日 星期六 16时00分21秒
> Modify: To support OpenCV v3.4.1
************************************************************************/

#include<iostream>
Expand Down Expand Up @@ -34,8 +35,8 @@ int main( int argc, char** argv )
// _detector = cv::FeatureDetector::create( "SIFT" );
// _descriptor = cv::DescriptorExtractor::create( "SIFT" );

detector = cv::FeatureDetector::create("ORB");
descriptor = cv::DescriptorExtractor::create("ORB");
detector = cv::ORB::create();
descriptor = cv::ORB::create();

vector< cv::KeyPoint > kp1, kp2; //关键点
detector->detect( rgb1, kp1 ); //提取关键点
Expand Down Expand Up @@ -134,8 +135,8 @@ int main( int argc, char** argv )
// 构建相机矩阵
cv::Mat cameraMatrix( 3, 3, CV_64F, camera_matrix_data );
cv::Mat rvec, tvec, inliers;
// 求解pnp
cv::solvePnPRansac( pts_obj, pts_img, cameraMatrix, cv::Mat(), rvec, tvec, false, 100, 1.0, 100, inliers );
// 求解pnp the confidence should be in (0, 1) in Opencv 3.x
cv::solvePnPRansac( pts_obj, pts_img, cameraMatrix, cv::Mat(), rvec, tvec, false, 100, 1.0, 0.99, inliers );

cout<<"inliers: "<<inliers.rows<<endl;
cout<<"R="<<rvec<<endl;
Expand Down