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
#include <fvutils/color/conversions.h>
26
#include <opencv/cv.h>
27
28
#include <cstddef>
29
30
namespace
firevision {
31
32
/** @class IplImageAdapter <fvutils/adapters/iplimage.h>
33
* Adapter for OpenCV IplImages.
34
* Conversion routines from FireVision buffers to OpenCV IplImages.
35
* @author Tim Niemueller
36
*/
37
38
/** Convert image from buffer into IplImage.
39
* @param buffer YUV422_PLANAR buffer of the same size as image
40
* @param image IplImage the result will be written to in BGR notation
41
*/
42
void
43
IplImageAdapter::convert_image_bgr
(
unsigned
char
*buffer, IplImage *image)
44
{
45
convert(
46
YUV422_PLANAR, BGR, buffer, (
unsigned
char
*)image->imageData, image->width, image->height);
47
}
48
49
/** Convert image from IplImage into buffer.
50
* @param image IplImage with BGR notation
51
* @param buffer YUV422_PLANAR of the same size to write the converted IplImage
52
*/
53
void
54
IplImageAdapter::convert_image_yuv422_planar
(IplImage *image,
unsigned
char
*buffer)
55
{
56
convert(
57
BGR, YUV422_PLANAR, (
unsigned
char
*)image->imageData, buffer, image->width, image->height);
58
}
59
60
/* Creates a new IplImage for a ROI.
61
* This will create a new IplImage with the size of the ROI and convert the data of the
62
* passed YUV422_PLANAR buffer to the IplImage.
63
* @param buffer YUV422_PLANAR buffer
64
* @param roi ROI to take the image from
65
* @return new IplImage instance with the image from the ROI. Use cvReleaseImage after you
66
* are done with it.
67
IplImage *
68
IplImageAdapter::create_image_from_roi(unsigned char *buffer, ROI *roi)
69
{
70
IplImage *image = cvCreateImage(cvSize(roi->extent.width, roi->extent.height), IPL_DEPTH_8U, 3);
71
72
unsigned int to_line = roi->start.y + roi->extend.height;
73
unsigned char *
74
for ( unsigned int h = roi->start.y; h < to_line; ++h) {
75
76
}
77
convert(YUV422_PLANAR, BGR, _src, (unsigned char *)image_->imageData, _width, _height);
78
79
}
80
*/
81
82
}
// end namespace firevision
firevision::IplImageAdapter::convert_image_yuv422_planar
static void convert_image_yuv422_planar(IplImage *image, unsigned char *buffer)
Convert image from IplImage into buffer.
Definition:
iplimage.cpp:60
firevision::IplImageAdapter::convert_image_bgr
static void convert_image_bgr(unsigned char *buffer, IplImage *image)
Convert image from buffer into IplImage.
Definition:
iplimage.cpp:49
src
libs
fvutils
adapters
iplimage.cpp
Generated by
1.8.17