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 <cstddef> 00028 #include <opencv/cv.h> 00029 00030 namespace firevision { 00031 #if 0 /* just to make Emacs auto-indent happy */ 00032 } 00033 #endif 00034 00035 /** @class IplImageAdapter <fvutils/adapters/iplimage.h> 00036 * Adapter for OpenCV IplImages. 00037 * Conversion routines from FireVision buffers to OpenCV IplImages. 00038 * @author Tim Niemueller 00039 */ 00040 00041 /** Convert image from buffer into IplImage. 00042 * @param buffer YUV422_PLANAR buffer of the same size as image 00043 * @param image IplImage the result will be written to in BGR notation 00044 */ 00045 void 00046 IplImageAdapter::convert_image_bgr(unsigned char *buffer, 00047 IplImage *image) 00048 { 00049 convert(YUV422_PLANAR, BGR, buffer, (unsigned char *)image->imageData, 00050 image->width, image->height); 00051 } 00052 00053 00054 /* Creates a new IplImage for a ROI. 00055 * This will create a new IplImage with the size of the ROI and convert the data of the 00056 * passed YUV422_PLANAR buffer to the IplImage. 00057 * @param buffer YUV422_PLANAR buffer 00058 * @param roi ROI to take the image from 00059 * @return new IplImage instance with the image from the ROI. Use cvReleaseImage after you 00060 * are done with it. 00061 IplImage * 00062 IplImageAdapter::create_image_from_roi(unsigned char *buffer, ROI *roi) 00063 { 00064 IplImage *image = cvCreateImage(cvSize(roi->extent.width, roi->extent.height), IPL_DEPTH_8U, 3); 00065 00066 unsigned int to_line = roi->start.y + roi->extend.height; 00067 unsigned char * 00068 for ( unsigned int h = roi->start.y; h < to_line; ++h) { 00069 00070 } 00071 convert(YUV422_PLANAR, BGR, _src, (unsigned char *)__image->imageData, _width, _height); 00072 00073 } 00074 */ 00075 00076 } // end namespace firevision