|
1 |
| -/*M/////////////////////////////////////////////////////////////////////////////////////// |
2 |
| -// |
3 |
| -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
4 |
| -// |
5 |
| -// By downloading, copying, installing or using the software you agree to this license. |
6 |
| -// If you do not agree to this license, do not download, install, |
7 |
| -// copy or use the software. |
8 |
| -// |
9 |
| -// |
10 |
| -// License Agreement |
11 |
| -// For Open Source Computer Vision Library |
12 |
| -// |
13 |
| -// Copyright (C) 2008, Willow Garage Inc., all rights reserved. |
14 |
| -// Third party copyrights are property of their respective owners. |
15 |
| -// |
16 |
| -// Redistribution and use in source and binary forms, with or without modification, |
17 |
| -// are permitted provided that the following conditions are met: |
18 |
| -// |
19 |
| -// * Redistribution's of source code must retain the above copyright notice, |
20 |
| -// this list of conditions and the following disclaimer. |
21 |
| -// |
22 |
| -// * Redistribution's in binary form must reproduce the above copyright notice, |
23 |
| -// this list of conditions and the following disclaimer in the documentation |
24 |
| -// and/or other materials provided with the distribution. |
25 |
| -// |
26 |
| -// * The name of Intel Corporation may not be used to endorse or promote products |
27 |
| -// derived from this software without specific prior written permission. |
28 |
| -// |
29 |
| -// This software is provided by the copyright holders and contributors "as is" and |
30 |
| -// any express or implied warranties, including, but not limited to, the implied |
31 |
| -// warranties of merchantability and fitness for a particular purpose are disclaimed. |
32 |
| -// In no event shall the Intel Corporation or contributors be liable for any direct, |
33 |
| -// indirect, incidental, special, exemplary, or consequential damages |
34 |
| -// (including, but not limited to, procurement of substitute goods or services; |
35 |
| -// loss of use, data, or profits; or business interruption) however caused |
36 |
| -// and on any theory of liability, whether in contract, strict liability, |
37 |
| -// or tort (including negligence or otherwise) arising in any way out of |
38 |
| -// the use of this software, even if advised of the possibility of such damage. |
39 |
| -// |
40 |
| -//M*/ |
41 | 1 | #include <opencv2/imgproc.hpp>
|
42 | 2 | #include <opencv2/highgui.hpp>
|
43 | 3 | #include <opencv2/ximgproc.hpp>
|
44 | 4 |
|
| 5 | +#include <iostream> |
| 6 | + |
| 7 | +static void help() |
| 8 | +{ |
| 9 | + std::cout << "\nThis program demonstrates Pei&Lin Normalization\n" |
| 10 | + "Usage:\n" |
| 11 | + "./peilin [image1_name -- default is ../data/peilin_plane.png] [image2_name -- default is ../data/peilin_shape.png]\n" << std::endl; |
| 12 | +} |
| 13 | + |
45 | 14 | static inline cv::Mat operator& ( const cv::Mat& lhs, const cv::Matx23d& rhs )
|
46 | 15 | {
|
47 |
| - cv::Mat ret; |
48 |
| - cv::warpAffine ( lhs, ret, rhs, lhs.size(), cv::INTER_LINEAR ); |
49 |
| - return ret; |
| 16 | + cv::Mat ret; |
| 17 | + cv::warpAffine ( lhs, ret, rhs, lhs.size(), cv::INTER_LINEAR ); |
| 18 | + return ret; |
50 | 19 | }
|
51 | 20 |
|
52 | 21 | static inline cv::Mat operator& ( const cv::Matx23d& lhs, const cv::Mat& rhs )
|
53 | 22 | {
|
54 |
| - cv::Mat ret; |
55 |
| - cv::warpAffine ( rhs, ret, lhs, rhs.size(), cv::INTER_LINEAR | cv::WARP_INVERSE_MAP ); |
56 |
| - return ret; |
| 23 | + cv::Mat ret; |
| 24 | + cv::warpAffine ( rhs, ret, lhs, rhs.size(), cv::INTER_LINEAR | cv::WARP_INVERSE_MAP ); |
| 25 | + return ret; |
57 | 26 | }
|
58 | 27 |
|
59 |
| -int main() |
| 28 | +int main(int argc, char** argv) |
60 | 29 | {
|
61 |
| - cv::Mat I = cv::imread ( "../data/peilin_plane.png", 0 ); |
62 |
| - cv::Mat N = I & cv::PeiLinNormalization ( I ); |
63 |
| - cv::Mat J = cv::imread ( "../data/peilin_shape.png", 0 ); |
64 |
| - cv::Mat D = cv::PeiLinNormalization ( J ) & I; |
65 |
| - cv::imshow ( "I", I ); |
66 |
| - cv::imshow ( "N", N ); |
67 |
| - cv::imshow ( "J", J ); |
68 |
| - cv::imshow ( "D", D ); |
69 |
| - cv::waitKey(); |
70 |
| - return 0; |
| 30 | + cv::CommandLineParser parser(argc, argv, "{help h | | }{ @input1 | ../data/peilin_plane.png | }{ @input2 | ../data/peilin_plane.png | }"); |
| 31 | + if (parser.has("help")) |
| 32 | + { |
| 33 | + help(); |
| 34 | + return 0; |
| 35 | + } |
| 36 | + std::string filename1 = parser.get<std::string>("@input1"); |
| 37 | + std::string filename2 = parser.get<std::string>("@input2"); |
| 38 | + |
| 39 | + cv::Mat I = cv::imread(filename1, 0); |
| 40 | + if (I.empty()) |
| 41 | + { |
| 42 | + std::cout << "Couldn't open image " << filename1 << std::endl; |
| 43 | + return 0; |
| 44 | + } |
| 45 | + cv::Mat J = cv::imread(filename2, 0); |
| 46 | + if (J.empty()) |
| 47 | + { |
| 48 | + std::cout << "Couldn't open image " << filename2 << std::endl; |
| 49 | + return 0; |
| 50 | + } |
| 51 | + cv::Mat N = I & cv::PeiLinNormalization ( I ); |
| 52 | + cv::Mat D = cv::PeiLinNormalization ( J ) & I; |
| 53 | + cv::imshow ( "I", I ); |
| 54 | + cv::imshow ( "N", N ); |
| 55 | + cv::imshow ( "J", J ); |
| 56 | + cv::imshow ( "D", D ); |
| 57 | + cv::waitKey(); |
| 58 | + return 0; |
71 | 59 | }
|
0 commit comments