iplimage.cpp
00001 00002 /*************************************************************************** 00003 * iplimage.cpp - Helper to convert FireVision buffers to IplImages for OpenCV 00004 * 00005 * Created: Sat Apr 19 17:33:00 2008 (GO2008, day 1) 00006 * Copyright 2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <fvutils/adapters/iplimage.h> 00025 00026 #include <fvutils/color/conversions.h> 00027 #include <opencv/cv.h> 00028 00029 00030 /** @class IplImageAdapter <fvutils/adapters/iplimage.h> 00031 * Adapter for OpenCV IplImages. 00032 * Conversion routines from FireVision buffers to OpenCV IplImages. 00033 * @author Tim Niemueller 00034 */ 00035 00036 /** Convert image from buffer into IplImage. 00037 * @param buffer YUV422_PLANAR buffer of the same size as image 00038 * @param image IplImage the result will be written to in BGR notation 00039 */ 00040 void 00041 IplImageAdapter::convert_image_bgr(unsigned char *buffer, 00042 IplImage *image) 00043 { 00044 convert(YUV422_PLANAR, BGR, buffer, (unsigned char *)image->imageData, 00045 image->width, image->height); 00046 } 00047 00048 00049 /* Creates a new IplImage for a ROI. 00050 * This will create a new IplImage with the size of the ROI and convert the data of the 00051 * passed YUV422_PLANAR buffer to the IplImage. 00052 * @param buffer YUV422_PLANAR buffer 00053 * @param roi ROI to take the image from 00054 * @return new IplImage instance with the image from the ROI. Use cvReleaseImage after you 00055 * are done with it. 00056 IplImage * 00057 IplImageAdapter::create_image_from_roi(unsigned char *buffer, ROI *roi) 00058 { 00059 IplImage *image = cvCreateImage(cvSize(roi->extent.width, roi->extent.height), IPL_DEPTH_8U, 3); 00060 00061 unsigned int to_line = roi->start.y + roi->extend.height; 00062 unsigned char * 00063 for ( unsigned int h = roi->start.y; h < to_line; ++h) { 00064 00065 } 00066 convert(YUV422_PLANAR, BGR, _src, (unsigned char *)__image->imageData, _width, _height); 00067 00068 } 00069 */

