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
dda824f2
Commit
dda824f2
authored
Aug 27, 2018
by
Thomas Boy
Browse files
Options
Downloads
Patches
Plain Diff
try next bug fix, huge work around for corrupted file test
parent
cb182607
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Demo.cpp
+258
-226
258 additions, 226 deletions
Demo.cpp
package_bgs/ttoolbox.cpp
+53
-0
53 additions, 0 deletions
package_bgs/ttoolbox.cpp
package_bgs/ttoolbox.h
+12
-0
12 additions, 0 deletions
package_bgs/ttoolbox.h
with
323 additions
and
226 deletions
Demo.cpp
+
258
−
226
View file @
dda824f2
...
@@ -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
4
#define PROCESS_CENTER_VERSION_MINOR_FIXES
7
//opencv
//opencv
#include
<opencv2/opencv.hpp>
#include
<opencv2/opencv.hpp>
...
@@ -46,6 +46,7 @@ bool cmdOptionExists(char** begin, char** end, const std::string& option)
...
@@ -46,6 +46,7 @@ bool cmdOptionExists(char** begin, char** end, const std::string& option)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
std
::
cout
<<
"using processcenter "
<<
PROCESS_CENTER_VERSION_MAJOR
<<
"."
<<
PROCESS_CENTER_VERSION_MINOR
<<
endl
;
std
::
cout
<<
"using processcenter "
<<
PROCESS_CENTER_VERSION_MAJOR
<<
"."
<<
PROCESS_CENTER_VERSION_MINOR
<<
endl
;
std
::
cout
<<
"Using OpenCV "
<<
CV_MAJOR_VERSION
<<
"."
<<
CV_MINOR_VERSION
<<
"."
<<
CV_SUBMINOR_VERSION
<<
"."
<<
PROCESS_CENTER_VERSION_MINOR_FIXES
<<
std
::
endl
;
std
::
cout
<<
"Using OpenCV "
<<
CV_MAJOR_VERSION
<<
"."
<<
CV_MINOR_VERSION
<<
"."
<<
CV_SUBMINOR_VERSION
<<
"."
<<
PROCESS_CENTER_VERSION_MINOR_FIXES
<<
std
::
endl
;
//!** parse programm input****************/
//!** parse programm input****************/
...
@@ -224,6 +225,14 @@ int main(int argc, char * argv[])
...
@@ -224,6 +225,14 @@ int main(int argc, char * argv[])
//std::string fileName = getFileName(begin);
//std::string fileName = getFileName(begin);
std
::
string
staticFile
=
inputDir
+
"/bk.jpg"
;
std
::
string
staticFile
=
inputDir
+
"/bk.jpg"
;
cout
<<
"a) load first static background pic :"
<<
staticFile
<<
endl
;
cout
<<
"a) load first static background pic :"
<<
staticFile
<<
endl
;
//we check for corrupt image
if
(
TToolBox
::
checkFileCorrupted
(
staticFile
))
{
cout
<<
"error file: "
<<
staticFile
<<
" is corrupted, will abort"
<<
endl
;
return
EXIT_FAILURE
;
}
img_input
=
imread
(
staticFile
.
c_str
(),
CV_LOAD_IMAGE_COLOR
);
img_input
=
imread
(
staticFile
.
c_str
(),
CV_LOAD_IMAGE_COLOR
);
if
(
img_input
.
data
)
if
(
img_input
.
data
)
{
{
...
@@ -271,6 +280,14 @@ int main(int argc, char * argv[])
...
@@ -271,6 +280,14 @@ int main(int argc, char * argv[])
fileName
=
inputDir
+
TToolBox
::
getFileName
(
index
);
fileName
=
inputDir
+
TToolBox
::
getFileName
(
index
);
myRandomTrainList
.
push_back
(
fileName
);
myRandomTrainList
.
push_back
(
fileName
);
//we check for corrupt image
if
(
TToolBox
::
checkFileCorrupted
(
fileName
))
{
cout
<<
"error file: "
<<
fileName
<<
" is corrupted, will ignore it and draw new"
<<
endl
;
i
--
;
continue
;
//we jump over the rest //TODO bad style
}
cout
<<
"
\t
"
<<
i
<<
"
\t
of
\t
"
<<
amountTrainingSteps
<<
" rnd file :"
<<
fileName
<<
endl
;
cout
<<
"
\t
"
<<
i
<<
"
\t
of
\t
"
<<
amountTrainingSteps
<<
" rnd file :"
<<
fileName
<<
endl
;
img_input
=
imread
(
fileName
.
c_str
(),
CV_LOAD_IMAGE_COLOR
);
img_input
=
imread
(
fileName
.
c_str
(),
CV_LOAD_IMAGE_COLOR
);
...
@@ -316,6 +333,7 @@ int main(int argc, char * argv[])
...
@@ -316,6 +333,7 @@ int main(int argc, char * argv[])
vector
<
string
>
myFileErrorList
;
//list for pure io error
vector
<
string
>
myFileErrorList
;
//list for pure io error
vector
<
string
>
myFileListNoContour
;
//list for no contours found;
vector
<
string
>
myFileListNoContour
;
//list for no contours found;
vector
<
string
>
myFileListAfterContourSelection
;
//list for no contours found after selection;
vector
<
string
>
myFileListAfterContourSelection
;
//list for no contours found after selection;
vector
<
string
>
myFileListCorrupted
;
//list all corrupted jpg files
for
(
frameCounter
=
0
;
frameCounter
<
amountFiles
;
frameCounter
++
)
for
(
frameCounter
=
0
;
frameCounter
<
amountFiles
;
frameCounter
++
)
{
{
...
@@ -341,6 +359,10 @@ int main(int argc, char * argv[])
...
@@ -341,6 +359,10 @@ int main(int argc, char * argv[])
cout
<<
" d 3: "
<<
fileName
.
size
()
<<
" size: "
<<
fileName
<<
endl
;
cout
<<
" d 3: "
<<
fileName
.
size
()
<<
" size: "
<<
fileName
<<
endl
;
cout
<<
" d 3: "
<<
fileNameCV
.
size
()
<<
" size:"
<<
fileNameCV
.
c_str
();
cout
<<
" d 3: "
<<
fileNameCV
.
size
()
<<
" size:"
<<
fileNameCV
.
c_str
();
//we check if the image in NOT corrupted
if
(
!
TToolBox
::
checkFileCorrupted
(
fileName
))
{
//we load the file
img_input
=
imread
(
fileNameCV
,
CV_LOAD_IMAGE_COLOR
);
img_input
=
imread
(
fileNameCV
,
CV_LOAD_IMAGE_COLOR
);
cout
<<
" e "
<<
endl
;
cout
<<
" e "
<<
endl
;
...
@@ -618,7 +640,8 @@ int main(int argc, char * argv[])
...
@@ -618,7 +640,8 @@ int main(int argc, char * argv[])
imwrite
(
nameOutPutFileDBGpic
.
c_str
(),
imgOverlay2
);
imwrite
(
nameOutPutFileDBGpic
.
c_str
(),
imgOverlay2
);
cout
<<
" l "
<<
endl
;
cout
<<
" l "
<<
endl
;
}
}
//end if we write a dbg picture
}
//end if the loaded picture has data
}
//end if the loaded picture has data
else
else
...
@@ -627,6 +650,15 @@ int main(int argc, char * argv[])
...
@@ -627,6 +650,15 @@ int main(int argc, char * argv[])
myFileErrorList
.
push_back
(
fileName
);
myFileErrorList
.
push_back
(
fileName
);
}
}
}
//end if not corrupted picture
else
{
cout
<<
"error file: "
<<
fileName
<<
" is corrupted, will ignore it"
<<
endl
;
myFileListCorrupted
.
push_back
(
fileName
);
}
//we calc the time which we used for a picture
//we calc the time which we used for a picture
clock_t
end
=
clock
();
clock_t
end
=
clock
();
double
elapsedSecs
=
double
(
end
-
begin
)
/
CLOCKS_PER_SEC
;
double
elapsedSecs
=
double
(
end
-
begin
)
/
CLOCKS_PER_SEC
;
...
...
This diff is collapsed.
Click to expand it.
package_bgs/ttoolbox.cpp
+
53
−
0
View file @
dda824f2
...
@@ -96,3 +96,56 @@ cv::Mat TToolBox::cropImageCircle(cv::Mat image, int x, int y, int r)
...
@@ -96,3 +96,56 @@ cv::Mat TToolBox::cropImageCircle(cv::Mat image, int x, int y, int r)
return
res
;
return
res
;
}
}
int
TToolBox
::
checkFileCorrupted
(
std
::
string
filename
)
{
int
retVal
=
1
;
//is as long Corrupted as we dont find it in another way
char
command
[]
=
"identify "
;
const
char
*
fileNameArr
=
filename
.
c_str
();
char
command2
[]
=
" > /dev/null 2>&1 ; echo $?"
;
char
*
cmd
=
new
char
[
std
::
strlen
(
command
)
+
std
::
strlen
(
fileNameArr
)
+
std
::
strlen
(
command2
)
+
1
];
//we put all peaces together
std
::
strcpy
(
cmd
,
command
);
std
::
strcat
(
cmd
,
fileNameArr
);
std
::
strcat
(
cmd
,
command2
);
//std:: cout <<"cmd is: "<< cmd<< std::endl;
//execute the command
std
::
string
result
=
TToolBox
::
execCMD
((
const
char
*
)
cmd
);
//std:: cout <<"results is: "<< result<< std::endl;
if
(
!
result
.
empty
())
{
try
{
retVal
=
std
::
stoi
(
result
);
}
catch
(
std
::
invalid_argument
&
e
)
{
std
::
cerr
<<
"wrong argument for stoi"
<<
std
::
endl
;
// if no conversion could be performed
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
"error during use stoi"
<<
std
::
endl
;
}
}
//end if
return
retVal
;
}
std
::
string
TToolBox
::
execCMD
(
const
char
*
cmd
)
{
std
::
array
<
char
,
128
>
buffer
;
std
::
string
result
;
std
::
shared_ptr
<
FILE
>
pipe
(
popen
(
cmd
,
"r"
),
pclose
);
if
(
!
pipe
)
throw
std
::
runtime_error
(
"popen() failed!"
);
while
(
!
feof
(
pipe
.
get
()))
{
if
(
fgets
(
buffer
.
data
(),
128
,
pipe
.
get
())
!=
nullptr
)
result
+=
buffer
.
data
();
//std::cout<<result<<std::endl;
}
//std::cout<<"call: " <<result<<std::endl;
return
result
;
}
This diff is collapsed.
Click to expand it.
package_bgs/ttoolbox.h
+
12
−
0
View file @
dda824f2
...
@@ -10,6 +10,11 @@
...
@@ -10,6 +10,11 @@
#include
<time.h>
/* time */
#include
<time.h>
/* time */
#include
<ctime>
#include
<ctime>
#include
<sstream>
#include
<sstream>
#include
<cstdio>
#include
<memory>
#include
<stdexcept>
#include
<string>
#include
<array>
//open cv
//open cv
#include
"opencv2/core/core.hpp"
#include
"opencv2/core/core.hpp"
...
@@ -36,6 +41,13 @@ public:
...
@@ -36,6 +41,13 @@ public:
//! canny edge detect
//! canny edge detect
static
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
applyCannyEdgeAndCalcCountours
(
cv
::
Mat
imgSource
,
double
threshholdMin
,
double
threshholdMax
,
int
apertureSize
);
static
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
applyCannyEdgeAndCalcCountours
(
cv
::
Mat
imgSource
,
double
threshholdMin
,
double
threshholdMax
,
int
apertureSize
);
//! will test if file is not corrupted
//! @return 1 if corrupted
//! @return 0 if not
static
int
checkFileCorrupted
(
std
::
string
filename
);
//! will try to execute the cmd on the bash
static
std
::
string
execCMD
(
const
char
*
cmd
);
};
};
...
...
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