Fawkes API  Fawkes Development Version
iplimage.cpp
1 
2 /***************************************************************************
3  * iplimage.cpp - Helper to convert FireVision buffers to IplImages for OpenCV
4  *
5  * Created: Sat Apr 19 17:33:00 2008 (GO2008, day 1)
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <fvutils/adapters/iplimage.h>
25 
26 #include <fvutils/color/conversions.h>
27 #include <cstddef>
28 #include <opencv/cv.h>
29 
30 namespace firevision {
31 #if 0 /* just to make Emacs auto-indent happy */
32 }
33 #endif
34 
35 /** @class IplImageAdapter <fvutils/adapters/iplimage.h>
36  * Adapter for OpenCV IplImages.
37  * Conversion routines from FireVision buffers to OpenCV IplImages.
38  * @author Tim Niemueller
39  */
40 
41 /** Convert image from buffer into IplImage.
42  * @param buffer YUV422_PLANAR buffer of the same size as image
43  * @param image IplImage the result will be written to in BGR notation
44  */
45 void
46 IplImageAdapter::convert_image_bgr(unsigned char *buffer,
47  IplImage *image)
48 {
49  convert(YUV422_PLANAR, BGR, buffer, (unsigned char *)image->imageData,
50  image->width, image->height);
51 }
52 
53 
54 /** Convert image from IplImage into buffer.
55  * @param image IplImage with BGR notation
56  * @param buffer YUV422_PLANAR of the same size to write the converted IplImage
57  */
58 void
60  unsigned char *buffer)
61 {
62  convert(BGR, YUV422_PLANAR, (unsigned char *)image->imageData, buffer,
63  image->width, image->height);
64 }
65 
66 
67 /* Creates a new IplImage for a ROI.
68  * This will create a new IplImage with the size of the ROI and convert the data of the
69  * passed YUV422_PLANAR buffer to the IplImage.
70  * @param buffer YUV422_PLANAR buffer
71  * @param roi ROI to take the image from
72  * @return new IplImage instance with the image from the ROI. Use cvReleaseImage after you
73  * are done with it.
74 IplImage *
75 IplImageAdapter::create_image_from_roi(unsigned char *buffer, ROI *roi)
76 {
77  IplImage *image = cvCreateImage(cvSize(roi->extent.width, roi->extent.height), IPL_DEPTH_8U, 3);
78 
79  unsigned int to_line = roi->start.y + roi->extend.height;
80  unsigned char *
81  for ( unsigned int h = roi->start.y; h < to_line; ++h) {
82 
83  }
84  convert(YUV422_PLANAR, BGR, _src, (unsigned char *)__image->imageData, _width, _height);
85 
86 }
87  */
88 
89 } // end namespace firevision
static void convert_image_bgr(unsigned char *buffer, IplImage *image)
Convert image from buffer into IplImage.
Definition: iplimage.cpp:46
static void convert_image_yuv422_planar(IplImage *image, unsigned char *buffer)
Convert image from IplImage into buffer.
Definition: iplimage.cpp:59