Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
ball_tracking
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Gomez-Gonzalez
ball_tracking
Commits
f186d4d7
Commit
f186d4d7
authored
7 years ago
by
Sebastian Gomez-Gonzalez
Browse files
Options
Downloads
Patches
Plain Diff
Adding Raphael example in an organized manner
parent
b54e3aee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/CMakeLists.txt
+8
-0
8 additions, 0 deletions
examples/CMakeLists.txt
examples/img_proc/log_reg_approach.cpp
+81
-0
81 additions, 0 deletions
examples/img_proc/log_reg_approach.cpp
with
89 additions
and
0 deletions
examples/CMakeLists.txt
+
8
−
0
View file @
f186d4d7
...
...
@@ -10,3 +10,11 @@ target_link_libraries(color_approach
ball_tracking
${
Boost_LIBRARIES
}
)
add_executable
(
log_reg_approach
img_proc/log_reg_approach.cpp
)
target_link_libraries
(
log_reg_approach
ball_tracking
${
Boost_LIBRARIES
}
)
This diff is collapsed.
Click to expand it.
examples/img_proc/log_reg_approach.cpp
0 → 100644
+
81
−
0
View file @
f186d4d7
#include
<ball_tracking/img_proc.hpp>
#include
<ball_tracking/utils.hpp>
#include
<opencv2/opencv.hpp>
#include
<opencv2/highgui/highgui.hpp>
#include
<iostream>
#include
<boost/program_options.hpp>
#include
<json.hpp>
using
namespace
cv
;
using
namespace
std
;
using
namespace
ball_tracking
;
using
json
=
nlohmann
::
json
;
int
main
(
int
argc
,
char
**
argv
)
{
try
{
namespace
po
=
boost
::
program_options
;
po
::
options_description
desc
(
"Options"
);
desc
.
add_options
()
(
"help"
,
"Produce help message"
)
(
"input,i"
,
po
::
value
<
string
>
(),
"path to the input image"
)
(
"conf,c"
,
po
::
value
<
string
>
(),
"path to the JSON configuration"
)
(
"output,o"
,
po
::
value
<
string
>
(),
"path to the output image"
);
po
::
variables_map
vm
;
po
::
store
(
po
::
parse_command_line
(
argc
,
argv
,
desc
),
vm
);
po
::
notify
(
vm
);
if
(
vm
.
count
(
"help"
))
{
cout
<<
desc
<<
endl
;
return
0
;
}
if
(
!
vm
.
count
(
"input"
))
{
cerr
<<
"Error: You should provide the image to process"
<<
endl
;
return
1
;
}
json
jobj
=
load_json
(
vm
[
"conf"
].
as
<
string
>
());
Mat
model_coef
=
json2cvmat
(
jobj
.
at
(
"model_coefs"
));
Mat
back
=
imread
(
jobj
.
at
(
"background"
),
CV_LOAD_IMAGE_COLOR
);
if
(
!
back
.
data
)
// Check for invalid input background
{
cout
<<
"Could not open or find the backgroundimage"
<<
std
::
endl
;
return
-
1
;
}
string
fname
=
vm
[
"input"
].
as
<
string
>
();
Mat
img
=
imread
(
fname
,
CV_LOAD_IMAGE_COLOR
);
imshow
(
"Color"
,
back
);
waitKey
(
0
);
//Calculate the data with coefs
Mat
im_proc
=
quadf_log_reg
(
img
,
back
,
model_coef
);
cout
<<
"pix data:"
<<
im_proc
.
at
<
double
>
(
340
,
290
)
<<
endl
<<
im_proc
.
at
<
double
>
(
342
,
291
)
<<
endl
<<
im_proc
.
at
<
double
>
(
290
,
340
)
<<
endl
<<
im_proc
.
at
<
double
>
(
2
,
2
)
<<
endl
;
MatIterator_
<
double
>
it_ans
=
im_proc
.
begin
<
double
>
(),
end
=
im_proc
.
end
<
double
>
();
//MatIterator_<Vec3b> it=im_proc.begin<Vec3b>(), end=im_proc.end<Vec3b>();
while
(
it_ans
!=
end
){
//cout << "pix data:" << *it_ans << endl;
double
prob
=
1.0
/
(
1.0
+
exp
(
-*
it_ans
));
//*it_ans = 255*prob;
*
it_ans
=
(
prob
>
0.95
)
?
255
:
0
;
it_ans
++
;
}
imshow
(
"Color"
,
im_proc
);
waitKey
(
0
);
//exp(-0.5*im_proc, im_proc);
//im_proc = 255*im_proc;
//imshow("Processed", im_proc);
//waitKey(0);
if
(
vm
.
count
(
"output"
))
{
imwrite
(
vm
[
"output"
].
as
<
string
>
(),
im_proc
);
}
return
0
;
}
catch
(
std
::
exception
&
ex
)
{
cerr
<<
"Exception: "
<<
ex
.
what
()
<<
endl
;
return
1
;
}
}
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