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
0f6b8002
Commit
0f6b8002
authored
May 10, 2011
by
Maria Dimashova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed save/load of dot; added data for the sample
parent
1c9f4e7c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
44 additions
and
18 deletions
+44
-18
objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+0
-1
dotdetector.cpp
modules/objdetect/src/dotdetector.cpp
+27
-14
dot.cpp
samples/cpp/dot.cpp
+6
-3
image_00002.png
samples/cpp/dot_data/test/image_00002.png
+0
-0
images.txt
samples/cpp/dot_data/test/images.txt
+2
-0
image_00000.png
samples/cpp/dot_data/train/black_coffee_cup/image_00000.png
+0
-0
image_00000.png.mask.png
.../dot_data/train/black_coffee_cup/image_00000.png.mask.png
+0
-0
images.txt
samples/cpp/dot_data/train/black_coffee_cup/images.txt
+2
-0
objects.txt
samples/cpp/dot_data/train/objects.txt
+7
-0
No files found.
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
View file @
0f6b8002
...
...
@@ -684,7 +684,6 @@ protected:
vector
<
vector
<
int
>
>&
dotTemplateIndices
)
const
;
TrainParams
trainParams
;
//bool isAddImageAndGradientMask;
std
::
vector
<
std
::
string
>
objectClassNames
;
std
::
vector
<
DOTTemplate
>
dotTemplates
;
...
...
modules/objdetect/src/dotdetector.cpp
View file @
0f6b8002
...
...
@@ -424,8 +424,8 @@ void DOTDetector::TrainParams::isConsistent() const
void
DOTDetector
::
TrainParams
::
read
(
FileNode
&
fn
)
{
winSize
.
width
=
fn
[
"winSize
.
width"
];
winSize
.
height
=
fn
[
"winSize
.
height"
];
winSize
.
width
=
fn
[
"winSize
_
width"
];
winSize
.
height
=
fn
[
"winSize
_
height"
];
regionSize
=
fn
[
"regionSize"
];
minMagnitude
=
fn
[
"minMagnitude"
];
...
...
@@ -441,8 +441,8 @@ void DOTDetector::TrainParams::write( FileStorage& fs ) const
{
CV_Assert
(
fs
.
isOpened
()
);
fs
<<
"winSize
.
width"
<<
winSize
.
width
;
fs
<<
"winSize
.
height"
<<
winSize
.
height
;
fs
<<
"winSize
_
width"
<<
winSize
.
width
;
fs
<<
"winSize
_
height"
<<
winSize
.
height
;
fs
<<
"regionSize"
<<
regionSize
;
fs
<<
"minMagnitude"
<<
minMagnitude
;
...
...
@@ -557,14 +557,22 @@ float DOTDetector::DOTTemplate::computeTexturelessRatio( const cv::Mat& quantize
void
DOTDetector
::
DOTTemplate
::
read
(
FileNode
&
fn
)
{
fn
[
"template"
]
>>
quantizedImage
;
fn
[
"objectClassIDs"
]
>>
objectClassIDs
;
for
(
FileNodeIterator
fni
=
fn
[
"objectClassIDs"
].
begin
();
fni
!=
fn
[
"objectClassIDs"
].
end
();
fni
++
)
{
objectClassIDs
.
push_back
(
*
fni
);
}
texturelessRatio
=
fn
[
"texturelessRatio"
];
}
void
DOTDetector
::
DOTTemplate
::
write
(
FileStorage
&
fs
)
const
{
fs
<<
"template"
<<
quantizedImage
;
fs
<<
"objectClassIDs"
<<
objectClassIDs
;
fs
<<
"objectClassIDs"
<<
"["
;
for
(
size_t
i
=
0
;
i
<
objectClassIDs
.
size
();
i
++
)
{
fs
<<
objectClassIDs
[
i
];
}
fs
<<
"]"
;
fs
<<
"texturelessRatio"
<<
texturelessRatio
;
}
...
...
@@ -601,8 +609,8 @@ void DOTDetector::read( FileNode& fn )
trainParams
.
read
(
fn_params
);
// read class names
int
classCount
=
fn
[
"class_count"
];
FileNodeIterator
fni
=
fn
[
"class_names"
].
begin
();
int
classCount
=
fn
[
"
object_
class_count"
];
FileNodeIterator
fni
=
fn
[
"
object_
class_names"
].
begin
();
for
(
int
i
=
0
;
i
<
classCount
;
i
++
)
{
string
name
;
...
...
@@ -612,11 +620,12 @@ void DOTDetector::read( FileNode& fn )
// read DOT templates
int
templatesCount
=
fn
[
"templates_count"
];
fni
=
fn
[
"templates"
].
begin
();
for
(
int
i
=
0
;
i
<
templatesCount
;
i
++
)
{
stringstream
ss
;
ss
<<
"template_"
<<
i
;
dotTemplates
.
push_back
(
DOTTemplate
()
);
FileNode
cur_fn
=
*
fni
;
FileNode
cur_fn
=
fn
[
"templates"
][
ss
.
str
()]
;
dotTemplates
.
rbegin
()
->
read
(
cur_fn
);
}
}
...
...
@@ -629,8 +638,8 @@ void DOTDetector::write( FileStorage& fs ) const
fs
<<
"}"
;
//params
// write class names
fs
<<
"class_count"
<<
(
int
)
objectClassNames
.
size
();
fs
<<
"class_names"
<<
"["
;
fs
<<
"
object_
class_count"
<<
(
int
)
objectClassNames
.
size
();
fs
<<
"
object_
class_names"
<<
"["
;
for
(
size_t
i
=
0
;
i
<
objectClassNames
.
size
();
i
++
)
{
fs
<<
objectClassNames
[
i
];
...
...
@@ -639,12 +648,16 @@ void DOTDetector::write( FileStorage& fs ) const
// write dot templates
fs
<<
"templates_count"
<<
(
int
)
dotTemplates
.
size
();
fs
<<
"templates"
<<
"
[
"
;
fs
<<
"templates"
<<
"
{
"
;
for
(
size_t
i
=
0
;
i
<
dotTemplates
.
size
();
i
++
)
{
stringstream
ss
;
ss
<<
"template_"
<<
i
;
fs
<<
ss
.
str
()
<<
"{"
;
dotTemplates
[
i
].
write
(
fs
);
fs
<<
"}"
;
}
fs
<<
"
]
"
;
fs
<<
"
}
"
;
}
void
DOTDetector
::
load
(
const
std
::
string
&
filename
)
...
...
samples/cpp/dot.cpp
View file @
0f6b8002
...
...
@@ -41,15 +41,15 @@ int main( int argc, char **argv )
{
if
(
argc
!=
1
&&
argc
!=
3
)
{
cout
<<
"Format:
base
; "
<<
endl
<<
"or without arguments to use default data"
<<
endl
;
cout
<<
"Format:
train_data test_data
; "
<<
endl
<<
"or without arguments to use default data"
<<
endl
;
return
-
1
;
}
string
baseDirName
,
testDirName
;
if
(
argc
==
1
)
{
baseDirName
=
"../
MultiScaleDOT/D
ata/train/"
;
testDirName
=
"../
MultiScaleDOT/D
ata/test/"
;
baseDirName
=
"../
../opencv/samples/cpp/dot_d
ata/train/"
;
testDirName
=
"../
../opencv/samples/cpp/dot_d
ata/test/"
;
}
else
{
...
...
@@ -71,6 +71,9 @@ int main( int argc, char **argv )
DOTDetector
dotDetector
;
dotDetector
.
train
(
baseDirName
,
trainParams
,
true
);
// dotDetector.save( "../../dot.xml.gz" );
// dotDetector.load( "../../dot.xml.gz" );
const
vector
<
string
>&
objectClassNames
=
dotDetector
.
getObjectClassNames
();
const
vector
<
DOTDetector
::
DOTTemplate
>&
dotTemplates
=
dotDetector
.
getDOTTemplates
();
...
...
samples/cpp/dot_data/test/image_00002.png
0 → 100644
View file @
0f6b8002
490 KB
samples/cpp/dot_data/test/images.txt
0 → 100644
View file @
0f6b8002
image_00002.png
samples/cpp/dot_data/train/black_coffee_cup/image_00000.png
0 → 100644
View file @
0f6b8002
489 KB
samples/cpp/dot_data/train/black_coffee_cup/image_00000.png.mask.png
0 → 100644
View file @
0f6b8002
114 KB
samples/cpp/dot_data/train/black_coffee_cup/images.txt
0 → 100644
View file @
0f6b8002
image_00000.png
samples/cpp/dot_data/train/objects.txt
0 → 100644
View file @
0f6b8002
black_coffee_cup
#blue_bowl
#blue_cup
#nvidia_cup
#rose_cup
#white_bowl
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