--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of the copyright holders may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "exposure_compensate.hpp"\r
+#include "util.hpp"\r
+\r
+using namespace std;\r
+using namespace cv;\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of the copyright holders may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/
+#ifndef __OPENCV_EXPOSURE_COMPENSATE_HPP__
+#define __OPENCV_EXPOSURE_COMPENSATE_HPP__
+
+#include "precomp.hpp"
+
+
+class ExposureCompensator
+{
+public:
+ virtual void feed(const std::vector<cv::Mat> &images, const std::vector<cv::Mat> &masks) = 0;
+ virtual void apply(int index, cv::Mat &image, cv::Mat &mask) = 0;
+};
+
+
+class NoExposureCompensator : public ExposureCompensator
+{
+public:
+ virtual void feed(const std::vector<cv::Mat> &/*images*/, const std::vector<cv::Mat> &/*masks*/) {};
+ virtual void apply(int /*index*/, cv::Mat &/*image*/, cv::Mat &/*mask*/) {};
+};
+
+
+#endif // __OPENCV_EXPOSURE_COMPENSATE_HPP__
\ No newline at end of file
#include "blenders.hpp"\r
#include "seam_finders.hpp"\r
#include "motion_estimators.hpp"\r
+#include "exposure_compensate.hpp"\r
\r
using namespace std;\r
using namespace cv;\r
\r
LOGLN("Warping images, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
\r
- LOGLN("Finding seams...");\r
+ LOGLN("Exposure compensation (feed)...");\r
t = getTickCount();\r
+ Ptr<ExposureCompensator> compensator = new NoExposureCompensator();\r
+ compensator->feed(images_warped, masks_warped);\r
+ LOGLN("Exposure compensation (feed), time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
\r
- // Find seams\r
+ LOGLN("Finding seams...");\r
+ t = getTickCount();\r
Ptr<SeamFinder> seam_finder = SeamFinder::createDefault(seam_find_type);\r
seam_finder->find(images_warped_f, corners, masks_warped);\r
-\r
LOGLN("Finding seams, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");\r
\r
// Release unused memory\r
// Warp the current image\r
warper->warp(img, static_cast<float>(cameras[img_idx].focal), cameras[img_idx].R, \r
img_warped);\r
- img_warped.convertTo(img_warped_s, CV_16S);\r
- img_warped.release();\r
- img.release();\r
\r
// Warp current image mask\r
mask.create(img_size, CV_8U);\r
mask.setTo(Scalar::all(255)); \r
warper->warp(mask, static_cast<float>(cameras[img_idx].focal), cameras[img_idx].R, mask_warped,\r
INTER_NEAREST, BORDER_CONSTANT);\r
+\r
+ // Compensate exposure\r
+ compensator->apply(img_idx, img_warped, mask_warped);\r
+\r
+ img_warped.convertTo(img_warped_s, CV_16S);\r
+ img_warped.release();\r
+ img.release();\r
mask.release();\r
+\r
dilate(masks_warped[img_idx], dilated_mask, Mat());\r
resize(dilated_mask, seam_mask, mask_warped.size());\r
mask_warped = seam_mask & mask_warped;\r