00001 /**************************************************************** 00002 * 00003 * Copyright (c) 2010 00004 * 00005 * Fraunhofer Institute for Manufacturing Engineering 00006 * and Automation (IPA) 00007 * 00008 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 * 00010 * Project name: care-o-bot 00011 * ROS stack name: cob_common 00012 * ROS package name: cob_vision_utils 00013 * Description: Utility functions for Fraunhofer IPA vision library. 00014 * 00015 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00016 * 00017 * Author: Jan Fischer, email:jan.fischer@ipa.fhg.de 00018 * Supervised by: Jan Fischer, email:jan.fischer@ipa.fhg.de 00019 * 00020 * Date of creation: July 2008 00021 * ToDo: 00022 * 00023 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00024 * 00025 * Redistribution and use in source and binary forms, with or without 00026 * modification, are permitted provided that the following conditions are met: 00027 * 00028 * * Redistributions of source code must retain the above copyright 00029 * notice, this list of conditions and the following disclaimer. 00030 * * Redistributions in binary form must reproduce the above copyright 00031 * notice, this list of conditions and the following disclaimer in the 00032 * documentation and/or other materials provided with the distribution. 00033 * * Neither the name of the Fraunhofer Institute for Manufacturing 00034 * Engineering and Automation (IPA) nor the names of its 00035 * contributors may be used to endorse or promote products derived from 00036 * this software without specific prior written permission. 00037 * 00038 * This program is free software: you can redistribute it and/or modify 00039 * it under the terms of the GNU Lesser General Public License LGPL as 00040 * published by the Free Software Foundation, either version 3 of the 00041 * License, or (at your option) any later version. 00042 * 00043 * This program is distributed in the hope that it will be useful, 00044 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00045 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00046 * GNU Lesser General Public License LGPL for more details. 00047 * 00048 * You should have received a copy of the GNU Lesser General Public 00049 * License LGPL along with this program. 00050 * If not, see <http://www.gnu.org/licenses/>. 00051 * 00052 ****************************************************************/ 00053 00058 00059 #ifndef __IPA_VISIONUTILS_H__ 00060 #define __IPA_VISIONUTILS_H__ 00061 00062 #ifdef __LINUX__ 00063 #include "cob_vision_utils/GlobalDefines.h" 00064 00065 #include <opencv/cv.h> 00066 #else 00067 #include "cob_common/cob_vision_utils/common/include/cob_vision_utils/GlobalDefines.h" 00068 00069 #include <cv.h> 00070 #endif 00071 00072 #include <iostream> 00073 00074 namespace ipa_Utils { 00075 00076 00080 cv::Mat vstack(const std::vector<cv::Mat> &mats); 00081 00083 void InitUndistortMap( const cv::Mat& A, const cv::Mat& dist_coeffs, 00084 cv::Mat& mapxarr, cv::Mat& mapyarr ); 00085 00093 unsigned long ConvertToShowImage(const cv::Mat& source, cv::Mat& dest, int channel = 1, double min = -1, double max = -1); 00094 00107 unsigned long MaskImage(const cv::Mat& source, cv::Mat& dest, const cv::Mat& mask, cv::Mat& destMask, float minMaskThresh = 0, 00108 float maxMaskTresh = 20000, int sourceChannel = 1, double sourceMin = -1, double sourceMax = -1); 00109 00116 unsigned long EvaluatePolynomial(double x, int degree, double* coefficients, double* y); 00117 00125 unsigned long FilterByAmplitude(cv::Mat& xyzImage, const cv::Mat& greyImage, cv::Mat* mask, cv::Mat* maskColor, float minMaskThresh, float maxMaskThresh); 00126 00135 unsigned long FilterTearOffEdges(cv::Mat& xyzImage, cv::Mat* mask, float piHalfFraction = 6); 00136 00138 unsigned long FilterSpeckles( cv::Mat& img, int maxSpeckleSize, double _maxDiff, cv::Mat& _buf ); 00139 00145 cv::Vec3f GrayColorMap(double value, double min, double max); 00146 00150 cv::Mat GetColorcoded(const cv::Mat& img_32F); 00151 00157 cv::Mat GetColorcoded(const cv::Mat& img_32F, double min, double max); 00158 00163 unsigned long SaveMat(cv::Mat& mat, std::string filename); 00164 00169 unsigned long LoadMat(cv::Mat& mat, std::string filename); 00170 00171 00172 } // end namespace __IPA_VISIONUTILS_H__ 00173 00174 00175 #endif