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
9d8dc78d
Commit
9d8dc78d
authored
Aug 21, 2015
by
Vladimir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Untabify VOT dataset code
parent
c3e88a71
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
196 additions
and
195 deletions
+196
-195
track_vot.hpp
modules/datasets/include/opencv2/datasets/track_vot.hpp
+10
-10
track_vot.cpp
modules/datasets/src/track_vot.cpp
+186
-185
No files found.
modules/datasets/include/opencv2/datasets/track_vot.hpp
View file @
9d8dc78d
...
@@ -68,30 +68,30 @@ struct TRACK_votObj : public Object
...
@@ -68,30 +68,30 @@ struct TRACK_votObj : public Object
{
{
int
id
;
int
id
;
std
::
string
imagePath
;
std
::
string
imagePath
;
vector
<
Point2d
>
gtbb
;
vector
<
Point2d
>
gtbb
;
};
};
class
CV_EXPORTS
TRACK_vot
:
public
Dataset
class
CV_EXPORTS
TRACK_vot
:
public
Dataset
{
{
public
:
public
:
static
Ptr
<
TRACK_vot
>
create
();
static
Ptr
<
TRACK_vot
>
create
();
virtual
void
load
(
const
std
::
string
&
path
)
=
0
;
virtual
void
load
(
const
std
::
string
&
path
)
=
0
;
virtual
int
getDatasetsNum
()
=
0
;
virtual
int
getDatasetsNum
()
=
0
;
virtual
int
getDatasetLength
(
int
id
)
=
0
;
virtual
int
getDatasetLength
(
int
id
)
=
0
;
virtual
bool
initDataset
(
int
id
)
=
0
;
virtual
bool
initDataset
(
int
id
)
=
0
;
virtual
bool
getNextFrame
(
Mat
&
frame
)
=
0
;
virtual
bool
getNextFrame
(
Mat
&
frame
)
=
0
;
virtual
vector
<
Point2d
>
getGT
()
=
0
;
virtual
vector
<
Point2d
>
getGT
()
=
0
;
protected
:
protected
:
vector
<
vector
<
Ptr
<
TRACK_votObj
>
>
>
data
;
vector
<
vector
<
Ptr
<
TRACK_votObj
>
>
>
data
;
int
activeDatasetID
;
int
activeDatasetID
;
int
frameCounter
;
int
frameCounter
;
};
};
//! @}
//! @}
...
...
modules/datasets/src/track_vot.cpp
View file @
9d8dc78d
...
@@ -45,189 +45,189 @@ using namespace std;
...
@@ -45,189 +45,189 @@ using namespace std;
namespace
cv
namespace
cv
{
{
namespace
datasets
namespace
datasets
{
{
class
TRACK_votImpl
:
public
TRACK_vot
class
TRACK_votImpl
:
public
TRACK_vot
{
{
public
:
public
:
//Constructor
//Constructor
TRACK_votImpl
()
TRACK_votImpl
()
{
{
activeDatasetID
=
1
;
activeDatasetID
=
1
;
frameCounter
=
0
;
frameCounter
=
0
;
}
}
//Destructor
//Destructor
virtual
~
TRACK_votImpl
()
{}
virtual
~
TRACK_votImpl
()
{}
//Load Dataset
//Load Dataset
virtual
void
load
(
const
string
&
path
);
virtual
void
load
(
const
string
&
path
);
virtual
int
getDatasetsNum
();
virtual
int
getDatasetsNum
();
virtual
int
getDatasetLength
(
int
id
);
virtual
int
getDatasetLength
(
int
id
);
virtual
bool
initDataset
(
int
id
);
virtual
bool
initDataset
(
int
id
);
virtual
bool
getNextFrame
(
Mat
&
frame
);
virtual
bool
getNextFrame
(
Mat
&
frame
);
virtual
vector
<
Point2d
>
getGT
();
virtual
vector
<
Point2d
>
getGT
();
private
:
private
:
void
loadDataset
(
const
string
&
path
);
void
loadDataset
(
const
string
&
path
);
string
numberToString
(
int
number
);
string
numberToString
(
int
number
);
};
};
void
TRACK_votImpl
::
load
(
const
string
&
path
)
void
TRACK_votImpl
::
load
(
const
string
&
path
)
{
{
loadDataset
(
path
);
loadDataset
(
path
);
}
}
string
TRACK_votImpl
::
numberToString
(
int
number
)
string
TRACK_votImpl
::
numberToString
(
int
number
)
{
{
string
out
;
string
out
;
char
numberStr
[
9
];
char
numberStr
[
9
];
sprintf
(
numberStr
,
"%u"
,
number
);
sprintf
(
numberStr
,
"%u"
,
number
);
for
(
unsigned
int
i
=
0
;
i
<
8
-
strlen
(
numberStr
);
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
8
-
strlen
(
numberStr
);
++
i
)
{
{
out
+=
"0"
;
out
+=
"0"
;
}
}
out
+=
numberStr
;
out
+=
numberStr
;
return
out
;
return
out
;
}
}
inline
bool
fileExists
(
const
std
::
string
&
name
)
inline
bool
fileExists
(
const
std
::
string
&
name
)
{
{
struct
stat
buffer
;
struct
stat
buffer
;
return
(
stat
(
name
.
c_str
(),
&
buffer
)
==
0
);
return
(
stat
(
name
.
c_str
(),
&
buffer
)
==
0
);
}
}
void
TRACK_votImpl
::
loadDataset
(
const
string
&
rootPath
)
void
TRACK_votImpl
::
loadDataset
(
const
string
&
rootPath
)
{
{
string
nameListPath
=
rootPath
+
"/list.txt"
;
string
nameListPath
=
rootPath
+
"/list.txt"
;
ifstream
namesList
(
nameListPath
.
c_str
());
ifstream
namesList
(
nameListPath
.
c_str
());
vector
<
int
>
datasetsLengths
;
vector
<
int
>
datasetsLengths
;
string
datasetName
;
string
datasetName
;
if
(
namesList
.
is_open
())
if
(
namesList
.
is_open
())
{
{
int
currDatasetID
=
0
;
int
currDatasetID
=
0
;
//All datasets/folders loop
//All datasets/folders loop
while
(
getline
(
namesList
,
datasetName
))
while
(
getline
(
namesList
,
datasetName
))
{
{
currDatasetID
++
;
currDatasetID
++
;
vector
<
Ptr
<
TRACK_votObj
>
>
objects
;
vector
<
Ptr
<
TRACK_votObj
>
>
objects
;
//All frames/images loop
//All frames/images loop
Ptr
<
TRACK_votObj
>
currDataset
(
new
TRACK_votObj
);
Ptr
<
TRACK_votObj
>
currDataset
(
new
TRACK_votObj
);
//Open dataset's ground truth file
//Open dataset's ground truth file
string
gtListPath
=
rootPath
+
"/"
+
datasetName
+
"/groundtruth.txt"
;
string
gtListPath
=
rootPath
+
"/"
+
datasetName
+
"/groundtruth.txt"
;
ifstream
gtList
(
gtListPath
.
c_str
());
ifstream
gtList
(
gtListPath
.
c_str
());
if
(
!
gtList
.
is_open
())
if
(
!
gtList
.
is_open
())
cout
<<
"Error to open groundtruth.txt!!!"
;
cout
<<
"Error to open groundtruth.txt!!!"
;
//Make a list of datasets lengths
//Make a list of datasets lengths
int
currFrameID
=
1
;
int
currFrameID
=
1
;
if
(
currDatasetID
==
0
)
if
(
currDatasetID
==
0
)
cout
<<
"VOT 2015 Dataset Initialization...
\n
"
;
cout
<<
"VOT 2015 Dataset Initialization...
\n
"
;
bool
trFLG
=
true
;
bool
trFLG
=
true
;
do
do
{
{
currFrameID
++
;
currFrameID
++
;
string
fullPath
=
rootPath
+
"/"
+
datasetName
+
"/"
+
numberToString
(
currFrameID
)
+
".jpg"
;
string
fullPath
=
rootPath
+
"/"
+
datasetName
+
"/"
+
numberToString
(
currFrameID
)
+
".jpg"
;
if
(
!
fileExists
(
fullPath
))
if
(
!
fileExists
(
fullPath
))
break
;
break
;
//Make VOT Object
//Make VOT Object
Ptr
<
TRACK_votObj
>
currObj
(
new
TRACK_votObj
);
Ptr
<
TRACK_votObj
>
currObj
(
new
TRACK_votObj
);
currObj
->
imagePath
=
fullPath
;
currObj
->
imagePath
=
fullPath
;
currObj
->
id
=
currFrameID
;
currObj
->
id
=
currFrameID
;
//Get Ground Truth data
//Get Ground Truth data
double
x1
=
0
,
y1
=
0
,
double
x1
=
0
,
y1
=
0
,
x2
=
0
,
y2
=
0
,
x2
=
0
,
y2
=
0
,
x3
=
0
,
y3
=
0
,
x3
=
0
,
y3
=
0
,
x4
=
0
,
y4
=
0
;
x4
=
0
,
y4
=
0
;
string
tmp
;
string
tmp
;
getline
(
gtList
,
tmp
);
getline
(
gtList
,
tmp
);
sscanf
(
tmp
.
c_str
(),
"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf"
,
&
x1
,
&
y1
,
&
x2
,
&
y2
,
&
x3
,
&
y3
,
&
x4
,
&
y4
);
sscanf
(
tmp
.
c_str
(),
"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf"
,
&
x1
,
&
y1
,
&
x2
,
&
y2
,
&
x3
,
&
y3
,
&
x4
,
&
y4
);
currObj
->
gtbb
.
push_back
(
Point2d
(
x1
,
y1
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x1
,
y1
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x2
,
y2
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x2
,
y2
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x3
,
y3
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x3
,
y3
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x4
,
y4
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x4
,
y4
));
//Add object to storage
//Add object to storage
objects
.
push_back
(
currObj
);
objects
.
push_back
(
currObj
);
}
while
(
trFLG
);
}
while
(
trFLG
);
datasetsLengths
.
push_back
(
currFrameID
-
1
);
datasetsLengths
.
push_back
(
currFrameID
-
1
);
data
.
push_back
(
objects
);
data
.
push_back
(
objects
);
}
}
}
}
else
else
{
{
cout
<<
rootPath
+
"Couldn't find a *list.txt* in VOT 2015 folder!!!"
;
cout
<<
rootPath
+
"Couldn't find a *list.txt* in VOT 2015 folder!!!"
;
}
}
namesList
.
close
();
namesList
.
close
();
return
;
return
;
}
}
int
TRACK_votImpl
::
getDatasetsNum
()
int
TRACK_votImpl
::
getDatasetsNum
()
{
{
return
data
.
size
();
return
data
.
size
();
}
}
int
TRACK_votImpl
::
getDatasetLength
(
int
id
)
int
TRACK_votImpl
::
getDatasetLength
(
int
id
)
{
{
if
(
id
>
0
&&
id
<=
(
int
)
data
.
size
())
if
(
id
>
0
&&
id
<=
(
int
)
data
.
size
())
return
data
[
id
-
1
].
size
();
return
data
[
id
-
1
].
size
();
else
else
{
{
cout
<<
"Dataset ID is out of range...
\n
"
<<
"Allowed IDs are: 1~"
<<
(
int
)
data
.
size
()
<<
endl
;
cout
<<
"Dataset ID is out of range...
\n
"
<<
"Allowed IDs are: 1~"
<<
(
int
)
data
.
size
()
<<
endl
;
return
-
1
;
return
-
1
;
}
}
}
}
bool
TRACK_votImpl
::
initDataset
(
int
id
)
bool
TRACK_votImpl
::
initDataset
(
int
id
)
{
{
if
(
id
>
0
&&
id
<=
(
int
)
data
.
size
())
if
(
id
>
0
&&
id
<=
(
int
)
data
.
size
())
{
{
activeDatasetID
=
id
;
activeDatasetID
=
id
;
return
true
;
return
true
;
}
}
else
else
{
{
cout
<<
"Dataset ID is out of range...
\n
"
<<
"Allowed IDs are: 1~"
<<
(
int
)
data
.
size
()
<<
endl
;
cout
<<
"Dataset ID is out of range...
\n
"
<<
"Allowed IDs are: 1~"
<<
(
int
)
data
.
size
()
<<
endl
;
return
false
;
return
false
;
}
}
}
}
bool
TRACK_votImpl
::
getNextFrame
(
Mat
&
frame
)
bool
TRACK_votImpl
::
getNextFrame
(
Mat
&
frame
)
{
{
if
(
frameCounter
>=
(
int
)
data
[
activeDatasetID
-
1
].
size
())
if
(
frameCounter
>=
(
int
)
data
[
activeDatasetID
-
1
].
size
())
return
false
;
return
false
;
string
imgPath
=
data
[
activeDatasetID
-
1
][
frameCounter
]
->
imagePath
;
string
imgPath
=
data
[
activeDatasetID
-
1
][
frameCounter
]
->
imagePath
;
frame
=
imread
(
imgPath
);
frame
=
imread
(
imgPath
);
frameCounter
++
;
frameCounter
++
;
return
!
frame
.
empty
();
return
!
frame
.
empty
();
}
}
Ptr
<
TRACK_vot
>
TRACK_vot
::
create
()
Ptr
<
TRACK_vot
>
TRACK_vot
::
create
()
{
{
return
Ptr
<
TRACK_votImpl
>
(
new
TRACK_votImpl
);
return
Ptr
<
TRACK_votImpl
>
(
new
TRACK_votImpl
);
}
}
vector
<
Point2d
>
TRACK_votImpl
::
getGT
()
vector
<
Point2d
>
TRACK_votImpl
::
getGT
()
{
{
Ptr
<
TRACK_votObj
>
currObj
=
data
[
activeDatasetID
-
1
][
frameCounter
-
1
];
Ptr
<
TRACK_votObj
>
currObj
=
data
[
activeDatasetID
-
1
][
frameCounter
-
1
];
return
currObj
->
gtbb
;
return
currObj
->
gtbb
;
}
}
}
}
}
}
\ No newline at end of file
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