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
b4aa33b6
Commit
b4aa33b6
authored
Jan 30, 2013
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move ICF -> ChannelFeature
parent
a01f5964
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
195 additions
and
130 deletions
+195
-130
fpool.cpp
apps/sft/fpool.cpp
+1
-12
fpool.hpp
apps/sft/include/sft/fpool.hpp
+1
-43
softcascade.hpp
...s/softcascade/include/opencv2/softcascade/softcascade.hpp
+25
-0
_random.hpp
modules/softcascade/src/_random.hpp
+118
-0
integral_channel_builder.cpp
modules/softcascade/src/integral_channel_builder.cpp
+49
-6
soft_cascade_octave.cpp
modules/softcascade/src/soft_cascade_octave.cpp
+1
-69
No files found.
apps/sft/fpool.cpp
View file @
b4aa33b6
...
...
@@ -72,11 +72,6 @@ void sft::ICFFeaturePool::write( cv::FileStorage& fs, int index) const
fs
<<
pool
[
index
];
}
void
sft
::
write
(
cv
::
FileStorage
&
fs
,
const
string
&
,
const
ICF
&
f
)
{
fs
<<
"{"
<<
"channel"
<<
f
.
channel
<<
"rect"
<<
f
.
bb
<<
"}"
;
}
sft
::
ICFFeaturePool
::~
ICFFeaturePool
(){}
#if defined _WIN32 && (_WIN32 || _WIN64)
...
...
@@ -137,7 +132,7 @@ void sft::ICFFeaturePool::fill(int desired)
int
ch
=
chRand
(
eng_ch
);
sft
::
ICF
f
(
x
,
y
,
w
,
h
,
ch
);
cv
::
ChannelFeature
f
(
x
,
y
,
w
,
h
,
ch
);
if
(
std
::
find
(
pool
.
begin
(),
pool
.
end
(),
f
)
==
pool
.
end
())
{
...
...
@@ -147,12 +142,6 @@ void sft::ICFFeaturePool::fill(int desired)
}
}
std
::
ostream
&
sft
::
operator
<<
(
std
::
ostream
&
out
,
const
sft
::
ICF
&
m
)
{
out
<<
m
.
channel
<<
" "
<<
m
.
bb
;
return
out
;
}
// ============ Dataset ============ //
namespace
{
using
namespace
sft
;
...
...
apps/sft/include/sft/fpool.hpp
View file @
b4aa33b6
...
...
@@ -50,48 +50,6 @@
#include <opencv2/softcascade/softcascade.hpp>
namespace
sft
{
struct
ICF
{
ICF
(
int
x
,
int
y
,
int
w
,
int
h
,
int
ch
)
:
bb
(
cv
::
Rect
(
x
,
y
,
w
,
h
)),
channel
(
ch
)
{}
bool
operator
==
(
ICF
b
)
{
return
bb
==
b
.
bb
&&
channel
==
b
.
channel
;
}
bool
operator
!=
(
ICF
b
)
{
return
bb
!=
b
.
bb
||
channel
!=
b
.
channel
;
}
float
operator
()
(
const
cv
::
Mat
&
integrals
,
const
cv
::
Size
&
model
)
const
{
int
step
=
model
.
width
+
1
;
const
int
*
ptr
=
integrals
.
ptr
<
int
>
(
0
)
+
(
model
.
height
*
channel
+
bb
.
y
)
*
step
+
bb
.
x
;
int
a
=
ptr
[
0
];
int
b
=
ptr
[
bb
.
width
];
ptr
+=
bb
.
height
*
step
;
int
c
=
ptr
[
bb
.
width
];
int
d
=
ptr
[
0
];
return
(
float
)(
a
-
b
+
c
-
d
);
}
private
:
cv
::
Rect
bb
;
int
channel
;
friend
void
write
(
cv
::
FileStorage
&
fs
,
const
std
::
string
&
,
const
ICF
&
f
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
ICF
&
f
);
};
void
write
(
cv
::
FileStorage
&
fs
,
const
std
::
string
&
,
const
ICF
&
f
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
ICF
&
m
);
using
cv
::
FeaturePool
;
using
cv
::
Dataset
;
...
...
@@ -115,7 +73,7 @@ private:
cv
::
Size
model
;
int
nfeatures
;
std
::
vector
<
ICF
>
pool
;
std
::
vector
<
cv
::
ChannelFeature
>
pool
;
static
const
unsigned
int
seed
=
0
;
...
...
modules/softcascade/include/opencv2/softcascade/softcascade.hpp
View file @
b4aa33b6
...
...
@@ -87,6 +87,31 @@ public:
virtual
~
Dataset
();
};
// ========================================================================== //
// First order channel feature.
// ========================================================================== //
class
CV_EXPORTS
ChannelFeature
{
public
:
ChannelFeature
(
int
x
,
int
y
,
int
w
,
int
h
,
int
ch
);
~
ChannelFeature
();
bool
operator
==
(
ChannelFeature
b
);
bool
operator
!=
(
ChannelFeature
b
);
float
operator
()
(
const
cv
::
Mat
&
integrals
,
const
cv
::
Size
&
model
)
const
;
friend
void
write
(
cv
::
FileStorage
&
fs
,
const
std
::
string
&
,
const
ChannelFeature
&
f
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
ChannelFeature
&
f
);
private
:
cv
::
Rect
bb
;
int
channel
;
};
void
write
(
cv
::
FileStorage
&
fs
,
const
std
::
string
&
,
const
ChannelFeature
&
f
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
ChannelFeature
&
m
);
// ========================================================================== //
// Public Interface for Integral Channel Feature.
...
...
modules/softcascade/src/_random.hpp
0 → 100644
View file @
b4aa33b6
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __SFT_RANDOM_HPP__
#define __SFT_RANDOM_HPP__
#if defined(_MSC_VER) && _MSC_VER >= 1600
# include <random>
namespace
sft
{
struct
Random
{
typedef
std
::
mt19937
engine
;
typedef
std
::
uniform_int
<
int
>
uniform
;
};
}
#elif (__GNUC__) && __GNUC__ > 3 && __GNUC_MINOR__ > 1 && !defined(__ANDROID__)
# if defined (__cplusplus) && __cplusplus > 201100L
# include <random>
namespace
sft
{
struct
Random
{
typedef
std
::
mt19937
engine
;
typedef
std
::
uniform_int
<
int
>
uniform
;
};
}
# else
# include <tr1/random>
namespace
sft
{
struct
Random
{
typedef
std
::
tr1
::
mt19937
engine
;
typedef
std
::
tr1
::
uniform_int
<
int
>
uniform
;
};
}
# endif
#else
#include <opencv2/core/core.hpp>
namespace
rnd
{
typedef
cv
::
RNG
engine
;
template
<
typename
T
>
struct
uniform_int
{
uniform_int
(
const
int
_min
,
const
int
_max
)
:
min
(
_min
),
max
(
_max
)
{}
T
operator
()
(
engine
&
eng
,
const
int
bound
)
const
{
return
(
T
)
eng
.
uniform
(
min
,
bound
);
}
T
operator
()
(
engine
&
eng
)
const
{
return
(
T
)
eng
.
uniform
(
min
,
max
);
}
private
:
int
min
;
int
max
;
};
}
namespace
sft
{
struct
Random
{
typedef
rnd
::
engine
engine
;
typedef
rnd
::
uniform_int
<
int
>
uniform
;
};
}
#endif
#endif
\ No newline at end of file
modules/softcascade/src/integral_channel_builder.cpp
View file @
b4aa33b6
...
...
@@ -44,9 +44,9 @@
namespace
{
class
ICF
:
public
cv
::
ChannelFeatureBuilder
class
ICF
Builder
:
public
cv
::
ChannelFeatureBuilder
{
virtual
~
ICF
()
{}
virtual
~
ICF
Builder
()
{}
virtual
cv
::
AlgorithmInfo
*
info
()
const
;
virtual
void
operator
()(
cv
::
InputArray
_frame
,
CV_OUT
cv
::
OutputArray
_integrals
)
const
{
...
...
@@ -107,12 +107,56 @@ class ICF : public cv::ChannelFeatureBuilder
}
CV_INIT_ALGORITHM
(
ICF
,
"ChannelFeatureBuilder.ICF
"
,
);
CV_INIT_ALGORITHM
(
ICF
Builder
,
"ChannelFeatureBuilder.ICFBuilder
"
,
);
cv
::
ChannelFeatureBuilder
::~
ChannelFeatureBuilder
()
{}
cv
::
Ptr
<
cv
::
ChannelFeatureBuilder
>
cv
::
ChannelFeatureBuilder
::
create
()
{
cv
::
Ptr
<
cv
::
ChannelFeatureBuilder
>
builder
(
new
ICF
());
cv
::
Ptr
<
cv
::
ChannelFeatureBuilder
>
builder
(
new
ICF
Builder
());
return
builder
;
}
\ No newline at end of file
}
cv
::
ChannelFeature
::
ChannelFeature
(
int
x
,
int
y
,
int
w
,
int
h
,
int
ch
)
:
bb
(
cv
::
Rect
(
x
,
y
,
w
,
h
)),
channel
(
ch
)
{}
bool
cv
::
ChannelFeature
::
operator
==
(
cv
::
ChannelFeature
b
)
{
return
bb
==
b
.
bb
&&
channel
==
b
.
channel
;
}
bool
cv
::
ChannelFeature
::
operator
!=
(
cv
::
ChannelFeature
b
)
{
return
bb
!=
b
.
bb
||
channel
!=
b
.
channel
;
}
float
cv
::
ChannelFeature
::
operator
()
(
const
cv
::
Mat
&
integrals
,
const
cv
::
Size
&
model
)
const
{
int
step
=
model
.
width
+
1
;
const
int
*
ptr
=
integrals
.
ptr
<
int
>
(
0
)
+
(
model
.
height
*
channel
+
bb
.
y
)
*
step
+
bb
.
x
;
int
a
=
ptr
[
0
];
int
b
=
ptr
[
bb
.
width
];
ptr
+=
bb
.
height
*
step
;
int
c
=
ptr
[
bb
.
width
];
int
d
=
ptr
[
0
];
return
(
float
)(
a
-
b
+
c
-
d
);
}
void
cv
::
write
(
cv
::
FileStorage
&
fs
,
const
string
&
,
const
cv
::
ChannelFeature
&
f
)
{
fs
<<
"{"
<<
"channel"
<<
f
.
channel
<<
"rect"
<<
f
.
bb
<<
"}"
;
}
std
::
ostream
&
cv
::
operator
<<
(
std
::
ostream
&
out
,
const
cv
::
ChannelFeature
&
m
)
{
out
<<
m
.
channel
<<
" "
<<
m
.
bb
;
return
out
;
}
cv
::
ChannelFeature
::~
ChannelFeature
(){}
modules/softcascade/src/soft_cascade_octave.cpp
View file @
b4aa33b6
...
...
@@ -43,6 +43,7 @@
#include "precomp.hpp"
#include <queue>
#include <string>
#include "_random.hpp"
#define WITH_DEBUG_OUT
...
...
@@ -53,75 +54,6 @@
# define dprintf(format, ...)
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1600
# include <random>
namespace
sft
{
struct
Random
{
typedef
std
::
mt19937
engine
;
typedef
std
::
uniform_int
<
int
>
uniform
;
};
}
#elif (__GNUC__) && __GNUC__ > 3 && __GNUC_MINOR__ > 1 && !defined(__ANDROID__)
# if defined (__cplusplus) && __cplusplus > 201100L
# include <random>
namespace
sft
{
struct
Random
{
typedef
std
::
mt19937
engine
;
typedef
std
::
uniform_int
<
int
>
uniform
;
};
}
# else
# include <tr1/random>
namespace
sft
{
struct
Random
{
typedef
std
::
tr1
::
mt19937
engine
;
typedef
std
::
tr1
::
uniform_int
<
int
>
uniform
;
};
}
# endif
#else
#include <opencv2/core/core.hpp>
namespace
rnd
{
typedef
cv
::
RNG
engine
;
template
<
typename
T
>
struct
uniform_int
{
uniform_int
(
const
int
_min
,
const
int
_max
)
:
min
(
_min
),
max
(
_max
)
{}
T
operator
()
(
engine
&
eng
,
const
int
bound
)
const
{
return
(
T
)
eng
.
uniform
(
min
,
bound
);
}
T
operator
()
(
engine
&
eng
)
const
{
return
(
T
)
eng
.
uniform
(
min
,
max
);
}
private
:
int
min
;
int
max
;
};
}
namespace
sft
{
struct
Random
{
typedef
rnd
::
engine
engine
;
typedef
rnd
::
uniform_int
<
int
>
uniform
;
};
}
#endif
using
cv
::
Dataset
;
using
cv
::
FeaturePool
;
...
...
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