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
b54e3aee
Commit
b54e3aee
authored
7 years ago
by
Sebastian Gomez-Gonzalez
Browse files
Options
Downloads
Patches
Plain Diff
The logistic regression validator (not tested)
parent
8516ca06
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
include/ball_tracking/img_proc.hpp
+13
-0
13 additions, 0 deletions
include/ball_tracking/img_proc.hpp
src/img_proc.cpp
+27
-0
27 additions, 0 deletions
src/img_proc.cpp
with
40 additions
and
0 deletions
include/ball_tracking/img_proc.hpp
+
13
−
0
View file @
b54e3aee
...
...
@@ -22,6 +22,19 @@ namespace ball_tracking {
*/
cv
::
Mat
map_channel_quad
(
cv
::
InputArray
src
,
cv
::
InputArray
mean
,
cv
::
InputArray
S
);
/**
* @brief Applies a pixel-wise logistic regression with quadratic features to the source
* image and returns a single-channel image with the log-probabilities
*
* @param[in] src The source image
* @param[in] bkg A background image (Without the ball)
* @param[in] weights Vector of weights of logistic regression
*
* @returns a new image where every pixel corresponds to the log-probability of the
* pixel being a ball according to the trained classifier
*/
cv
::
Mat
quadf_log_reg
(
cv
::
InputArray
src
,
cv
::
InputArray
bkg
,
cv
::
InputArray
weights
);
/**
* @brief Produces a single channel image highlighting the possible position of the ball
...
...
This diff is collapsed.
Click to expand it.
src/img_proc.cpp
+
27
−
0
View file @
b54e3aee
...
...
@@ -34,4 +34,31 @@ namespace ball_tracking {
return
ans
;
}
cv
::
Mat
quadf_log_reg
(
cv
::
InputArray
_src
,
cv
::
InputArray
_bkg
,
cv
::
InputArray
_weights
)
{
Mat
src
=
_src
.
getMat
(),
bkg
=
_bkg
.
getMat
(),
tmp_weight
=
_weights
.
getMat
();
const
unsigned
int
channels
=
src
.
channels
();
CV_Assert
(
channels
==
3
);
CV_Assert
(
src
.
rows
==
bkg
.
rows
&&
src
.
cols
==
bkg
.
cols
);
double
w
[
28
];
copy
(
tmp_weight
.
begin
<
double
>
(),
tmp_weight
.
end
<
double
>
(),
w
);
Mat
ans
(
src
.
rows
,
src
.
cols
,
CV_64FC1
);
MatIterator_
<
Vec3b
>
it
=
src
.
begin
<
Vec3b
>
(),
end
=
src
.
end
<
Vec3b
>
();
MatIterator_
<
Vec3b
>
it_bkg
=
bkg
.
begin
<
Vec3b
>
();
MatIterator_
<
double
>
it_ans
=
ans
.
begin
<
double
>
();
for
(;
it
!=
end
;
it
++
,
it_ans
++
,
it_bkg
++
)
{
double
sum
=
0.0
;
double
lfeat
[
7
]
=
{(
*
it
)[
0
]
/
255.0
,
(
*
it
)[
1
]
/
255.0
,
(
*
it
)[
2
]
/
255.0
,
(
*
it_bkg
)[
0
]
/
255.0
,
(
*
it_bkg
)[
1
]
/
255.0
,
(
*
it_bkg
)[
2
]
/
255.0
,
1.0
};
double
*
wptr
=
w
;
for
(
unsigned
int
i
=
0
;
i
<
7
;
i
++
)
{
for
(
unsigned
int
j
=
i
;
j
<
channels
;
j
++
,
wptr
++
)
{
sum
+=
(
*
wptr
)
*
lfeat
[
i
]
*
lfeat
[
j
];
}
}
*
it_ans
=
sum
;
}
return
ans
;
}
};
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