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
d67b4507
Commit
d67b4507
authored
Mar 26, 2014
by
Roman Donchenko
Committed by
OpenCV Buildbot
Mar 26, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2378 from ngryman:progressive_jpeg
parents
d63a8ba0
b211e1d9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
6 deletions
+40
-6
highgui.hpp
modules/highgui/include/opencv2/highgui.hpp
+7
-6
highgui_c.h
modules/highgui/include/opencv2/highgui/highgui_c.h
+1
-0
grfmt_jpeg.cpp
modules/highgui/src/grfmt_jpeg.cpp
+8
-0
test_grfmt.cpp
modules/highgui/test/test_grfmt.cpp
+24
-0
No files found.
modules/highgui/include/opencv2/highgui.hpp
View file @
d67b4507
...
...
@@ -215,12 +215,13 @@ enum { IMREAD_UNCHANGED = -1, // 8bit, color or not
IMREAD_ANYCOLOR
=
4
// ?, any color
};
enum
{
IMWRITE_JPEG_QUALITY
=
1
,
IMWRITE_PNG_COMPRESSION
=
16
,
IMWRITE_PNG_STRATEGY
=
17
,
IMWRITE_PNG_BILEVEL
=
18
,
IMWRITE_PXM_BINARY
=
32
,
IMWRITE_WEBP_QUALITY
=
64
enum
{
IMWRITE_JPEG_QUALITY
=
1
,
IMWRITE_JPEG_PROGRESSIVE
=
2
,
IMWRITE_PNG_COMPRESSION
=
16
,
IMWRITE_PNG_STRATEGY
=
17
,
IMWRITE_PNG_BILEVEL
=
18
,
IMWRITE_PXM_BINARY
=
32
,
IMWRITE_WEBP_QUALITY
=
64
};
enum
{
IMWRITE_PNG_STRATEGY_DEFAULT
=
0
,
...
...
modules/highgui/include/opencv2/highgui/highgui_c.h
View file @
d67b4507
...
...
@@ -220,6 +220,7 @@ CVAPI(CvMat*) cvLoadImageM( const char* filename, int iscolor CV_DEFAULT(CV_LOAD
enum
{
CV_IMWRITE_JPEG_QUALITY
=
1
,
CV_IMWRITE_JPEG_PROGRESSIVE
=
2
,
CV_IMWRITE_PNG_COMPRESSION
=
16
,
CV_IMWRITE_PNG_STRATEGY
=
17
,
CV_IMWRITE_PNG_BILEVEL
=
18
,
...
...
modules/highgui/src/grfmt_jpeg.cpp
View file @
d67b4507
...
...
@@ -598,6 +598,7 @@ bool JpegEncoder::write( const Mat& img, const std::vector<int>& params )
cinfo
.
in_color_space
=
channels
>
1
?
JCS_RGB
:
JCS_GRAYSCALE
;
int
quality
=
95
;
int
progressive
=
0
;
for
(
size_t
i
=
0
;
i
<
params
.
size
();
i
+=
2
)
{
...
...
@@ -606,11 +607,18 @@ bool JpegEncoder::write( const Mat& img, const std::vector<int>& params )
quality
=
params
[
i
+
1
];
quality
=
MIN
(
MAX
(
quality
,
0
),
100
);
}
if
(
params
[
i
]
==
CV_IMWRITE_JPEG_PROGRESSIVE
)
{
progressive
=
params
[
i
+
1
];
}
}
jpeg_set_defaults
(
&
cinfo
);
jpeg_set_quality
(
&
cinfo
,
quality
,
TRUE
/* limit to baseline-JPEG values */
);
if
(
progressive
)
jpeg_simple_progression
(
&
cinfo
);
jpeg_start_compress
(
&
cinfo
,
TRUE
);
if
(
channels
>
1
)
...
...
modules/highgui/test/test_grfmt.cpp
View file @
d67b4507
...
...
@@ -386,6 +386,30 @@ TEST(Highgui_Jpeg, encode_empty)
ASSERT_THROW
(
cv
::
imencode
(
".jpg"
,
img
,
jpegImg
),
cv
::
Exception
);
}
TEST
(
Highgui_Jpeg
,
encode_decode_progressive_jpeg
)
{
cvtest
::
TS
&
ts
=
*
cvtest
::
TS
::
ptr
();
string
input
=
string
(
ts
.
get_data_path
())
+
"../cv/shared/lena.png"
;
cv
::
Mat
img
=
cv
::
imread
(
input
);
ASSERT_FALSE
(
img
.
empty
());
std
::
vector
<
int
>
params
;
params
.
push_back
(
IMWRITE_JPEG_PROGRESSIVE
);
params
.
push_back
(
1
);
string
output_progressive
=
cv
::
tempfile
(
".jpg"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output_progressive
,
img
,
params
));
cv
::
Mat
img_jpg_progressive
=
cv
::
imread
(
output_progressive
);
string
output_normal
=
cv
::
tempfile
(
".jpg"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output_normal
,
img
));
cv
::
Mat
img_jpg_normal
=
cv
::
imread
(
output_normal
);
EXPECT_EQ
(
0
,
cv
::
norm
(
img_jpg_progressive
,
img_jpg_normal
,
NORM_INF
));
remove
(
output_progressive
.
c_str
());
}
#endif
...
...
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