Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * image_drawer.cpp - Skeleton Visualization GUI: image drawer 00004 * 00005 * Created: Sat Mar 19 00:08:37 2011 00006 * Copyright 2006-2011 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. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #include "image_drawer.h" 00024 00025 #include <fvcams/camera.h> 00026 #include <fvutils/color/colorspaces.h> 00027 #include <fvutils/color/conversions.h> 00028 00029 #include <cstdlib> 00030 #include <cstdio> 00031 #include <algorithm> 00032 #include <GL/glut.h> 00033 00034 using namespace fawkes; 00035 using namespace firevision; 00036 00037 /** @class SkelGuiImageDrawer "image_drawer.h" 00038 * Draw images from camera in texture. 00039 * Uses texture mapping to show an image acquired from a camera in the 00040 * background. 00041 * @author Tim Niemueller 00042 */ 00043 00044 /** Constructor. 00045 * @param cam camera to capture image with 00046 */ 00047 SkelGuiImageDrawer::SkelGuiImageDrawer(firevision::Camera *cam) 00048 : SkelGuiTextureDrawer(cam->pixel_width(), cam->pixel_height()) 00049 { 00050 __cam = cam; 00051 __rgb_buf = malloc_buffer(RGB, __width, __height); 00052 00053 } 00054 00055 /** Destructor. */ 00056 SkelGuiImageDrawer::~SkelGuiImageDrawer() 00057 { 00058 free(__rgb_buf); 00059 } 00060 00061 /** Fill texture. */ 00062 void 00063 SkelGuiImageDrawer::fill_texture() 00064 { 00065 __cam->capture(); 00066 convert(__cam->colorspace(), RGB, __cam->buffer(), __rgb_buf, __width, __height); 00067 copy_rgb_to_texture(__rgb_buf); 00068 __cam->dispose_buffer(); 00069 } 00070