Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
camtron
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kr69sugu
camtron
Commits
48fbbfa8
Commit
48fbbfa8
authored
Aug 27, 2018
by
Thomas Boy
Browse files
Options
Downloads
Patches
Plain Diff
meant to be the bug fix
parent
3ab56e9e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Demo.cpp
+151
-121
151 additions, 121 deletions
Demo.cpp
with
151 additions
and
121 deletions
Demo.cpp
+
151
−
121
View file @
48fbbfa8
...
@@ -15,7 +15,7 @@ based on original demo.cpp
...
@@ -15,7 +15,7 @@ based on original demo.cpp
#define PROCESS_CENTER_VERSION_MAJOR 0
#define PROCESS_CENTER_VERSION_MAJOR 0
#define PROCESS_CENTER_VERSION_MINOR 9
#define PROCESS_CENTER_VERSION_MINOR 9
#define PROCESS_CENTER_VERSION_MINOR_FIXES
1
#define PROCESS_CENTER_VERSION_MINOR_FIXES
2
//opencv
//opencv
#include
<opencv2/opencv.hpp>
#include
<opencv2/opencv.hpp>
...
@@ -308,7 +308,9 @@ int main(int argc, char * argv[])
...
@@ -308,7 +308,9 @@ int main(int argc, char * argv[])
int
everyPic
=
60
*
5
;
int
everyPic
=
60
*
5
;
int
frameCounter
=
0
;
int
frameCounter
=
0
;
vector
<
string
>
myFileErrorList
;
vector
<
string
>
myFileErrorList
;
//list for pure io error
vector
<
string
>
myFileListNoContour
;
//list for no contours found;
vector
<
string
>
myFileListAfterContourSelection
;
//list for no contours found after selection;
for
(
frameCounter
=
0
;
frameCounter
<
amountFiles
;
frameCounter
++
)
for
(
frameCounter
=
0
;
frameCounter
<
amountFiles
;
frameCounter
++
)
{
{
...
@@ -351,7 +353,14 @@ int main(int argc, char * argv[])
...
@@ -351,7 +353,14 @@ int main(int argc, char * argv[])
int
apertureSize
=
3
;
int
apertureSize
=
3
;
std
::
vector
<
vector
<
Point
>
>
contours
=
TToolBox
::
applyCannyEdgeAndCalcCountours
(
img_mask
,
threshholdMin
,
threshholdMax
,
apertureSize
);
std
::
vector
<
vector
<
Point
>
>
contours
=
TToolBox
::
applyCannyEdgeAndCalcCountours
(
img_mask
,
threshholdMin
,
threshholdMax
,
apertureSize
);
//define what we will write down
std
::
vector
<
vector
<
Point
>
>
contourSelection
;
vector
<
Point2f
>
massCenters
;
vector
<
Point
>
conHull
;
Point2f
muConvexHullMassCenter
(
0.0
,
0.0
);
if
(
!
contours
.
empty
())
{
// //TODO: we need to order the points to get a nice polygon, otherwise not usefull
// //TODO: we need to order the points to get a nice polygon, otherwise not usefull
// //we also try to find the aproximate polygon*****************
// //we also try to find the aproximate polygon*****************
//// vector<Point> aproxiCurve;
//// vector<Point> aproxiCurve;
...
@@ -390,10 +399,9 @@ int main(int argc, char * argv[])
...
@@ -390,10 +399,9 @@ int main(int argc, char * argv[])
//! step 4) we make a selection out of all counters with area sizes******************************
//! step 4) we make a selection out of all counters with area sizes******************************
vector
<
vector
<
Point
>
>
contourSelection
;
//we exlcude very small one and very big ones
//we calc all min rotated rectangles for all contour from candy egde detect
//we calc all min rotated rectangles for all contour from candy egde detect
//we exlcude very small one and very big ones
vector
<
RotatedRect
>
minRect
(
contours
.
size
()
);
vector
<
RotatedRect
>
minRect
(
contours
.
size
()
);
//calc boxes around the contours
//calc boxes around the contours
...
@@ -439,6 +447,8 @@ int main(int argc, char * argv[])
...
@@ -439,6 +447,8 @@ int main(int argc, char * argv[])
}
}
}
//end iterate all min rectangle
}
//end iterate all min rectangle
if
(
!
contourSelection
.
empty
())
{
//! step 5) we calc the moments from the contour selection
//! step 5) we calc the moments from the contour selection
vector
<
Moments
>
mu
(
contourSelection
.
size
()
);
vector
<
Moments
>
mu
(
contourSelection
.
size
()
);
for
(
size_t
i
=
0
;
i
<
contourSelection
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
contourSelection
.
size
();
i
++
)
...
@@ -447,7 +457,7 @@ int main(int argc, char * argv[])
...
@@ -447,7 +457,7 @@ int main(int argc, char * argv[])
}
}
// Get the mass centers:
// Get the mass centers:
vector
<
Point2f
>
massCenters
(
contourSelection
.
size
()
);
massCenters
=
vector
<
Point2f
>
(
contourSelection
.
size
()
);
for
(
size_t
i
=
0
;
i
<
contourSelection
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
contourSelection
.
size
();
i
++
)
{
{
massCenters
[
i
]
=
Point2f
(
mu
[
i
].
m10
/
mu
[
i
].
m00
,
mu
[
i
].
m01
/
mu
[
i
].
m00
);
massCenters
[
i
]
=
Point2f
(
mu
[
i
].
m10
/
mu
[
i
].
m00
,
mu
[
i
].
m01
/
mu
[
i
].
m00
);
...
@@ -467,7 +477,7 @@ int main(int argc, char * argv[])
...
@@ -467,7 +477,7 @@ int main(int argc, char * argv[])
}
}
// calc the hull ******************
// calc the hull ******************
vector
<
Point
>
conHull
(
allContourPoints
.
size
());
conHull
=
vector
<
Point
>
(
allContourPoints
.
size
());
convexHull
(
Mat
(
allContourPoints
),
conHull
,
false
);
convexHull
(
Mat
(
allContourPoints
),
conHull
,
false
);
// Point roiCenter;
// Point roiCenter;
// float roiRadius;
// float roiRadius;
...
@@ -478,13 +488,23 @@ int main(int argc, char * argv[])
...
@@ -478,13 +488,23 @@ int main(int argc, char * argv[])
///we calc the mass center of the convex hull
///we calc the mass center of the convex hull
Moments
muConvexHull
;
Moments
muConvexHull
;
Point2f
muConvexHullMassCenter
(
0.0
,
0.0
);
if
(
!
conHull
.
empty
())
if
(
!
conHull
.
empty
())
{
{
muConvexHull
=
moments
(
conHull
,
true
);
muConvexHull
=
moments
(
conHull
,
true
);
muConvexHullMassCenter
=
Point2f
(
muConvexHull
.
m10
/
muConvexHull
.
m00
,
muConvexHull
.
m01
/
muConvexHull
.
m00
);
muConvexHullMassCenter
=
Point2f
(
muConvexHull
.
m10
/
muConvexHull
.
m00
,
muConvexHull
.
m01
/
muConvexHull
.
m00
);
}
}
}
//end after selection is empty
{
cerr
<<
"error, no contour found after selection in file: "
<<
fileName
<<
endl
;
myFileListAfterContourSelection
.
push_back
(
fileName
);
}
}
//end if contours are empty, to canny edge found nothing
else
{
cerr
<<
"error, no contour found at all in file: "
<<
fileName
<<
endl
;
myFileListNoContour
.
push_back
(
fileName
);
}
#ifdef MC_SHOW_STEP_ANALYSE
#ifdef MC_SHOW_STEP_ANALYSE
if
(
!
conHull
.
empty
())
//if we any elements, we process further
if
(
!
conHull
.
empty
())
//if we any elements, we process further
...
@@ -594,20 +614,30 @@ int main(int argc, char * argv[])
...
@@ -594,20 +614,30 @@ int main(int argc, char * argv[])
clock_t
endAll
=
clock
();
clock_t
endAll
=
clock
();
double
elapsed
=
double
(
endAll
-
beginAll
)
/
CLOCKS_PER_SEC
;
double
elapsed
=
double
(
endAll
-
beginAll
)
/
CLOCKS_PER_SEC
;
cout
<<
"process : "
<<
amountFiles
<<
" files took:
\t
"
<<
(
int
)(
elapsed
/
60
)
<<
" min -
\t
"
<<
(
int
)(
elapsed
/
60
/
60
)
<<
" h
\n
in total"
<<
endl
;
cout
<<
"process : "
<<
amountFiles
<<
" files took:
\t
"
<<
(
int
)(
elapsed
/
60
)
<<
" min -
\t
"
<<
(
int
)(
elapsed
/
60
/
60
)
<<
" h
\n
in total"
<<
endl
;
//we write the random file list to a file
//we write the random file list to a file
std
::
string
nameOutRandomFile
=
outputDir
+
"randlist.yml"
;
std
::
string
nameOutRandomFile
=
outputDir
+
"randlist.yml"
;
FileStorage
fs
(
nameOutRandomFile
.
c_str
(),
FileStorage
::
WRITE
);
FileStorage
fs
(
nameOutRandomFile
.
c_str
(),
FileStorage
::
WRITE
);
fs
<<
"randomlist"
<<
myRandomTrainList
;
fs
<<
"randomlist"
<<
myRandomTrainList
;
fs
.
release
();
fs
.
release
();
//TODO we should merge the file
//we write the random file list to a file
//we write the random file list to a file
std
::
string
nameOutErrorList
=
outputDir
+
"fileErrorList.yml"
;
std
::
string
nameOutErrorList
=
outputDir
+
"fileErrorList.yml"
;
cout
<<
"amount of file errors: "
<<
myFileErrorList
.
size
()
<<
endl
;
cout
<<
"amount of file errors: "
<<
myFileErrorList
.
size
()
<<
endl
;
FileStorage
fs2
(
nameOutErrorList
.
c_str
(),
FileStorage
::
WRITE
);
FileStorage
fs2
(
nameOutErrorList
.
c_str
(),
FileStorage
::
WRITE
);
fs2
<<
"fileErrorList"
<<
myFileErrorList
;
fs2
<<
"fileErrorIO"
<<
myFileErrorList
;
//we write error list no contours found in file
cout
<<
"amount contour errors with canny edge: "
<<
myFileListNoContour
.
size
()
<<
endl
;
fs2
<<
"fileErrorNoContours"
<<
myFileListNoContour
;
//we write error list no contours found in file
cout
<<
"amount contour errors after selection: "
<<
myFileListAfterContourSelection
.
size
()
<<
endl
;
fs2
<<
"fileErrorNoContoursAfterSelection"
<<
myFileListAfterContourSelection
;
fs2
.
release
();
fs2
.
release
();
delete
bgs
;
delete
bgs
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment