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
554080d8
Commit
554080d8
authored
Dec 06, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add file globbing
parent
86973f8e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
4 deletions
+114
-4
common.hpp
apps/sft/include/sft/common.hpp
+6
-1
octave.hpp
apps/sft/include/sft/octave.hpp
+12
-1
random.hpp
apps/sft/include/sft/random.hpp
+42
-0
octave.cpp
apps/sft/octave.cpp
+50
-1
sft.cpp
apps/sft/sft.cpp
+4
-1
No files found.
apps/sft/include/sft/common.hpp
View file @
554080d8
...
@@ -49,8 +49,12 @@ namespace sft
...
@@ -49,8 +49,12 @@ namespace sft
{
{
using
cv
::
Mat
;
using
cv
::
Mat
;
struct
ICF
;
struct
ICF
;
typedef
std
::
vector
<
ICF
>
Icfvector
;
typedef
std
::
string
string
;
typedef
std
::
vector
<
ICF
>
Icfvector
;
typedef
std
::
vector
<
sft
::
string
>
svector
;
}
}
#endif
#endif
\ No newline at end of file
apps/sft/include/sft/octave.hpp
View file @
554080d8
...
@@ -49,6 +49,16 @@
...
@@ -49,6 +49,16 @@
namespace
sft
namespace
sft
{
{
class
Dataset
{
public
:
Dataset
(
const
sft
::
string
&
path
,
const
int
octave
);
private
:
svector
pos
;
svector
neg
;
};
struct
ICF
struct
ICF
{
{
ICF
(
int
x
,
int
y
,
int
w
,
int
h
,
int
ch
)
:
bb
(
cv
::
Rect
(
x
,
y
,
w
,
h
)),
channel
(
ch
)
{}
ICF
(
int
x
,
int
y
,
int
w
,
int
h
,
int
ch
)
:
bb
(
cv
::
Rect
(
x
,
y
,
w
,
h
)),
channel
(
ch
)
{}
...
@@ -93,12 +103,13 @@ private:
...
@@ -93,12 +103,13 @@ private:
class
Octave
:
cv
::
Boost
class
Octave
:
cv
::
Boost
{
{
public
:
public
:
Octave
();
Octave
(
int
logScale
);
virtual
~
Octave
();
virtual
~
Octave
();
virtual
bool
train
(
const
cv
::
Mat
&
trainData
,
const
cv
::
Mat
&
responses
,
const
cv
::
Mat
&
varIdx
=
cv
::
Mat
(),
virtual
bool
train
(
const
cv
::
Mat
&
trainData
,
const
cv
::
Mat
&
responses
,
const
cv
::
Mat
&
varIdx
=
cv
::
Mat
(),
const
cv
::
Mat
&
sampleIdx
=
cv
::
Mat
(),
const
cv
::
Mat
&
varType
=
cv
::
Mat
(),
const
cv
::
Mat
&
missingDataMask
=
cv
::
Mat
());
const
cv
::
Mat
&
sampleIdx
=
cv
::
Mat
(),
const
cv
::
Mat
&
varType
=
cv
::
Mat
(),
const
cv
::
Mat
&
missingDataMask
=
cv
::
Mat
());
int
logScale
;
private
:
private
:
CvBoostParams
params
;
CvBoostParams
params
;
};
};
...
...
apps/sft/include/sft/random.hpp
View file @
554080d8
/*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__
#ifndef __SFT_RANDOM_HPP__
#define __SFT_RANDOM_HPP__
#define __SFT_RANDOM_HPP__
...
...
apps/sft/octave.cpp
View file @
554080d8
...
@@ -54,8 +54,10 @@
...
@@ -54,8 +54,10 @@
# define show(a, b)
# define show(a, b)
#endif
#endif
#include <glob.h>
// ============ Octave ============ //
// ============ Octave ============ //
sft
::
Octave
::
Octave
(
)
{}
sft
::
Octave
::
Octave
(
int
ls
)
:
logScale
(
ls
)
{}
sft
::
Octave
::~
Octave
(){}
sft
::
Octave
::~
Octave
(){}
...
@@ -121,4 +123,50 @@ void sft::FeaturePool::fill(int desired)
...
@@ -121,4 +123,50 @@ void sft::FeaturePool::fill(int desired)
if
(
std
::
find
(
pool
.
begin
(),
pool
.
end
(),
f
)
==
pool
.
end
())
if
(
std
::
find
(
pool
.
begin
(),
pool
.
end
(),
f
)
==
pool
.
end
())
pool
.
push_back
(
f
);
pool
.
push_back
(
f
);
}
}
}
// ============ Dataset ============ //
namespace
{
using
namespace
sft
;
string
itoa
(
long
i
)
{
char
s
[
65
];
sprintf
(
s
,
"%ld"
,
i
);
return
std
::
string
(
s
);
}
void
glob
(
const
string
&
path
,
svector
&
ret
)
{
glob_t
glob_result
;
glob
(
path
.
c_str
(),
GLOB_TILDE
,
0
,
&
glob_result
);
ret
.
clear
();
ret
.
reserve
(
glob_result
.
gl_pathc
);
for
(
uint
i
=
0
;
i
<
glob_result
.
gl_pathc
;
++
i
)
{
ret
.
push_back
(
std
::
string
(
glob_result
.
gl_pathv
[
i
]));
// dprintf("%s\n", ret[i].c_str());
}
globfree
(
&
glob_result
);
}
}
// in the default case data folders should be alligned as following:
// 1. positives: <train or test path>/octave_<octave number>/pos/*.png
// 2. negatives: <train or test path>/octave_<octave number>/neg/*.png
Dataset
::
Dataset
(
const
string
&
path
,
const
int
oct
)
{
// dprintf("%s\n", "get dataset file names...");
// dprintf("%s\n", "Positives globbing...");
glob
(
path
+
"/pos/octave_"
+
itoa
(
oct
)
+
"/*.png"
,
pos
);
// dprintf("%s\n", "Negatives globbing...");
glob
(
path
+
"/neg/octave_"
+
itoa
(
oct
)
+
"/*.png"
,
neg
);
// Check: files not empty
CV_Assert
(
pos
.
size
()
!=
size_t
(
0
));
CV_Assert
(
neg
.
size
()
!=
size_t
(
0
));
}
}
\ No newline at end of file
apps/sft/sft.cpp
View file @
554080d8
...
@@ -51,13 +51,16 @@ int main(int argc, char** argv)
...
@@ -51,13 +51,16 @@ int main(int argc, char** argv)
int
nfeatures
=
50
;
int
nfeatures
=
50
;
int
npositives
=
10
;
int
npositives
=
10
;
int
nnegatives
=
10
;
int
nnegatives
=
10
;
int
nsamples
=
npositives
+
nnegatives
;
int
nsamples
=
npositives
+
nnegatives
;
cv
::
Size
model
(
64
,
128
);
cv
::
Size
model
(
64
,
128
);
std
::
string
path
=
"/home/kellan/cuda-dev/opencv_extra/testdata/sctrain/rescaled-train-2012-10-27-19-02-52"
;
sft
::
Octave
boost
;
sft
::
Octave
boost
(
0
)
;
cv
::
Mat
train_data
(
nfeatures
,
nsamples
,
CV_32FC1
);
cv
::
Mat
train_data
(
nfeatures
,
nsamples
,
CV_32FC1
);
sft
::
FeaturePool
pool
(
model
,
nfeatures
);
sft
::
FeaturePool
pool
(
model
,
nfeatures
);
sft
::
Dataset
(
path
,
boost
.
logScale
);
cv
::
RNG
rng
;
cv
::
RNG
rng
;
...
...
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