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
8672ae58
Commit
8672ae58
authored
Jan 09, 2013
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix globbing under win
parent
e2de3b0b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
16 deletions
+80
-16
fpool.cpp
apps/sft/fpool.cpp
+70
-3
common.hpp
apps/sft/include/sft/common.hpp
+1
-2
config.hpp
apps/sft/include/sft/config.hpp
+2
-2
ml.hpp
modules/ml/include/opencv2/ml/ml.hpp
+3
-3
octave.cpp
modules/ml/src/octave.cpp
+4
-6
No files found.
apps/sft/fpool.cpp
View file @
8672ae58
...
@@ -43,7 +43,6 @@
...
@@ -43,7 +43,6 @@
#include <sft/fpool.hpp>
#include <sft/fpool.hpp>
#include <sft/random.hpp>
#include <sft/random.hpp>
#include <glob.h>
#include <queue>
#include <queue>
// ========= FeaturePool ========= //
// ========= FeaturePool ========= //
...
@@ -89,8 +88,8 @@ void sft::ICFFeaturePool::fill(int desired)
...
@@ -89,8 +88,8 @@ void sft::ICFFeaturePool::fill(int desired)
pool
.
reserve
(
nfeatures
);
pool
.
reserve
(
nfeatures
);
sft
::
Random
::
engine
eng
(
8854342234L
);
sft
::
Random
::
engine
eng
(
8854342234L
U
);
sft
::
Random
::
engine
eng_ch
(
314152314L
);
sft
::
Random
::
engine
eng_ch
(
314152314L
U
);
sft
::
Random
::
uniform
chRand
(
0
,
N_CHANNELS
-
1
);
sft
::
Random
::
uniform
chRand
(
0
,
N_CHANNELS
-
1
);
...
@@ -142,6 +141,14 @@ string itoa(long i)
...
@@ -142,6 +141,14 @@ string itoa(long i)
return
std
::
string
(
s
);
return
std
::
string
(
s
);
}
}
}
#if !defined (_WIN32) && ! defined(__MINGW32__)
#include <glob.h>
namespace
{
using
namespace
sft
;
void
glob
(
const
string
&
path
,
svector
&
ret
)
void
glob
(
const
string
&
path
,
svector
&
ret
)
{
{
glob_t
glob_result
;
glob_t
glob_result
;
...
@@ -158,7 +165,58 @@ void glob(const string& path, svector& ret)
...
@@ -158,7 +165,58 @@ void glob(const string& path, svector& ret)
globfree
(
&
glob_result
);
globfree
(
&
glob_result
);
}
}
}
#else
#include <windows.h>
namespace
{
using
namespace
sft
;
void
glob
(
const
string
&
refRoot
,
const
string
&
refExt
,
svector
&
refvecFiles
)
{
std
::
string
strFilePath
;
// Filepath
std
::
string
strExtension
;
// Extension
std
::
string
strPattern
=
refRoot
+
"
\\
*.*"
;
WIN32_FIND_DATA
FileInformation
;
// File information
HANDLE
hFile
=
::
FindFirstFile
(
strPattern
.
c_str
(),
&
FileInformation
);
if
(
hFile
==
INVALID_HANDLE_VALUE
)
CV_Error
(
CV_StsBadArg
,
"Your dataset search path is incorrect"
);
do
{
if
(
FileInformation
.
cFileName
[
0
]
!=
'.'
)
{
strFilePath
.
erase
();
strFilePath
=
refRoot
+
"
\\
"
+
FileInformation
.
cFileName
;
if
(
!
(
FileInformation
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
)
{
// Check extension
strExtension
=
FileInformation
.
cFileName
;
strExtension
=
strExtension
.
substr
(
strExtension
.
rfind
(
"."
)
+
1
);
if
(
strExtension
==
refExt
)
// Save filename
refvecFiles
.
push_back
(
strFilePath
);
}
}
}
while
(
::
FindNextFile
(
hFile
,
&
FileInformation
)
==
TRUE
);
// Close handle
::
FindClose
(
hFile
);
DWORD
dwError
=
::
GetLastError
();
if
(
dwError
!=
ERROR_NO_MORE_FILES
)
CV_Error
(
CV_StsBadArg
,
"Your dataset search path is incorrect"
);
}
}
}
#endif
// in the default case data folders should be alligned as following:
// in the default case data folders should be alligned as following:
// 1. positives: <train or test path>/octave_<octave number>/pos/*.png
// 1. positives: <train or test path>/octave_<octave number>/pos/*.png
// 2. negatives: <train or test path>/octave_<octave number>/neg/*.png
// 2. negatives: <train or test path>/octave_<octave number>/neg/*.png
...
@@ -167,10 +225,19 @@ ScaledDataset::ScaledDataset(const string& path, const int oct)
...
@@ -167,10 +225,19 @@ ScaledDataset::ScaledDataset(const string& path, const int oct)
dprintf
(
"%s
\n
"
,
"get dataset file names..."
);
dprintf
(
"%s
\n
"
,
"get dataset file names..."
);
dprintf
(
"%s
\n
"
,
"Positives globbing..."
);
dprintf
(
"%s
\n
"
,
"Positives globbing..."
);
#if !defined (_WIN32) && ! defined(__MINGW32__)
glob
(
path
+
"/pos/octave_"
+
itoa
(
oct
)
+
"/*.png"
,
pos
);
glob
(
path
+
"/pos/octave_"
+
itoa
(
oct
)
+
"/*.png"
,
pos
);
#else
glob
(
path
+
"/pos/octave_"
+
itoa
(
oct
),
"png"
,
pos
);
#endif
dprintf
(
"%s
\n
"
,
"Negatives globbing..."
);
dprintf
(
"%s
\n
"
,
"Negatives globbing..."
);
#if !defined (_WIN32) && ! defined(__MINGW32__)
glob
(
path
+
"/neg/octave_"
+
itoa
(
oct
)
+
"/*.png"
,
neg
);
glob
(
path
+
"/neg/octave_"
+
itoa
(
oct
)
+
"/*.png"
,
neg
);
#else
glob
(
path
+
"/neg/octave_"
+
itoa
(
oct
),
"png"
,
neg
);
#endif
// Check: files not empty
// Check: files not empty
CV_Assert
(
pos
.
size
()
!=
size_t
(
0
));
CV_Assert
(
pos
.
size
()
!=
size_t
(
0
));
...
...
apps/sft/include/sft/common.hpp
View file @
8672ae58
...
@@ -62,8 +62,7 @@ namespace sft
...
@@ -62,8 +62,7 @@ namespace sft
#if defined WITH_DEBUG_OUT
#if defined WITH_DEBUG_OUT
# include <stdio.h>
# include <stdio.h>
# define dprintf(format, ...) \
# define dprintf(format, ...) printf(format, ##__VA_ARGS__)
do { printf(format, ##__VA_ARGS__); } while (0)
#else
#else
# define dprintf(format, ...)
# define dprintf(format, ...)
#endif
#endif
...
...
apps/sft/include/sft/config.hpp
View file @
8672ae58
...
@@ -60,7 +60,7 @@ struct Config
...
@@ -60,7 +60,7 @@ struct Config
// Scaled and shrunk model size.
// Scaled and shrunk model size.
cv
::
Size
model
(
ivector
::
const_iterator
it
)
const
cv
::
Size
model
(
ivector
::
const_iterator
it
)
const
{
{
float
octave
=
powf
(
2
,
*
it
);
float
octave
=
powf
(
2
.
f
,
*
it
);
return
cv
::
Size
(
cvRound
(
modelWinSize
.
width
*
octave
)
/
shrinkage
,
return
cv
::
Size
(
cvRound
(
modelWinSize
.
width
*
octave
)
/
shrinkage
,
cvRound
(
modelWinSize
.
height
*
octave
)
/
shrinkage
);
cvRound
(
modelWinSize
.
height
*
octave
)
/
shrinkage
);
}
}
...
@@ -68,7 +68,7 @@ struct Config
...
@@ -68,7 +68,7 @@ struct Config
// Scaled but, not shrunk bounding box for object in sample image.
// Scaled but, not shrunk bounding box for object in sample image.
cv
::
Rect
bbox
(
ivector
::
const_iterator
it
)
const
cv
::
Rect
bbox
(
ivector
::
const_iterator
it
)
const
{
{
float
octave
=
powf
(
2
,
*
it
);
float
octave
=
powf
(
2
.
f
,
*
it
);
return
cv
::
Rect
(
cvRound
(
offset
.
x
*
octave
),
cvRound
(
offset
.
y
*
octave
),
return
cv
::
Rect
(
cvRound
(
offset
.
x
*
octave
),
cvRound
(
offset
.
y
*
octave
),
cvRound
(
modelWinSize
.
width
*
octave
),
cvRound
(
modelWinSize
.
height
*
octave
));
cvRound
(
modelWinSize
.
width
*
octave
),
cvRound
(
modelWinSize
.
height
*
octave
));
}
}
...
...
modules/ml/include/opencv2/ml/ml.hpp
View file @
8672ae58
...
@@ -2132,7 +2132,7 @@ template<> CV_EXPORTS void Ptr<CvDTreeSplit>::delete_obj();
...
@@ -2132,7 +2132,7 @@ template<> CV_EXPORTS void Ptr<CvDTreeSplit>::delete_obj();
CV_EXPORTS
bool
initModule_ml
(
void
);
CV_EXPORTS
bool
initModule_ml
(
void
);
CV_EXPORTS
class
FeaturePool
class
CV_EXPORTS
FeaturePool
{
{
public
:
public
:
...
@@ -2145,7 +2145,7 @@ public:
...
@@ -2145,7 +2145,7 @@ public:
virtual
~
FeaturePool
();
virtual
~
FeaturePool
();
};
};
class
Dataset
class
CV_EXPORTS
Dataset
{
{
public
:
public
:
typedef
enum
{
POSITIVE
=
1
,
NEGATIVE
=
2
}
SampleType
;
typedef
enum
{
POSITIVE
=
1
,
NEGATIVE
=
2
}
SampleType
;
...
@@ -2156,7 +2156,7 @@ public:
...
@@ -2156,7 +2156,7 @@ public:
};
};
// used for traning single octave scale
// used for traning single octave scale
class
Octave
:
cv
::
Boost
class
CV_EXPORTS
Octave
:
public
cv
::
Boost
{
{
public
:
public
:
...
...
modules/ml/src/octave.cpp
View file @
8672ae58
...
@@ -47,8 +47,7 @@
...
@@ -47,8 +47,7 @@
#if defined WITH_DEBUG_OUT
#if defined WITH_DEBUG_OUT
# include <stdio.h>
# include <stdio.h>
# define dprintf(format, ...) \
# define dprintf(format, ...) printf(format, ##__VA_ARGS__)
do { printf(format, ##__VA_ARGS__); } while (0)
#else
#else
# define dprintf(format, ...)
# define dprintf(format, ...)
#endif
#endif
...
@@ -121,7 +120,6 @@ struct Random
...
@@ -121,7 +120,6 @@ struct Random
typedef
rnd
::
uniform_int
<
int
>
uniform
;
typedef
rnd
::
uniform_int
<
int
>
uniform
;
};
};
}
}
#endif
#endif
cv
::
FeaturePool
::~
FeaturePool
(){}
cv
::
FeaturePool
::~
FeaturePool
(){}
...
@@ -244,8 +242,8 @@ void cv::Octave::processPositives(const Dataset* dataset, const FeaturePool* poo
...
@@ -244,8 +242,8 @@ void cv::Octave::processPositives(const Dataset* dataset, const FeaturePool* poo
void
cv
::
Octave
::
generateNegatives
(
const
Dataset
*
dataset
,
const
FeaturePool
*
pool
)
void
cv
::
Octave
::
generateNegatives
(
const
Dataset
*
dataset
,
const
FeaturePool
*
pool
)
{
{
// ToDo: set seed, use offsets
// ToDo: set seed, use offsets
sft
::
Random
::
engine
eng
(
65633343L
);
sft
::
Random
::
engine
eng
(
65633343L
U
);
sft
::
Random
::
engine
idxEng
(
764224349868L
);
sft
::
Random
::
engine
idxEng
(
764224349868L
U
);
int
h
=
boundingBox
.
height
;
int
h
=
boundingBox
.
height
;
...
@@ -350,7 +348,7 @@ void cv::Octave::traverse(const CvBoostTree* tree, cv::FileStorage& fs, int& nfe
...
@@ -350,7 +348,7 @@ void cv::Octave::traverse(const CvBoostTree* tree, cv::FileStorage& fs, int& nfe
void
cv
::
Octave
::
write
(
cv
::
FileStorage
&
fso
,
const
FeaturePool
*
pool
,
InputArray
_thresholds
)
const
void
cv
::
Octave
::
write
(
cv
::
FileStorage
&
fso
,
const
FeaturePool
*
pool
,
InputArray
_thresholds
)
const
{
{
CV_Assert
(
!
_thresholds
.
empty
());
CV_Assert
(
!
_thresholds
.
empty
());
cv
::
Mat
used
(
1
,
weak
->
total
*
(
pow
(
2.
f
,
params
.
max_depth
)
-
1
),
CV_32SC1
);
cv
::
Mat
used
(
1
,
weak
->
total
*
(
(
int
)
pow
(
2.
f
,
params
.
max_depth
)
-
1
),
CV_32SC1
);
int
*
usedPtr
=
used
.
ptr
<
int
>
(
0
);
int
*
usedPtr
=
used
.
ptr
<
int
>
(
0
);
int
nfeatures
=
0
;
int
nfeatures
=
0
;
cv
::
Mat
thresholds
=
_thresholds
.
getMat
();
cv
::
Mat
thresholds
=
_thresholds
.
getMat
();
...
...
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