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
83799d6b
Commit
83799d6b
authored
Oct 12, 2012
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Mat indexing in TrackingMotion tutorial code (supersedes pull request #38)
parent
30471486
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
cornerDetector_Demo.cpp
.../cpp/tutorial_code/TrackingMotion/cornerDetector_Demo.cpp
+10
-10
No files found.
samples/cpp/tutorial_code/TrackingMotion/cornerDetector_Demo.cpp
View file @
83799d6b
...
@@ -15,7 +15,7 @@ using namespace std;
...
@@ -15,7 +15,7 @@ using namespace std;
/// Global variables
/// Global variables
Mat
src
,
src_gray
;
Mat
src
,
src_gray
;
Mat
myHarris_dst
;
Mat
myHarris_copy
;
Mat
Mc
;
Mat
myHarris_dst
;
Mat
myHarris_copy
;
Mat
Mc
;
Mat
myShiTomasi_dst
;
Mat
myShiTomasi_copy
;
Mat
myShiTomasi_dst
;
Mat
myShiTomasi_copy
;
int
myShiTomasi_qualityLevel
=
50
;
int
myShiTomasi_qualityLevel
=
50
;
int
myHarris_qualityLevel
=
50
;
int
myHarris_qualityLevel
=
50
;
...
@@ -51,34 +51,34 @@ int main( int argc, char** argv )
...
@@ -51,34 +51,34 @@ int main( int argc, char** argv )
cornerEigenValsAndVecs
(
src_gray
,
myHarris_dst
,
blockSize
,
apertureSize
,
BORDER_DEFAULT
);
cornerEigenValsAndVecs
(
src_gray
,
myHarris_dst
,
blockSize
,
apertureSize
,
BORDER_DEFAULT
);
/* calculate Mc */
/* calculate Mc */
for
(
int
j
=
0
;
j
<
src_gray
.
rows
;
j
++
)
for
(
int
j
=
0
;
j
<
src_gray
.
rows
;
j
++
)
{
for
(
int
i
=
0
;
i
<
src_gray
.
cols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
src_gray
.
cols
;
i
++
)
{
{
float
lambda_1
=
myHarris_dst
.
at
<
float
>
(
j
,
i
,
0
)
;
float
lambda_1
=
myHarris_dst
.
at
<
Vec6f
>
(
j
,
i
)[
0
]
;
float
lambda_2
=
myHarris_dst
.
at
<
float
>
(
j
,
i
,
1
)
;
float
lambda_2
=
myHarris_dst
.
at
<
Vec6f
>
(
j
,
i
)[
1
]
;
Mc
.
at
<
float
>
(
j
,
i
)
=
lambda_1
*
lambda_2
-
0.04
*
pow
(
(
lambda_1
+
lambda_2
),
2
);
Mc
.
at
<
float
>
(
j
,
i
)
=
lambda_1
*
lambda_2
-
0.04
*
pow
(
(
lambda_1
+
lambda_2
),
2
);
}
}
}
}
minMaxLoc
(
Mc
,
&
myHarris_minVal
,
&
myHarris_maxVal
,
0
,
0
,
Mat
()
);
minMaxLoc
(
Mc
,
&
myHarris_minVal
,
&
myHarris_maxVal
,
0
,
0
,
Mat
()
);
/* Create Window and Trackbar */
/* Create Window and Trackbar */
namedWindow
(
myHarris_window
,
CV_WINDOW_AUTOSIZE
);
namedWindow
(
myHarris_window
,
CV_WINDOW_AUTOSIZE
);
createTrackbar
(
" Quality Level:"
,
myHarris_window
,
&
myHarris_qualityLevel
,
max_qualityLevel
,
myHarris_function
);
createTrackbar
(
" Quality Level:"
,
myHarris_window
,
&
myHarris_qualityLevel
,
max_qualityLevel
,
myHarris_function
);
myHarris_function
(
0
,
0
);
myHarris_function
(
0
,
0
);
/// My Shi-Tomasi -- Using cornerMinEigenVal
/// My Shi-Tomasi -- Using cornerMinEigenVal
myShiTomasi_dst
=
Mat
::
zeros
(
src_gray
.
size
(),
CV_32FC1
);
myShiTomasi_dst
=
Mat
::
zeros
(
src_gray
.
size
(),
CV_32FC1
);
cornerMinEigenVal
(
src_gray
,
myShiTomasi_dst
,
blockSize
,
apertureSize
,
BORDER_DEFAULT
);
cornerMinEigenVal
(
src_gray
,
myShiTomasi_dst
,
blockSize
,
apertureSize
,
BORDER_DEFAULT
);
minMaxLoc
(
myShiTomasi_dst
,
&
myShiTomasi_minVal
,
&
myShiTomasi_maxVal
,
0
,
0
,
Mat
()
);
minMaxLoc
(
myShiTomasi_dst
,
&
myShiTomasi_minVal
,
&
myShiTomasi_maxVal
,
0
,
0
,
Mat
()
);
/* Create Window and Trackbar */
/* Create Window and Trackbar */
namedWindow
(
myShiTomasi_window
,
CV_WINDOW_AUTOSIZE
);
namedWindow
(
myShiTomasi_window
,
CV_WINDOW_AUTOSIZE
);
createTrackbar
(
" Quality Level:"
,
myShiTomasi_window
,
&
myShiTomasi_qualityLevel
,
max_qualityLevel
,
myShiTomasi_function
);
createTrackbar
(
" Quality Level:"
,
myShiTomasi_window
,
&
myShiTomasi_qualityLevel
,
max_qualityLevel
,
myShiTomasi_function
);
myShiTomasi_function
(
0
,
0
);
myShiTomasi_function
(
0
,
0
);
waitKey
(
0
);
waitKey
(
0
);
return
(
0
);
return
(
0
);
}
}
...
...
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