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
d1229efe
Commit
d1229efe
authored
Sep 01, 2014
by
Grigory Serebryakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No output image resize in case of PNG dataset
parent
74d8527f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
37 deletions
+6
-37
cvsamplesoutput.cpp
apps/haartraining/cvsamplesoutput.cpp
+5
-33
cvsamplesoutput.h
apps/haartraining/cvsamplesoutput.h
+1
-4
No files found.
apps/haartraining/cvsamplesoutput.cpp
View file @
d1229efe
...
...
@@ -113,9 +113,9 @@ bool PngDatasetOutput::init( const char* annotationsListFileName )
}
bool
PngDatasetOutput
::
write
(
const
CvMat
&
img
,
const
CvRect
&
boundingBox
)
const
CvRect
&
boundingBox
)
{
CvRect
bbox
=
scaleBoundingBox
(
cvGetSize
(
&
img
),
boundingBox
);
CvRect
bbox
=
addBoundingboxBorder
(
boundingBox
);
sprintf
(
imgFileName
,
"%04d_%04d_%04d_%04d_%04d"
,
...
...
@@ -148,44 +148,16 @@ bool PngDatasetOutput::write( const CvMat& img,
bbox
.
y
+
bbox
.
height
);
fclose
(
annotationFile
);
writeImage
(
img
);
cvSaveImage
(
imgFullPath
,
&
img
);
return
true
;
}
void
PngDatasetOutput
::
writeImage
(
const
CvMat
&
img
)
const
{
CvSize
origsize
=
cvGetSize
(
&
img
);
if
(
origsize
.
height
>
destImgHeight
||
origsize
.
width
>
destImgWidth
)
{
CvMat
result
=
cvMat
(
destImgHeight
,
destImgWidth
,
CV_8UC1
,
cvAlloc
(
sizeof
(
uchar
)
*
destImgHeight
*
destImgWidth
)
);
cvResize
(
&
img
,
&
result
);
cvSaveImage
(
imgFullPath
,
&
result
);
cvFree
(
&
(
result
.
data
.
ptr
)
);
}
else
{
cvSaveImage
(
imgFullPath
,
&
img
);
}
return
;
}
CvRect
PngDatasetOutput
::
scaleBoundingBox
(
const
CvSize
&
imgSize
,
const
CvRect
&
bbox
)
CvRect
PngDatasetOutput
::
addBoundingboxBorder
(
const
CvRect
&
bbox
)
const
{
double
scale
=
MAX
(
(
float
)
destImgWidth
/
imgSize
.
width
,
(
float
)
destImgHeight
/
imgSize
.
height
);
CvRect
boundingBox
=
bbox
;
int
border
=
5
;
if
(
scale
<
1.
)
{
boundingBox
.
x
=
bbox
.
x
*
scale
;
boundingBox
.
y
=
bbox
.
y
*
scale
;
boundingBox
.
width
=
bbox
.
width
*
scale
;
boundingBox
.
height
=
bbox
.
height
*
scale
;
}
boundingBox
.
x
-=
border
;
boundingBox
.
y
-=
border
;
boundingBox
.
width
+=
2
*
border
;
...
...
apps/haartraining/cvsamplesoutput.h
View file @
d1229efe
...
...
@@ -20,10 +20,7 @@ private:
virtual
bool
init
(
const
char
*
annotationsListFileName
);
void
writeImage
(
const
CvMat
&
img
)
const
;
CvRect
scaleBoundingBox
(
const
CvSize
&
imgSize
,
const
CvRect
&
bbox
);
CvRect
addBoundingboxBorder
(
const
CvRect
&
bbox
)
const
;
private
:
char
annotationFullPath
[
PATH_MAX
];
...
...
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