forked from zmoratto/PatchMatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestMoc.cxx
56 lines (45 loc) · 2.11 KB
/
TestMoc.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <PatchMatch.h>
#include <vw/Math/Vector.h>
#include <vw/FileIO/DiskImageResourceGDAL.h>
#include <vw/FileIO/DiskImageView.h>
#include <vw/Stereo/DisparityMap.h>
#include <gtest/gtest.h>
using namespace vw;
namespace vw {
template<> struct PixelFormatID<Vector2f> { static const PixelFormatEnum value = VW_PIXEL_GENERIC_2_CHANNEL; };
template<> struct PixelFormatID<Vector4f> { static const PixelFormatEnum value = VW_PIXEL_GENERIC_4_CHANNEL; };
}
template <class ImageT>
void block_write_image( const std::string &filename,
vw::ImageViewBase<ImageT> const& image,
vw::ProgressCallback const& progress_callback = vw::ProgressCallback::dummy_instance() ) {
boost::scoped_ptr<vw::DiskImageResourceGDAL> rsrc
(new vw::DiskImageResourceGDAL(filename, image.impl().format(), Vector2i(256,256)));
vw::block_write_image( *rsrc, image.impl(), progress_callback );
}
TEST( Moc, Crop ) {
DiskImageView<float >
left_image("../SemiGlobalMatching/data/moc/epi-L.crop.tif"),
right_image("../SemiGlobalMatching/data/moc/epi-R.crop.tif");
DiskImageView<PixelMask<Vector2i> >
correct_disp("../SemiGlobalMatching/data/moc/crop11/crop11-D.tif");
block_write_image( "moc_crop_pmview-D.tif",
stereo::patch_match( left_image, right_image,
BBox2i(Vector2i(-20,-10),Vector2i(24,50)),
Vector2i(11,11) ),
TerminalProgressCallback("test","PatchMatch:") );
}
TEST( Moc, All ) {
DiskImageView<float >
left_image("../SemiGlobalMatching/data/moc/epi-L.tif"),
right_image("../SemiGlobalMatching/data/moc/epi-R.tif");
block_write_image( "moc_full_pmview-D.tif",
stereo::patch_match( left_image, right_image,
BBox2i(Vector2i(-40,-10),Vector2i(44,50)),
Vector2i(11,11) ),
TerminalProgressCallback("test","PatchMatch:") );
}
int main( int argc, char **argv ) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}