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
84ea0c9a
Commit
84ea0c9a
authored
Jun 24, 2013
by
Fedor Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests and rgbe fix
parent
96dfbf5d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
3 deletions
+113
-3
rgbe.cpp
modules/highgui/src/rgbe.cpp
+3
-3
test_grfmt.cpp
modules/highgui/test/test_grfmt.cpp
+25
-0
hdr_fusion.cpp
modules/photo/src/hdr_fusion.cpp
+6
-0
test_hdr.cpp
modules/photo/test/test_hdr.cpp
+79
-0
No files found.
modules/highgui/src/rgbe.cpp
View file @
84ea0c9a
...
@@ -56,8 +56,8 @@
...
@@ -56,8 +56,8 @@
// feel free to modify it to suit your needs.
// feel free to modify it to suit your needs.
// Some opencv specific changes have been added:
// Some opencv specific changes have been added:
// inline define specified,
channel order changed (to ger bgr by default)
,
// inline define specified,
error handler uses CV_Error
,
//
error handler uses CV_Error
.
//
defines changed to work in bgr color space
.
//
//
// posted to http://www.graphics.cornell.edu/~bjw/
// posted to http://www.graphics.cornell.edu/~bjw/
// written by Bruce Walter (bjw@graphics.cornell.edu) 5/26/95
// written by Bruce Walter (bjw@graphics.cornell.edu) 5/26/95
...
@@ -380,7 +380,7 @@ int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
...
@@ -380,7 +380,7 @@ int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
}
}
if
((
rgbe
[
0
]
!=
2
)
||
(
rgbe
[
1
]
!=
2
)
||
(
rgbe
[
2
]
&
0x80
))
{
if
((
rgbe
[
0
]
!=
2
)
||
(
rgbe
[
1
]
!=
2
)
||
(
rgbe
[
2
]
&
0x80
))
{
/* this file is not run length encoded */
/* this file is not run length encoded */
rgbe2float
(
&
data
[
0
],
&
data
[
1
],
&
data
[
2
],
rgbe
);
rgbe2float
(
&
data
[
RGBE_DATA_RED
],
&
data
[
RGBE_DATA_GREEN
],
&
data
[
RGBE_DATA_BLUE
],
rgbe
);
data
+=
RGBE_DATA_SIZE
;
data
+=
RGBE_DATA_SIZE
;
free
(
scanline_buffer
);
free
(
scanline_buffer
);
return
RGBE_ReadPixels
(
fp
,
data
,
scanline_width
*
num_scanlines
-
1
);
return
RGBE_ReadPixels
(
fp
,
data
,
scanline_width
*
num_scanlines
-
1
);
...
...
modules/highgui/test/test_grfmt.cpp
View file @
84ea0c9a
...
@@ -406,3 +406,28 @@ TEST(Highgui_WebP, encode_decode_lossy_webp)
...
@@ -406,3 +406,28 @@ TEST(Highgui_WebP, encode_decode_lossy_webp)
}
}
#endif
#endif
TEST
(
Highgui_hdr
,
regression
)
{
string
folder
=
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"../cv/hdr/"
;
string
name_rle
=
folder
+
"grand_canal_rle.hdr"
;
string
name_no_rle
=
folder
+
"grand_canal_no_rle.hdr"
;
Mat
img_rle
=
imread
(
name_rle
,
-
1
);
ASSERT_FALSE
(
img_rle
.
empty
())
<<
"Could not open "
<<
name_rle
;
Mat
img_no_rle
=
imread
(
name_no_rle
,
-
1
);
ASSERT_FALSE
(
img_no_rle
.
empty
())
<<
"Could not open "
<<
name_no_rle
;
double
min
=
0.0
,
max
=
1.0
;
minMaxLoc
(
abs
(
img_rle
-
img_no_rle
),
&
min
,
&
max
);
ASSERT_FALSE
(
max
>
0
);
string
tmp_file_name
=
tempfile
(
".hdr"
);
vector
<
int
>
param
(
1
);
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
param
[
0
]
=
i
;
imwrite
(
tmp_file_name
,
img_rle
,
param
);
Mat
written_img
=
imread
(
tmp_file_name
,
-
1
);
ASSERT_FALSE
(
written_img
.
empty
())
<<
"Could not open "
<<
tmp_file_name
;
minMaxLoc
(
abs
(
img_rle
-
written_img
),
&
min
,
&
max
);
ASSERT_FALSE
(
max
>
0
);
}
}
modules/photo/src/hdr_fusion.cpp
View file @
84ea0c9a
...
@@ -91,6 +91,7 @@ void makeHDR(InputArrayOfArrays _images, std::vector<float> exp_times, OutputArr
...
@@ -91,6 +91,7 @@ void makeHDR(InputArrayOfArrays _images, std::vector<float> exp_times, OutputArr
triangleWeights
(
weights
);
triangleWeights
(
weights
);
generateResponce
(
responce
);
generateResponce
(
responce
);
float
max
=
0
;
float
*
res_ptr
=
result
.
ptr
<
float
>
();
float
*
res_ptr
=
result
.
ptr
<
float
>
();
for
(
size_t
pos
=
0
;
pos
<
result
.
total
();
pos
++
,
res_ptr
+=
3
)
{
for
(
size_t
pos
=
0
;
pos
<
result
.
total
();
pos
++
,
res_ptr
+=
3
)
{
...
@@ -108,8 +109,12 @@ void makeHDR(InputArrayOfArrays _images, std::vector<float> exp_times, OutputArr
...
@@ -108,8 +109,12 @@ void makeHDR(InputArrayOfArrays _images, std::vector<float> exp_times, OutputArr
}
}
for
(
int
channel
=
0
;
channel
<
3
;
channel
++
)
{
for
(
int
channel
=
0
;
channel
<
3
;
channel
++
)
{
res_ptr
[
channel
]
=
exp
(
sum
[
channel
]
/
weight_sum
);
res_ptr
[
channel
]
=
exp
(
sum
[
channel
]
/
weight_sum
);
if
(
res_ptr
[
channel
]
>
max
)
{
max
=
res_ptr
[
channel
];
}
}
}
}
}
result
=
result
/
max
;
}
}
};
};
\ No newline at end of file
modules/photo/test/test_hdr.cpp
0 → 100644
View file @
84ea0c9a
/*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) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage 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 Intel Corporation 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 "test_precomp.hpp"
#include <string>
#include <algorithm>
using
namespace
cv
;
using
namespace
std
;
TEST
(
Photo_MakeHdr
,
regression
)
{
string
folder
=
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"hdr/"
;
vector
<
string
>
file_names
(
3
);
file_names
[
0
]
=
folder
+
"grand_canal_1_45.jpg"
;
file_names
[
1
]
=
folder
+
"grand_canal_1_180.jpg"
;
file_names
[
2
]
=
folder
+
"grand_canal_1_750.jpg"
;
vector
<
Mat
>
images
(
3
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
images
[
i
]
=
imread
(
file_names
[
i
]);
ASSERT_FALSE
(
images
[
i
].
empty
())
<<
"Could not load input image "
<<
file_names
[
i
];
}
string
expected_path
=
folder
+
"grand_canal_rle.hdr"
;
Mat
expected
=
imread
(
expected_path
,
-
1
);
ASSERT_FALSE
(
expected
.
empty
())
<<
"Could not load input image "
<<
expected_path
;
vector
<
float
>
times
(
3
);
times
[
0
]
=
1.0
f
/
45.0
f
;
times
[
1
]
=
1.0
f
/
180.0
f
;
times
[
2
]
=
1.0
f
/
750.0
f
;
Mat
result
;
makeHDR
(
images
,
times
,
result
);
double
min
=
0.0
,
max
=
1.0
;
minMaxLoc
(
abs
(
result
-
expected
),
&
min
,
&
max
);
ASSERT_TRUE
(
max
<
0.01
);
}
\ 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