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
2d2cc3ec
Commit
2d2cc3ec
authored
Jun 14, 2010
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated
parent
365e6b7b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
15 deletions
+12
-15
build3dmodel.cpp
samples/cpp/build3dmodel.cpp
+3
-11
select3dobj.cpp
samples/cpp/select3dobj.cpp
+9
-4
No files found.
samples/cpp/build3dmodel.cpp
View file @
2d2cc3ec
...
@@ -270,7 +270,7 @@ static Point3f triangulatePoint(const vector<Point2f>& ps,
...
@@ -270,7 +270,7 @@ static Point3f triangulatePoint(const vector<Point2f>& ps,
{
{
Mat_
<
double
>
K
(
cameraMatrix
);
Mat_
<
double
>
K
(
cameraMatrix
);
if
(
ps
.
size
()
>
2
)
/*
if( ps.size() > 2 )
{
{
Mat_<double> L(ps.size()*3, 4), U, evalues;
Mat_<double> L(ps.size()*3, 4), U, evalues;
Mat_<double> P(3,4), Rt(3,4), Rt_part1=Rt.colRange(0,3), Rt_part2=Rt.colRange(3,4);
Mat_<double> P(3,4), Rt(3,4), Rt_part1=Rt.colRange(0,3), Rt_part2=Rt.colRange(3,4);
...
@@ -296,7 +296,7 @@ static Point3f triangulatePoint(const vector<Point2f>& ps,
...
@@ -296,7 +296,7 @@ static Point3f triangulatePoint(const vector<Point2f>& ps,
double W = fabs(U(3,3)) > FLT_EPSILON ? 1./U(3,3) : 0;
double W = fabs(U(3,3)) > FLT_EPSILON ? 1./U(3,3) : 0;
return Point3f((float)(U(3,0)*W), (float)(U(3,1)*W), (float)(U(3,2)*W));
return Point3f((float)(U(3,0)*W), (float)(U(3,1)*W), (float)(U(3,2)*W));
}
}
else
else
*/
{
{
Mat_
<
float
>
iK
=
K
.
inv
();
Mat_
<
float
>
iK
=
K
.
inv
();
Mat_
<
float
>
R1t
=
Mat_
<
float
>
(
Rs
[
0
]).
t
();
Mat_
<
float
>
R1t
=
Mat_
<
float
>
(
Rs
[
0
]).
t
();
...
@@ -497,18 +497,10 @@ static void build3dmodel( const Ptr<FeatureDetector>& detector,
...
@@ -497,18 +497,10 @@ static void build3dmodel( const Ptr<FeatureDetector>& detector,
double
e1
=
norm
(
imgpts1
[
0
]
-
keypoints1
[
i1
].
pt
);
double
e1
=
norm
(
imgpts1
[
0
]
-
keypoints1
[
i1
].
pt
);
double
e2
=
norm
(
imgpts2
[
0
]
-
keypoints2
[
i2
].
pt
);
double
e2
=
norm
(
imgpts2
[
0
]
-
keypoints2
[
i2
].
pt
);
if
(
e1
+
e2
>
10
)
if
(
e1
+
e2
>
5
)
continue
;
continue
;
pairsFound
++
;
pairsFound
++
;
//pts_k[0] = imgpts1[0];
//pts_k[1] = imgpts2[0];
//objpt = triangulatePoint(pts_k, Rs_k, ts_k, cameraMatrix);
//objpts[0] = objpt;
//projectPoints(Mat(objpts), Rs_k[0], ts_k[0], cameraMatrix, Mat(), imgpts1);
//projectPoints(Mat(objpts), Rs_k[1], ts_k[1], cameraMatrix, Mat(), imgpts2);
//double e1 = norm(imgpts1[0] - keypoints1[i1].pt);
//double e2 = norm(imgpts2[0] - keypoints2[i2].pt);
//model.points.push_back(objpt);
//model.points.push_back(objpt);
pairs
[
Pair2i
(
i1
+
dstart
[
i
],
i2
+
dstart
[
j
])]
=
1
;
pairs
[
Pair2i
(
i1
+
dstart
[
i
],
i2
+
dstart
[
j
])]
=
1
;
...
...
samples/cpp/select3dobj.cpp
View file @
2d2cc3ec
...
@@ -67,7 +67,7 @@ static Point3f image2plane(Point2f imgpt, const Mat& R, const Mat& tvec,
...
@@ -67,7 +67,7 @@ static Point3f image2plane(Point2f imgpt, const Mat& R, const Mat& tvec,
static
Rect
extract3DBox
(
const
Mat
&
frame
,
Mat
&
shownFrame
,
Mat
&
selectedObjFrame
,
static
Rect
extract3DBox
(
const
Mat
&
frame
,
Mat
&
shownFrame
,
Mat
&
selectedObjFrame
,
const
Mat
&
cameraMatrix
,
const
Mat
&
rvec
,
const
Mat
&
tvec
,
const
Mat
&
cameraMatrix
,
const
Mat
&
rvec
,
const
Mat
&
tvec
,
const
vector
<
Point3f
>&
box
,
int
nobjpt
)
const
vector
<
Point3f
>&
box
,
int
nobjpt
,
bool
runExtraSegmentation
)
{
{
selectedObjFrame
=
Mat
::
zeros
(
frame
.
size
(),
frame
.
type
());
selectedObjFrame
=
Mat
::
zeros
(
frame
.
size
(),
frame
.
type
());
if
(
nobjpt
==
0
)
if
(
nobjpt
==
0
)
...
@@ -120,8 +120,13 @@ static Rect extract3DBox(const Mat& frame, Mat& shownFrame, Mat& selectedObjFram
...
@@ -120,8 +120,13 @@ static Rect extract3DBox(const Mat& frame, Mat& shownFrame, Mat& selectedObjFram
convexHull
(
Mat_
<
Point
>
(
Mat
(
imgpt
)),
hull
);
convexHull
(
Mat_
<
Point
>
(
Mat
(
imgpt
)),
hull
);
Mat
selectedObjMask
=
Mat
::
zeros
(
frame
.
size
(),
CV_8U
);
Mat
selectedObjMask
=
Mat
::
zeros
(
frame
.
size
(),
CV_8U
);
fillConvexPoly
(
selectedObjMask
,
&
hull
[
0
],
hull
.
size
(),
Scalar
::
all
(
255
),
8
,
0
);
fillConvexPoly
(
selectedObjMask
,
&
hull
[
0
],
hull
.
size
(),
Scalar
::
all
(
255
),
8
,
0
);
Rect
roi
=
boundingRect
(
Mat
(
hull
))
&
Rect
(
Point
(),
frame
.
size
());
///////////////// insert GrabCut here ////////////////////
//////////////////////////////////////////////////////////
frame
.
copyTo
(
selectedObjFrame
,
selectedObjMask
);
frame
.
copyTo
(
selectedObjFrame
,
selectedObjMask
);
return
boundingRect
(
Mat
(
hull
))
&
Rect
(
Point
(),
frame
.
size
())
;
return
roi
;
}
}
...
@@ -211,7 +216,7 @@ static int select3DBox(const string& windowname, const string& selWinName, const
...
@@ -211,7 +216,7 @@ static int select3DBox(const string& windowname, const string& selWinName, const
frame
.
copyTo
(
shownFrame
);
frame
.
copyTo
(
shownFrame
);
extract3DBox
(
frame
,
shownFrame
,
selectedObjFrame
,
extract3DBox
(
frame
,
shownFrame
,
selectedObjFrame
,
cameraMatrix
,
rvec
,
tvec
,
box
,
npt
);
cameraMatrix
,
rvec
,
tvec
,
box
,
npt
,
false
);
imshow
(
windowname
,
shownFrame
);
imshow
(
windowname
,
shownFrame
);
imshow
(
selWinName
,
selectedObjFrame
);
imshow
(
selWinName
,
selectedObjFrame
);
...
@@ -500,7 +505,7 @@ int main(int argc, char** argv)
...
@@ -500,7 +505,7 @@ int main(int argc, char** argv)
if
(
!
box
.
empty
()
)
if
(
!
box
.
empty
()
)
{
{
Rect
r
=
extract3DBox
(
frame
,
shownFrame
,
selectedObjFrame
,
Rect
r
=
extract3DBox
(
frame
,
shownFrame
,
selectedObjFrame
,
cameraMatrix
,
rvec
,
tvec
,
box
,
4
);
cameraMatrix
,
rvec
,
tvec
,
box
,
4
,
true
);
if
(
r
.
area
()
)
if
(
r
.
area
()
)
{
{
const
int
maxFrameIdx
=
10000
;
const
int
maxFrameIdx
=
10000
;
...
...
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