opencv on mbed

Dependencies:   mbed

Committer:
joeverbout
Date:
Thu Mar 31 21:16:38 2016 +0000
Revision:
0:ea44dc9ed014
OpenCV on mbed attempt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joeverbout 0:ea44dc9ed014 1 /*M///////////////////////////////////////////////////////////////////////////////////////
joeverbout 0:ea44dc9ed014 2 //
joeverbout 0:ea44dc9ed014 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
joeverbout 0:ea44dc9ed014 4 //
joeverbout 0:ea44dc9ed014 5 // By downloading, copying, installing or using the software you agree to this license.
joeverbout 0:ea44dc9ed014 6 // If you do not agree to this license, do not download, install,
joeverbout 0:ea44dc9ed014 7 // copy or use the software.
joeverbout 0:ea44dc9ed014 8 //
joeverbout 0:ea44dc9ed014 9 //
joeverbout 0:ea44dc9ed014 10 // License Agreement
joeverbout 0:ea44dc9ed014 11 // For Open Source Computer Vision Library
joeverbout 0:ea44dc9ed014 12 //
joeverbout 0:ea44dc9ed014 13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
joeverbout 0:ea44dc9ed014 14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
joeverbout 0:ea44dc9ed014 15 // Third party copyrights are property of their respective owners.
joeverbout 0:ea44dc9ed014 16 //
joeverbout 0:ea44dc9ed014 17 // Redistribution and use in source and binary forms, with or without modification,
joeverbout 0:ea44dc9ed014 18 // are permitted provided that the following conditions are met:
joeverbout 0:ea44dc9ed014 19 //
joeverbout 0:ea44dc9ed014 20 // * Redistribution's of source code must retain the above copyright notice,
joeverbout 0:ea44dc9ed014 21 // this list of conditions and the following disclaimer.
joeverbout 0:ea44dc9ed014 22 //
joeverbout 0:ea44dc9ed014 23 // * Redistribution's in binary form must reproduce the above copyright notice,
joeverbout 0:ea44dc9ed014 24 // this list of conditions and the following disclaimer in the documentation
joeverbout 0:ea44dc9ed014 25 // and/or other materials provided with the distribution.
joeverbout 0:ea44dc9ed014 26 //
joeverbout 0:ea44dc9ed014 27 // * The name of the copyright holders may not be used to endorse or promote products
joeverbout 0:ea44dc9ed014 28 // derived from this software without specific prior written permission.
joeverbout 0:ea44dc9ed014 29 //
joeverbout 0:ea44dc9ed014 30 // This software is provided by the copyright holders and contributors "as is" and
joeverbout 0:ea44dc9ed014 31 // any express or implied warranties, including, but not limited to, the implied
joeverbout 0:ea44dc9ed014 32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
joeverbout 0:ea44dc9ed014 33 // In no event shall the Intel Corporation or contributors be liable for any direct,
joeverbout 0:ea44dc9ed014 34 // indirect, incidental, special, exemplary, or consequential damages
joeverbout 0:ea44dc9ed014 35 // (including, but not limited to, procurement of substitute goods or services;
joeverbout 0:ea44dc9ed014 36 // loss of use, data, or profits; or business interruption) however caused
joeverbout 0:ea44dc9ed014 37 // and on any theory of liability, whether in contract, strict liability,
joeverbout 0:ea44dc9ed014 38 // or tort (including negligence or otherwise) arising in any way out of
joeverbout 0:ea44dc9ed014 39 // the use of this software, even if advised of the possibility of such damage.
joeverbout 0:ea44dc9ed014 40 //
joeverbout 0:ea44dc9ed014 41 //M*/
joeverbout 0:ea44dc9ed014 42
joeverbout 0:ea44dc9ed014 43 #ifndef __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
joeverbout 0:ea44dc9ed014 44 #define __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
joeverbout 0:ea44dc9ed014 45
joeverbout 0:ea44dc9ed014 46 #include "opencv2/core.hpp"
joeverbout 0:ea44dc9ed014 47
joeverbout 0:ea44dc9ed014 48 namespace cv {
joeverbout 0:ea44dc9ed014 49 namespace detail {
joeverbout 0:ea44dc9ed014 50
joeverbout 0:ea44dc9ed014 51 //! @addtogroup stitching_exposure
joeverbout 0:ea44dc9ed014 52 //! @{
joeverbout 0:ea44dc9ed014 53
joeverbout 0:ea44dc9ed014 54 /** @brief Base class for all exposure compensators.
joeverbout 0:ea44dc9ed014 55 */
joeverbout 0:ea44dc9ed014 56 class CV_EXPORTS ExposureCompensator
joeverbout 0:ea44dc9ed014 57 {
joeverbout 0:ea44dc9ed014 58 public:
joeverbout 0:ea44dc9ed014 59 virtual ~ExposureCompensator() {}
joeverbout 0:ea44dc9ed014 60
joeverbout 0:ea44dc9ed014 61 enum { NO, GAIN, GAIN_BLOCKS };
joeverbout 0:ea44dc9ed014 62 static Ptr<ExposureCompensator> createDefault(int type);
joeverbout 0:ea44dc9ed014 63
joeverbout 0:ea44dc9ed014 64 /**
joeverbout 0:ea44dc9ed014 65 @param corners Source image top-left corners
joeverbout 0:ea44dc9ed014 66 @param images Source images
joeverbout 0:ea44dc9ed014 67 @param masks Image masks to update (second value in pair specifies the value which should be used
joeverbout 0:ea44dc9ed014 68 to detect where image is)
joeverbout 0:ea44dc9ed014 69 */
joeverbout 0:ea44dc9ed014 70 void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
joeverbout 0:ea44dc9ed014 71 const std::vector<UMat> &masks);
joeverbout 0:ea44dc9ed014 72 /** @overload */
joeverbout 0:ea44dc9ed014 73 virtual void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
joeverbout 0:ea44dc9ed014 74 const std::vector<std::pair<UMat,uchar> > &masks) = 0;
joeverbout 0:ea44dc9ed014 75 /** @brief Compensate exposure in the specified image.
joeverbout 0:ea44dc9ed014 76
joeverbout 0:ea44dc9ed014 77 @param index Image index
joeverbout 0:ea44dc9ed014 78 @param corner Image top-left corner
joeverbout 0:ea44dc9ed014 79 @param image Image to process
joeverbout 0:ea44dc9ed014 80 @param mask Image mask
joeverbout 0:ea44dc9ed014 81 */
joeverbout 0:ea44dc9ed014 82 virtual void apply(int index, Point corner, InputOutputArray image, InputArray mask) = 0;
joeverbout 0:ea44dc9ed014 83 };
joeverbout 0:ea44dc9ed014 84
joeverbout 0:ea44dc9ed014 85 /** @brief Stub exposure compensator which does nothing.
joeverbout 0:ea44dc9ed014 86 */
joeverbout 0:ea44dc9ed014 87 class CV_EXPORTS NoExposureCompensator : public ExposureCompensator
joeverbout 0:ea44dc9ed014 88 {
joeverbout 0:ea44dc9ed014 89 public:
joeverbout 0:ea44dc9ed014 90 void feed(const std::vector<Point> &/*corners*/, const std::vector<UMat> &/*images*/,
joeverbout 0:ea44dc9ed014 91 const std::vector<std::pair<UMat,uchar> > &/*masks*/) { }
joeverbout 0:ea44dc9ed014 92 void apply(int /*index*/, Point /*corner*/, InputOutputArray /*image*/, InputArray /*mask*/) { }
joeverbout 0:ea44dc9ed014 93 };
joeverbout 0:ea44dc9ed014 94
joeverbout 0:ea44dc9ed014 95 /** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image
joeverbout 0:ea44dc9ed014 96 intensities, see @cite BL07 and @cite WJ10 for details.
joeverbout 0:ea44dc9ed014 97 */
joeverbout 0:ea44dc9ed014 98 class CV_EXPORTS GainCompensator : public ExposureCompensator
joeverbout 0:ea44dc9ed014 99 {
joeverbout 0:ea44dc9ed014 100 public:
joeverbout 0:ea44dc9ed014 101 void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
joeverbout 0:ea44dc9ed014 102 const std::vector<std::pair<UMat,uchar> > &masks);
joeverbout 0:ea44dc9ed014 103 void apply(int index, Point corner, InputOutputArray image, InputArray mask);
joeverbout 0:ea44dc9ed014 104 std::vector<double> gains() const;
joeverbout 0:ea44dc9ed014 105
joeverbout 0:ea44dc9ed014 106 private:
joeverbout 0:ea44dc9ed014 107 Mat_<double> gains_;
joeverbout 0:ea44dc9ed014 108 };
joeverbout 0:ea44dc9ed014 109
joeverbout 0:ea44dc9ed014 110 /** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image block
joeverbout 0:ea44dc9ed014 111 intensities, see @cite UES01 for details.
joeverbout 0:ea44dc9ed014 112 */
joeverbout 0:ea44dc9ed014 113 class CV_EXPORTS BlocksGainCompensator : public ExposureCompensator
joeverbout 0:ea44dc9ed014 114 {
joeverbout 0:ea44dc9ed014 115 public:
joeverbout 0:ea44dc9ed014 116 BlocksGainCompensator(int bl_width = 32, int bl_height = 32)
joeverbout 0:ea44dc9ed014 117 : bl_width_(bl_width), bl_height_(bl_height) {}
joeverbout 0:ea44dc9ed014 118 void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
joeverbout 0:ea44dc9ed014 119 const std::vector<std::pair<UMat,uchar> > &masks);
joeverbout 0:ea44dc9ed014 120 void apply(int index, Point corner, InputOutputArray image, InputArray mask);
joeverbout 0:ea44dc9ed014 121
joeverbout 0:ea44dc9ed014 122 private:
joeverbout 0:ea44dc9ed014 123 int bl_width_, bl_height_;
joeverbout 0:ea44dc9ed014 124 std::vector<UMat> gain_maps_;
joeverbout 0:ea44dc9ed014 125 };
joeverbout 0:ea44dc9ed014 126
joeverbout 0:ea44dc9ed014 127 //! @}
joeverbout 0:ea44dc9ed014 128
joeverbout 0:ea44dc9ed014 129 } // namespace detail
joeverbout 0:ea44dc9ed014 130 } // namespace cv
joeverbout 0:ea44dc9ed014 131
joeverbout 0:ea44dc9ed014 132 #endif // __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
joeverbout 0:ea44dc9ed014 133