Fawkes API
Fawkes Development Version
image_drawer.cpp
1
2
/***************************************************************************
3
* image_drawer.cpp - Skeleton Visualization GUI: image drawer
4
*
5
* Created: Sat Mar 19 00:08:37 2011
6
* Copyright 2006-2011 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.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include "image_drawer.h"
24
25
#include <GL/glut.h>
26
#include <fvcams/camera.h>
27
#include <fvutils/color/colorspaces.h>
28
#include <fvutils/color/conversions.h>
29
30
#include <algorithm>
31
#include <cstdio>
32
#include <cstdlib>
33
34
using namespace
fawkes
;
35
using namespace
firevision;
36
37
/** @class SkelGuiImageDrawer "image_drawer.h"
38
* Draw images from camera in texture.
39
* Uses texture mapping to show an image acquired from a camera in the
40
* background.
41
* @author Tim Niemueller
42
*/
43
44
/** Constructor.
45
* @param cam camera to capture image with
46
*/
47
SkelGuiImageDrawer::SkelGuiImageDrawer
(
firevision::Camera
*cam)
48
:
SkelGuiTextureDrawer
(cam->pixel_width(), cam->pixel_height())
49
{
50
cam_ = cam;
51
rgb_buf_ = malloc_buffer(RGB,
width_
,
height_
);
52
}
53
54
/** Destructor. */
55
SkelGuiImageDrawer::~SkelGuiImageDrawer
()
56
{
57
free(rgb_buf_);
58
}
59
60
/** Fill texture. */
61
void
62
SkelGuiImageDrawer::fill_texture
()
63
{
64
cam_->
capture
();
65
convert(cam_->
colorspace
(), RGB, cam_->
buffer
(), rgb_buf_,
width_
,
height_
);
66
copy_rgb_to_texture
(rgb_buf_);
67
cam_->
dispose_buffer
();
68
}
SkelGuiTextureDrawer
Draw images from camera in texture.
Definition:
texture_drawer.h:33
firevision::Camera::colorspace
virtual colorspace_t colorspace()=0
Colorspace of returned image.
SkelGuiTextureDrawer::width_
const unsigned int width_
Width of visible area from texture.
Definition:
texture_drawer.h:52
SkelGuiImageDrawer::fill_texture
void fill_texture()
Fill texture.
Definition:
image_drawer.cpp:62
firevision::Camera::dispose_buffer
virtual void dispose_buffer()=0
Dispose current buffer.
SkelGuiTextureDrawer::copy_rgb_to_texture
void copy_rgb_to_texture(const unsigned char *rgb_buf)
Copy an RGB buffer to texture.
Definition:
texture_drawer.cpp:150
firevision::Camera::buffer
virtual unsigned char * buffer()=0
Get access to current image buffer.
SkelGuiTextureDrawer::height_
const unsigned int height_
Height of visible area from texture.
Definition:
texture_drawer.h:53
fawkes
Fawkes library namespace.
SkelGuiImageDrawer::SkelGuiImageDrawer
SkelGuiImageDrawer(firevision::Camera *cam)
Constructor.
Definition:
image_drawer.cpp:47
SkelGuiImageDrawer::~SkelGuiImageDrawer
~SkelGuiImageDrawer()
Destructor.
Definition:
image_drawer.cpp:55
firevision::Camera::capture
virtual void capture()=0
Capture an image.
firevision::Camera
Camera interface for image aquiring devices in FireVision.
Definition:
camera.h:33
src
plugins
openni
skelgui
image_drawer.cpp
Generated by
1.8.20