/usr/include/visp/vpImageConvert.h is in libvisp-dev 2.8.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | /****************************************************************************
*
* $Id: vpImageConvert.h 4216 2013-04-17 09:06:18Z fspindle $
*
* This file is part of the ViSP software.
* Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* ("GPL") version 2 as published by the Free Software Foundation.
* See the file LICENSE.txt at the root directory of this source
* distribution for additional information about the GNU GPL.
*
* For using ViSP with software that can not be combined with the GNU
* GPL, please contact INRIA about acquiring a ViSP Professional
* Edition License.
*
* See http://www.irisa.fr/lagadic/visp/visp.html for more information.
*
* This software was developed at:
* INRIA Rennes - Bretagne Atlantique
* Campus Universitaire de Beaulieu
* 35042 Rennes Cedex
* France
* http://www.irisa.fr/lagadic
*
* If you have questions regarding the use of this file, please contact
* INRIA at visp@inria.fr
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* Description:
* Convert image types.
*
* Authors:
* Eric Marchand
* Fabien Spindler
* Anthony Saunier
*
*****************************************************************************/
/*!
\file vpImageConvert.h
\brief Convert image types
*/
#ifndef vpIMAGECONVERT_H
#define vpIMAGECONVERT_H
// image
#include <visp/vpConfig.h>
#include <visp/vpImage.h>
#include <visp/vpDebug.h>
// color
#include <visp/vpRGBa.h>
#ifdef VISP_HAVE_OPENCV
# if (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1
# include <opencv2/core/core.hpp>
# include <opencv2/legacy/legacy.hpp>
# include <opencv2/highgui/highgui.hpp>
# include <opencv2/highgui/highgui_c.h>
# else
# include <highgui.h>
# endif
#endif
#ifdef VISP_HAVE_YARP
# include <yarp/sig/Image.h>
#endif
#ifdef WIN32
# include <windows.h>
#endif
#if defined(VISP_HAVE_LIBJPEG)
# include <jpeglib.h>
# include <jerror.h>
#endif
#if defined(VISP_HAVE_LIBPNG)
# include <png.h>
#endif
/*!
\class vpImageConvert
\ingroup ImageConversion
Convert image types.
The following example available in tutorial-image-converter.cpp shows how to
convert an OpenCV cv::Mat image into a vpImage:
\include tutorial-image-converter.cpp
*/
class VISP_EXPORT vpImageConvert
{
public:
static void convert(const vpImage<unsigned char> &src,
vpImage<vpRGBa> & dest) ;
static void convert(const vpImage<vpRGBa> &src,
vpImage<unsigned char> & dest) ;
static void convert(const vpImage<float> &src,
vpImage<unsigned char> &dest);
static void convert(const vpImage<unsigned char> &src,
vpImage<float> &dest);
static void convert(const vpImage<double> &src,
vpImage<unsigned char> &dest);
static void convert(const vpImage<unsigned char> &src,
vpImage<double> &dest);
#ifdef VISP_HAVE_OPENCV
static void convert(const IplImage* src,
vpImage<vpRGBa> & dest, bool flip = false) ;
static void convert(const IplImage* src,
vpImage<unsigned char> & dest, bool flip = false) ;
static void convert(const vpImage<vpRGBa> & src,
IplImage *&dest) ;
static void convert(const vpImage<unsigned char> & src,
IplImage* &dest) ;
#if VISP_HAVE_OPENCV_VERSION >= 0x020100
static void convert(const cv::Mat& src,
vpImage<vpRGBa>& dest, const bool flip = false);
static void convert(const cv::Mat& src,
vpImage<unsigned char>& dest, const bool flip = false);
static void convert(const vpImage<vpRGBa> & src,
cv::Mat& dest) ;
static void convert(const vpImage<unsigned char> & src,
cv::Mat& dest, const bool copyData = true) ;
#endif
#endif
#ifdef VISP_HAVE_YARP
static void convert(const vpImage<unsigned char> & src,
yarp::sig::ImageOf< yarp::sig::PixelMono > *dest, const bool copyData = true) ;
static void convert(const yarp::sig::ImageOf< yarp::sig::PixelMono > *src,
vpImage<unsigned char> & dest,const bool copyData = true ) ;
static void convert(const vpImage<vpRGBa> & src,
yarp::sig::ImageOf< yarp::sig::PixelRgba > *dest, const bool copyData = true) ;
static void convert(const yarp::sig::ImageOf< yarp::sig::PixelRgba > *src,
vpImage<vpRGBa> & dest,const bool copyData = true) ;
static void convert(const vpImage<vpRGBa> & src,
yarp::sig::ImageOf< yarp::sig::PixelRgb > *dest) ;
static void convert(const yarp::sig::ImageOf< yarp::sig::PixelRgb > *src,
vpImage<vpRGBa> & dest) ;
#endif
#ifdef VISP_HAVE_LIBJPEG
#if JPEG_LIB_VERSION > 70
static void convertToJPEGBuffer(const vpImage<unsigned char> &src,
unsigned char **dest, long unsigned int &destSize, int quality = 100);
static void convertToJPEGBuffer(unsigned char *src, long unsigned int srcSize,
vpImage<unsigned char> &dest);
#endif
#endif
static void split(const vpImage<vpRGBa> &src,
vpImage<unsigned char>* pR,
vpImage<unsigned char>* pG,
vpImage<unsigned char>* pB,
vpImage<unsigned char>* pa = NULL) ;
/*!
Converts a yuv pixel value in rgb format.
\param y Y component of a pixel.
\param u U component of a pixel.
\param v V component of a pixel.
\param r Red component from the YUV coding format. This value is computed
using:
\f[ r = 0.9999695*y - 0.0009508*(u-128) + 1.1359061*(v-128) \f]
\param g Green component from the YUV coding format. This value is computed
using:
\f[g = 0.9999695*y - 0.3959609*(u-128) - 0.5782955*(v-128) \f]
\param b Blue component from the YUV coding format. This value is computed
using:
\f[b = 0.9999695*y + 2.04112*(u-128) - 0.0016314*(v-128) \f]
*/
static inline void YUVToRGB(unsigned char y,
unsigned char u,
unsigned char v,
unsigned char &r,
unsigned char &g,
unsigned char &b)
{
double dr, dg, db;
dr = floor(0.9999695*y - 0.0009508*(u-128) + 1.1359061*(v-128));
dg = floor(0.9999695*y - 0.3959609*(u-128) - 0.5782955*(v-128));
db = floor(0.9999695*y + 2.04112*(u-128) - 0.0016314*(v-128));
dr = dr < 0. ? 0. : dr;
dg = dg < 0. ? 0. : dg;
db = db < 0. ? 0. : db;
dr = dr > 255. ? 255. : dr;
dg = dg > 255. ? 255. : dg;
db = db > 255. ? 255. : db;
r = (unsigned char) dr;
g = (unsigned char) dg;
b = (unsigned char) db;
};
static void YUYVToRGBa(unsigned char* yuyv, unsigned char* rgba,
unsigned int width, unsigned int height);
static void YUYVToRGB(unsigned char* yuyv, unsigned char* rgb,
unsigned int width, unsigned int height);
static void YUYVToGrey(unsigned char* yuyv, unsigned char* grey,
unsigned int size);
static void YUV411ToRGBa(unsigned char* yuv,
unsigned char* rgba, unsigned int size);
static void YUV411ToRGB(unsigned char* yuv,
unsigned char* rgb, unsigned int size);
static void YUV411ToGrey(unsigned char* yuv,
unsigned char* grey, unsigned int size);
static void YUV422ToRGBa(unsigned char* yuv,
unsigned char* rgba, unsigned int size);
static void YUV422ToRGB(unsigned char* yuv,
unsigned char* rgb, unsigned int size);
static void YUV422ToGrey(unsigned char* yuv,
unsigned char* grey, unsigned int size);
static void YUV420ToRGBa(unsigned char* yuv,
unsigned char* rgba, unsigned int width, unsigned int height);
static void YUV420ToRGB(unsigned char* yuv,
unsigned char* rgb, unsigned int width, unsigned int height);
static void YUV420ToGrey(unsigned char* yuv,
unsigned char* grey, unsigned int size);
static void YUV444ToRGBa(unsigned char* yuv,
unsigned char* rgba, unsigned int size);
static void YUV444ToRGB(unsigned char* yuv,
unsigned char* rgb, unsigned int size);
static void YUV444ToGrey(unsigned char* yuv,
unsigned char* grey, unsigned int size);
static void YV12ToRGBa(unsigned char* yuv,
unsigned char* rgba, unsigned int width, unsigned int height);
static void YV12ToRGB(unsigned char* yuv,
unsigned char* rgb, unsigned int width, unsigned int height);
static void YVU9ToRGBa(unsigned char* yuv,
unsigned char* rgba, unsigned int width, unsigned int height);
static void YVU9ToRGB(unsigned char* yuv,
unsigned char* rgb, unsigned int width, unsigned int height);
static void RGBToRGBa(unsigned char* rgb,
unsigned char* rgba, unsigned int size);
static void RGBaToRGB(unsigned char* rgba,
unsigned char* rgb, unsigned int size);
static void RGBToGrey(unsigned char* rgb,
unsigned char* grey, unsigned int size);
static void RGBaToGrey(unsigned char* rgba,
unsigned char* grey, unsigned int size);
static void RGBToRGBa(unsigned char * bgr, unsigned char * rgba,
unsigned int width, unsigned int height, bool flip = false);
static void RGBToGrey(unsigned char * bgr, unsigned char * grey,
unsigned int width, unsigned int height, bool flip = false);
static void GreyToRGBa(unsigned char* grey,
unsigned char* rgba, unsigned int size);
static void GreyToRGB(unsigned char* grey,
unsigned char* rgb, unsigned int size);
static void BGRToRGBa(unsigned char * bgr, unsigned char * rgba,
unsigned int width, unsigned int height, bool flip);
static void BGRToGrey(unsigned char * bgr, unsigned char * grey,
unsigned int width, unsigned int height, bool flip);
static void YCbCrToRGB(unsigned char *ycbcr, unsigned char *rgb,
unsigned int size);
static void YCbCrToRGBa (unsigned char *ycbcr, unsigned char *rgb,
unsigned int size);
static void YCrCbToRGB(unsigned char *ycbcr, unsigned char *rgb,
unsigned int size);
static void YCrCbToRGBa(unsigned char *ycbcr, unsigned char *rgb,
unsigned int size);
static void YCbCrToGrey(unsigned char *ycbcr, unsigned char *grey,
unsigned int size);
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey,
unsigned int size);
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba,
unsigned int size);
private:
static void computeYCbCrLUT();
private:
static bool YCbCrLUTcomputed;
static int vpCrr[256];
static int vpCgb[256];
static int vpCgr[256];
static int vpCbb[256];
} ;
#endif
/*
* Local variables:
* c-basic-offset: 2
* End:
*/
|