Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
d09b4041
Commit
d09b4041
authored
Aug 09, 2014
by
edgarriba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tutorial update
parent
7ecad71a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
76 deletions
+52
-76
main_registration.cpp
...lib3d/real_time_pose_estimation/src/main_registration.cpp
+52
-76
No files found.
samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/main_registration.cpp
View file @
d09b4041
// C++
#include <iostream>
#include <iostream>
// OpenCV
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/nonfree/features2d.hpp>
// PnP Tutorial
#include "Mesh.h"
#include "Mesh.h"
#include "Model.h"
#include "Model.h"
#include "PnPProblem.h"
#include "PnPProblem.h"
...
@@ -7,75 +14,50 @@
...
@@ -7,75 +14,50 @@
#include "ModelRegistration.h"
#include "ModelRegistration.h"
#include "Utils.h"
#include "Utils.h"
#include <opencv2/core/core.hpp>
/** GLOBAL VARIABLES **/
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/nonfree/features2d.hpp>
/*
* Set up the images paths
*/
// COOKIES BOX [718x480]
std
::
string
img_path
=
"../Data/resized_IMG_3875.JPG"
;
// f 55
// COOKIES BOX MESH
std
::
string
tutorial_path
=
"../../samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/"
;
// path to tutorial
std
::
string
ply_read_path
=
"../Data/box.ply"
;
// YAML writting path
std
::
string
img_path
=
tutorial_path
+
"Data/resized_IMG_3875.JPG"
;
// image to register
std
::
string
write_path
=
"../Data/cookies_ORB.yml"
;
std
::
string
ply_read_path
=
tutorial_path
+
"Data/box.ply"
;
// object mesh
std
::
string
write_path
=
tutorial_path
+
"Data/cookies_ORB.yml"
;
// output file
void
help
()
{
std
::
cout
<<
"--------------------------------------------------------------------------"
<<
std
::
endl
<<
"This program shows how to create your 3D textured model. "
<<
std
::
endl
<<
"Usage:"
<<
std
::
endl
<<
"./pnp_registration "
<<
std
::
endl
<<
"--------------------------------------------------------------------------"
<<
std
::
endl
<<
std
::
endl
;
}
// Boolean the know if the registration it's done
// Boolean the know if the registration it's done
bool
end_registration
=
false
;
bool
end_registration
=
false
;
/*
// Intrinsic camera parameters: UVC WEBCAM
* Set up the intrinsic camera parameters: CANON
double
f
=
45
;
// focal length in mm
*/
double
sx
=
22.3
,
sy
=
14.9
;
double
f
=
45
;
// focal length in mm
double
width
=
2592
,
height
=
1944
;
double
sx
=
22.3
,
sy
=
14.9
;
double
params_CANON
[]
=
{
width
*
f
/
sx
,
// fx
double
width
=
2592
,
height
=
1944
;
double
params_CANON
[]
=
{
width
*
f
/
sx
,
// fx
height
*
f
/
sy
,
// fy
height
*
f
/
sy
,
// fy
width
/
2
,
// cx
width
/
2
,
// cx
height
/
2
};
// cy
height
/
2
};
// cy
// Setup the points to register in the image
// In the order of the *.ply file and starting at 1
int
n
=
8
;
int
pts
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
};
// 3 -> 4
// Setup the points to register in the image
// Some basic colors
// In the order of the *.ply file and starting at 1
cv
::
Scalar
red
(
0
,
0
,
255
);
int
n
=
8
;
cv
::
Scalar
green
(
0
,
255
,
0
);
int
pts
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
};
// 3 -> 4
cv
::
Scalar
blue
(
255
,
0
,
0
);
cv
::
Scalar
yellow
(
0
,
255
,
255
);
/*
* Set up some basic colors
*/
cv
::
Scalar
red
(
0
,
0
,
255
);
cv
::
Scalar
green
(
0
,
255
,
0
);
cv
::
Scalar
blue
(
255
,
0
,
0
);
cv
::
Scalar
yellow
(
0
,
255
,
255
);
/*
/*
* CREATE MODEL REGISTRATION OBJECT
* CREATE MODEL REGISTRATION OBJECT
* CREATE OBJECT MESH
* CREATE OBJECT MESH
* CREATE OBJECT MODEL
* CREATE OBJECT MODEL
* CREATE PNP OBJECT
* CREATE PNP OBJECT
*/
*/
ModelRegistration
registration
;
ModelRegistration
registration
;
Model
model
;
Model
model
;
Mesh
mesh
;
Mesh
mesh
;
PnPProblem
pnp_registration
(
params_CANON
);
PnPProblem
pnp_registration
(
params_CANON
);
/** Functions headers **/
void
help
();
// Mouse events for model registration
// Mouse events for model registration
static
void
onMouseModelRegistration
(
int
event
,
int
x
,
int
y
,
int
,
void
*
)
static
void
onMouseModelRegistration
(
int
event
,
int
x
,
int
y
,
int
,
void
*
)
...
@@ -97,11 +79,7 @@ static void onMouseModelRegistration( int event, int x, int y, int, void* )
...
@@ -97,11 +79,7 @@ static void onMouseModelRegistration( int event, int x, int y, int, void* )
}
}
}
}
/*
/** Main program **/
* MAIN PROGRAM
*
*/
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
...
@@ -118,11 +96,7 @@ int main(int argc, char *argv[])
...
@@ -118,11 +96,7 @@ int main(int argc, char *argv[])
cv
::
FeatureDetector
*
detector
=
new
cv
::
OrbFeatureDetector
(
numKeyPoints
);
cv
::
FeatureDetector
*
detector
=
new
cv
::
OrbFeatureDetector
(
numKeyPoints
);
rmatcher
.
setFeatureDetector
(
detector
);
rmatcher
.
setFeatureDetector
(
detector
);
/*
/** GROUND TRUTH OF THE FIRST IMAGE **/
* GROUND TRUTH OF THE FIRST IMAGE
*
* by the moment it is the reference image
*/
// Create & Open Window
// Create & Open Window
cv
::
namedWindow
(
"MODEL REGISTRATION"
,
cv
::
WINDOW_KEEPRATIO
);
cv
::
namedWindow
(
"MODEL REGISTRATION"
,
cv
::
WINDOW_KEEPRATIO
);
...
@@ -183,12 +157,7 @@ int main(int argc, char *argv[])
...
@@ -183,12 +157,7 @@ int main(int argc, char *argv[])
cv
::
imshow
(
"MODEL REGISTRATION"
,
img_vis
);
cv
::
imshow
(
"MODEL REGISTRATION"
,
img_vis
);
}
}
/** COMPUTE CAMERA POSE **/
/*
*
* COMPUTE CAMERA POSE
*
*/
std
::
cout
<<
"COMPUTING POSE ..."
<<
std
::
endl
;
std
::
cout
<<
"COMPUTING POSE ..."
<<
std
::
endl
;
...
@@ -217,12 +186,7 @@ int main(int argc, char *argv[])
...
@@ -217,12 +186,7 @@ int main(int argc, char *argv[])
cv
::
waitKey
(
0
);
cv
::
waitKey
(
0
);
/*
/** COMPUTE 3D of the image Keypoints **/
*
* COMPUTE 3D of the image Keypoints
*
*/
// Containers for keypoints and descriptors of the model
// Containers for keypoints and descriptors of the model
std
::
vector
<
cv
::
KeyPoint
>
keypoints_model
;
std
::
vector
<
cv
::
KeyPoint
>
keypoints_model
;
...
@@ -288,3 +252,15 @@ int main(int argc, char *argv[])
...
@@ -288,3 +252,15 @@ int main(int argc, char *argv[])
std
::
cout
<<
"GOODBYE"
<<
std
::
endl
;
std
::
cout
<<
"GOODBYE"
<<
std
::
endl
;
}
}
/**********************************************************************************************************/
void
help
()
{
std
::
cout
<<
"--------------------------------------------------------------------------"
<<
std
::
endl
<<
"This program shows how to create your 3D textured model. "
<<
std
::
endl
<<
"Usage:"
<<
std
::
endl
<<
"./cpp-tutorial-pnp_registration"
<<
std
::
endl
<<
"--------------------------------------------------------------------------"
<<
std
::
endl
<<
std
::
endl
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment