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
c5bc6e82
Commit
c5bc6e82
authored
Oct 21, 2014
by
Dmitriy Anisimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added fr_adience dataset loader
parent
e16ba043
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
373 additions
and
0 deletions
+373
-0
fr_adience.hpp
modules/datasets/include/opencv2/datasets/fr_adience.hpp
+93
-0
fr_adience.cpp
modules/datasets/samples/fr_adience.cpp
+105
-0
fr_adience.cpp
modules/datasets/src/fr_adience.cpp
+175
-0
No files found.
modules/datasets/include/opencv2/datasets/fr_adience.hpp
0 → 100644
View file @
c5bc6e82
/*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_FR_ADIENCE_HPP
#define OPENCV_DATASETS_FR_ADIENCE_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include <opencv2/core.hpp>
namespace
cv
{
namespace
datasets
{
enum
genderType
{
male
=
0
,
female
,
none
};
struct
FR_adienceObj
:
public
Object
{
std
::
string
user_id
;
std
::
string
original_image
;
int
face_id
;
std
::
string
age
;
genderType
gender
;
int
x
;
int
y
;
int
dx
;
int
dy
;
int
tilt_ang
;
int
fiducial_yaw_angle
;
int
fiducial_score
;
};
class
CV_EXPORTS
FR_adience
:
public
Dataset
{
public
:
virtual
void
load
(
const
std
::
string
&
path
)
=
0
;
static
Ptr
<
FR_adience
>
create
();
std
::
vector
<
std
::
string
>
paths
;
};
}
}
#endif
modules/datasets/samples/fr_adience.cpp
0 → 100644
View file @
c5bc6e82
/*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/fr_adience.hpp"
#include <opencv2/core.hpp>
#include <cstdio>
#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 and splits }"
;
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
path
(
parser
.
get
<
string
>
(
"path"
));
if
(
parser
.
has
(
"help"
)
||
path
==
"true"
)
{
parser
.
printMessage
();
return
-
1
;
}
Ptr
<
FR_adience
>
dataset
=
FR_adience
::
create
();
dataset
->
load
(
path
);
// ***************
// dataset contains for each object its images.
// For example, let output splits number, dataset size and last image.
int
numSplits
=
dataset
->
getNumSplits
();
printf
(
"splits number: %u
\n
"
,
numSplits
);
printf
(
"dataset size: %u
\n
"
,
(
unsigned
int
)
dataset
->
getTrain
().
size
());
FR_adienceObj
*
example
=
static_cast
<
FR_adienceObj
*>
(
dataset
->
getTrain
().
back
().
get
());
printf
(
"last image:
\n
"
);
printf
(
"user_id: %s
\n
"
,
example
->
user_id
.
c_str
());
printf
(
"original_image: %s
\n
"
,
example
->
original_image
.
c_str
());
printf
(
"face_id: %u
\n
"
,
example
->
face_id
);
printf
(
"age: %s
\n
"
,
example
->
age
.
c_str
());
printf
(
"gender: "
);
if
(
example
->
gender
==
male
)
{
printf
(
"m
\n
"
);
}
else
if
(
example
->
gender
==
female
)
{
printf
(
"f
\n
"
);
}
else
{
printf
(
"none
\n
"
);
}
printf
(
"x: %u
\n
"
,
example
->
x
);
printf
(
"y: %u
\n
"
,
example
->
y
);
printf
(
"dx: %u
\n
"
,
example
->
dx
);
printf
(
"dy: %u
\n
"
,
example
->
dy
);
printf
(
"tilt_ang: %u
\n
"
,
example
->
tilt_ang
);
printf
(
"fiducial_yaw_angle: %u
\n
"
,
example
->
fiducial_yaw_angle
);
printf
(
"fiducial_score: %u
\n
"
,
example
->
fiducial_score
);
return
0
;
}
modules/datasets/src/fr_adience.cpp
0 → 100644
View file @
c5bc6e82
/*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/fr_adience.hpp"
#include "opencv2/datasets/util.hpp"
#include "precomp.hpp"
namespace
cv
{
namespace
datasets
{
using
namespace
std
;
class
CV_EXPORTS
FR_adienceImp
:
public
FR_adience
{
public
:
FR_adienceImp
()
{}
//FR_adienceImp(const string &path);
virtual
~
FR_adienceImp
()
{}
virtual
void
load
(
const
string
&
path
);
private
:
void
loadDataset
(
const
string
&
path
);
void
loadFile
(
const
string
&
filename
,
vector
<
Ptr
<
FR_adienceObj
>
>
&
out
);
void
cv5ToSplits
(
vector
<
Ptr
<
FR_adienceObj
>
>
fileList
[
5
]);
};
/*FR_adienceImp::FR_adienceImp(const string &path)
{
loadDataset(path);
}*/
void
FR_adienceImp
::
load
(
const
string
&
path
)
{
loadDataset
(
path
);
}
void
FR_adienceImp
::
loadFile
(
const
string
&
filename
,
vector
<
Ptr
<
FR_adienceObj
>
>
&
out
)
{
string
line
;
ifstream
infile
(
filename
.
c_str
());
while
(
getline
(
infile
,
line
))
{
Ptr
<
FR_adienceObj
>
curr
(
new
FR_adienceObj
);
vector
<
string
>
elems
;
split
(
line
,
elems
,
','
);
curr
->
user_id
=
elems
[
0
];
curr
->
original_image
=
elems
[
1
];
curr
->
face_id
=
atoi
(
elems
[
2
].
c_str
());
curr
->
age
=
elems
[
3
];
if
(
elems
[
4
]
==
"m"
)
{
curr
->
gender
=
male
;
}
else
if
(
elems
[
4
]
==
"f"
)
{
curr
->
gender
=
female
;
}
else
{
curr
->
gender
=
none
;
}
curr
->
x
=
atoi
(
elems
[
5
].
c_str
());
curr
->
y
=
atoi
(
elems
[
6
].
c_str
());
curr
->
dx
=
atoi
(
elems
[
7
].
c_str
());
curr
->
dy
=
atoi
(
elems
[
8
].
c_str
());
curr
->
tilt_ang
=
atoi
(
elems
[
9
].
c_str
());
curr
->
fiducial_yaw_angle
=
atoi
(
elems
[
10
].
c_str
());
curr
->
fiducial_score
=
atoi
(
elems
[
11
].
c_str
());
out
.
push_back
(
curr
);
}
}
void
FR_adienceImp
::
cv5ToSplits
(
vector
<
Ptr
<
FR_adienceObj
>
>
fileList
[
5
])
{
for
(
unsigned
int
i
=
0
;
i
<
5
;
++
i
)
{
train
.
push_back
(
vector
<
Ptr
<
Object
>
>
());
test
.
push_back
(
vector
<
Ptr
<
Object
>
>
());
validation
.
push_back
(
vector
<
Ptr
<
Object
>
>
());
for
(
unsigned
int
j
=
0
;
j
<
5
;
++
j
)
{
vector
<
Ptr
<
FR_adienceObj
>
>
&
currlist
=
fileList
[
j
];
if
(
i
!=
j
)
{
for
(
vector
<
Ptr
<
FR_adienceObj
>
>::
iterator
it
=
currlist
.
begin
();
it
!=
currlist
.
end
();
++
it
)
{
train
.
back
().
push_back
(
*
it
);
}
}
else
{
for
(
vector
<
Ptr
<
FR_adienceObj
>
>::
iterator
it
=
currlist
.
begin
();
it
!=
currlist
.
end
();
++
it
)
{
test
.
back
().
push_back
(
*
it
);
}
}
}
}
}
void
FR_adienceImp
::
loadDataset
(
const
string
&
path
)
{
vector
<
Ptr
<
FR_adienceObj
>
>
fileList
[
5
];
for
(
unsigned
int
i
=
0
;
i
<
5
;
++
i
)
{
char
tmp
[
3
];
sprintf
(
tmp
,
"%u"
,
i
);
string
filename
(
path
+
"fold_"
+
string
(
tmp
)
+
"_data.txt"
);
loadFile
(
filename
,
fileList
[
i
]);
}
cv5ToSplits
(
fileList
);
for
(
unsigned
int
i
=
0
;
i
<
5
;
++
i
)
{
char
tmp
[
3
];
sprintf
(
tmp
,
"%u"
,
i
);
string
filename
(
path
+
"fold_frontal_"
+
string
(
tmp
)
+
"_data.txt"
);
fileList
[
i
].
clear
();
loadFile
(
filename
,
fileList
[
i
]);
}
cv5ToSplits
(
fileList
);
}
Ptr
<
FR_adience
>
FR_adience
::
create
()
{
return
Ptr
<
FR_adienceImp
>
(
new
FR_adienceImp
);
}
}
}
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