Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
38168334
Commit
38168334
authored
Oct 25, 2014
by
Dmitriy Anisimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added first version of hpe_humaneva dataset loader
parent
44f47427
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
418 additions
and
0 deletions
+418
-0
hpe_humaneva.hpp
modules/datasets/include/opencv2/datasets/hpe_humaneva.hpp
+85
-0
hpe_humaneva.cpp
modules/datasets/samples/hpe_humaneva.cpp
+100
-0
hpe_humaneva.cpp
modules/datasets/src/hpe_humaneva.cpp
+233
-0
No files found.
modules/datasets/include/opencv2/datasets/hpe_humaneva.hpp
0 → 100644
View file @
38168334
/*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) 2014, Itseez 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 Itseez Inc 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 OPENCV_DATASETS_HPE_HUMANEVA_HPP
#define OPENCV_DATASETS_HPE_HUMANEVA_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace
cv
{
namespace
datasets
{
struct
HPE_humanevaObj
:
public
Object
{
char
person
;
// 1..4
std
::
string
action
;
int
type1
;
std
::
string
type2
;
Matx13d
ofs
;
std
::
string
fileName
;
std
::
vector
<
std
::
string
>
imageNames
;
// for HumanEva_II
};
enum
datasetType
{
humaneva_1
=
1
,
humaneva_2
};
class
CV_EXPORTS
HPE_humaneva
:
public
Dataset
{
public
:
virtual
void
load
(
const
std
::
string
&
path
)
=
0
;
static
Ptr
<
HPE_humaneva
>
create
(
int
num
=
humaneva_1
);
};
}
}
#endif
modules/datasets/samples/hpe_humaneva.cpp
0 → 100644
View file @
38168334
/*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) 2014, Itseez 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 Itseez Inc 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*/
#include "opencv2/datasets/hpe_humaneva.hpp"
#include <opencv2/core.hpp>
#include <cstdio>
#include <cstdlib> // atoi
#include <string>
#include <vector>
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
datasets
;
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
keys
=
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset folder }"
;
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
path
(
parser
.
get
<
string
>
(
"path"
));
if
(
parser
.
has
(
"help"
)
||
path
==
"true"
)
{
parser
.
printMessage
();
return
-
1
;
}
for
(
unsigned
int
i
=
1
;
i
<=
2
;
++
i
)
{
printf
(
"
\t
HumanEva %u
\n
"
,
i
);
char
number
[
2
];
sprintf
(
number
,
"%u"
,
i
);
string
pathCurr
(
path
+
"HumanEva_"
+
number
+
"/"
);
Ptr
<
HPE_humaneva
>
dataset
=
HPE_humaneva
::
create
(
i
);
dataset
->
load
(
pathCurr
);
// ***************
// dataset contains pair of rgb\dep images
// For example, let output train size and last element.
HPE_humanevaObj
*
example
=
static_cast
<
HPE_humanevaObj
*>
(
dataset
->
getTrain
().
back
().
get
());
printf
(
"train size: %u
\n
"
,
(
unsigned
int
)
dataset
->
getTrain
().
size
());
printf
(
"last train video:
\n
"
);
printf
(
"person: %u
\n
"
,
example
->
person
);
printf
(
"action: %s
\n
"
,
example
->
action
.
c_str
());
printf
(
"type1: %u
\n
"
,
example
->
type1
);
printf
(
"type2: %s
\n
"
,
example
->
type2
.
c_str
());
printf
(
"filename: %s
\n
"
,
example
->
fileName
.
c_str
());
printf
(
"num images: %u
\n
"
,
(
int
)
example
->
imageNames
.
size
());
printf
(
"ofs:"
);
for
(
int
j
=
0
;
j
<
3
;
++
j
)
{
printf
(
" %f"
,
example
->
ofs
(
0
,
j
));
}
printf
(
"
\n
"
);
}
return
0
;
}
modules/datasets/src/hpe_humaneva.cpp
0 → 100644
View file @
38168334
/*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) 2014, Itseez 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 Itseez Inc 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*/
#include "opencv2/datasets/hpe_humaneva.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
#include <cstring>
namespace
cv
{
namespace
datasets
{
using
namespace
std
;
class
HPE_humanevaImp
:
public
HPE_humaneva
{
public
:
HPE_humanevaImp
()
{}
//HPE_humanevaImp(const string &path);
virtual
~
HPE_humanevaImp
()
{}
virtual
void
load
(
const
string
&
path
);
private
:
void
loadDataset
(
const
string
&
path
);
};
/*HPE_humanevaImp::HPE_humanevaImp(const string &path)
{
loadDataset(path);
}*/
void
HPE_humanevaImp
::
load
(
const
string
&
path
)
{
loadDataset
(
path
);
}
void
HPE_humanevaImp
::
loadDataset
(
const
string
&
path
)
{
train
.
push_back
(
vector
<
Ptr
<
Object
>
>
());
test
.
push_back
(
vector
<
Ptr
<
Object
>
>
());
validation
.
push_back
(
vector
<
Ptr
<
Object
>
>
());
for
(
unsigned
int
i
=
1
;
i
<=
4
;
++
i
)
{
char
number
[
2
];
sprintf
(
number
,
"%u"
,
i
);
string
pathDatasetI
(
path
+
"S"
+
number
+
"/Image_Data/"
);
string
pathDatasetS
(
path
+
"S"
+
number
+
"/Sync_Data/"
);
vector
<
string
>
fileNames
;
getDirList
(
pathDatasetI
,
fileNames
);
for
(
vector
<
string
>::
iterator
it
=
fileNames
.
begin
();
it
!=
fileNames
.
end
();
++
it
)
{
string
&
file
=
*
it
;
vector
<
string
>
elems
;
split
(
file
,
elems
,
'_'
);
if
(
elems
.
size
()
!=
3
)
{
continue
;
}
Ptr
<
HPE_humanevaObj
>
curr
(
new
HPE_humanevaObj
);
curr
->
person
=
(
char
)
i
;
curr
->
action
=
elems
[
0
];
curr
->
type1
=
atoi
(
elems
[
1
].
c_str
());
curr
->
fileName
=
pathDatasetI
+
file
;
unsigned
int
type2End
=
2
;
if
(
elems
[
2
][
type2End
+
1
]
!=
')'
)
{
type2End
=
3
;
}
curr
->
type2
=
elems
[
2
].
substr
(
1
,
type2End
);
file
=
file
.
substr
(
0
,
file
.
length
()
-
3
)
+
"ofs"
;
ifstream
infileOFS
((
pathDatasetS
+
file
).
c_str
());
string
line
;
unsigned
int
j
=
0
;
while
(
getline
(
infileOFS
,
line
))
{
curr
->
ofs
(
0
,
j
)
=
atof
(
line
.
c_str
());
++
j
;
}
train
.
back
().
push_back
(
curr
);
}
}
}
//
// HumanEva II
//
class
HPE_humanevaImpII
:
public
HPE_humaneva
{
public
:
HPE_humanevaImpII
()
{}
//HPE_humanevaImpII(const string &path);
virtual
~
HPE_humanevaImpII
()
{}
virtual
void
load
(
const
string
&
path
);
private
:
void
loadDataset
(
const
string
&
path
);
};
/*HPE_humanevaImpII::HPE_humanevaImpII(const string &path)
{
loadDataset(path);
}*/
void
HPE_humanevaImpII
::
load
(
const
string
&
path
)
{
loadDataset
(
path
);
}
void
HPE_humanevaImpII
::
loadDataset
(
const
string
&
path
)
{
train
.
push_back
(
vector
<
Ptr
<
Object
>
>
());
test
.
push_back
(
vector
<
Ptr
<
Object
>
>
());
validation
.
push_back
(
vector
<
Ptr
<
Object
>
>
());
for
(
unsigned
int
i
=
1
;
i
<=
2
;
++
i
)
{
char
number
[
2
];
sprintf
(
number
,
"%u"
,
i
*
2
);
// 2 & 4
string
pathDatasetI
(
path
+
"S"
+
number
+
"/Image_Data/"
);
string
pathDatasetS
(
path
+
"S"
+
number
+
"/Sync_Data/"
);
vector
<
string
>
fileNames
;
getDirList
(
pathDatasetI
,
fileNames
);
for
(
vector
<
string
>::
iterator
it
=
fileNames
.
begin
();
it
!=
fileNames
.
end
();
++
it
)
{
string
&
file
=
*
it
;
vector
<
string
>
elems
;
split
(
file
,
elems
,
'_'
);
if
(
elems
.
size
()
!=
3
)
{
continue
;
}
Ptr
<
HPE_humanevaObj
>
curr
(
new
HPE_humanevaObj
);
curr
->
person
=
(
char
)
i
;
curr
->
action
=
elems
[
0
];
curr
->
type1
=
atoi
(
elems
[
1
].
c_str
());
curr
->
fileName
=
pathDatasetI
+
file
;
unsigned
int
type2End
=
2
;
if
(
elems
[
2
][
type2End
+
1
]
!=
')'
)
{
type2End
=
3
;
}
curr
->
type2
=
elems
[
2
].
substr
(
1
,
type2End
);
vector
<
string
>
imageNames
;
getDirList
(
curr
->
fileName
,
imageNames
);
for
(
vector
<
string
>::
iterator
itI
=
imageNames
.
begin
();
itI
!=
imageNames
.
end
();
++
itI
)
{
string
&
image
=
*
itI
;
if
(
image
.
substr
(
image
.
length
()
-
3
)
==
"png"
)
{
curr
->
imageNames
.
push_back
(
image
);
}
}
file
=
file
.
substr
(
0
,
file
.
length
())
+
".ofs"
;
ifstream
infileOFS
((
pathDatasetS
+
file
).
c_str
());
string
line
;
unsigned
int
j
=
0
;
while
(
getline
(
infileOFS
,
line
))
{
curr
->
ofs
(
0
,
j
)
=
atof
(
line
.
c_str
());
++
j
;
}
train
.
back
().
push_back
(
curr
);
}
}
}
Ptr
<
HPE_humaneva
>
HPE_humaneva
::
create
(
int
num
)
{
if
(
humaneva_2
==
num
)
{
return
Ptr
<
HPE_humanevaImpII
>
(
new
HPE_humanevaImpII
);
}
return
Ptr
<
HPE_humanevaImp
>
(
new
HPE_humanevaImp
);
}
}
}
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