OpenGLCapture.cpp
Go to the documentation of this file.
1 // ****************************************************************************
2 // This file is part of the Integrating Vision Toolkit (IVT).
3 //
4 // The IVT is maintained by the Karlsruhe Institute of Technology (KIT)
5 // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de).
6 //
7 // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT).
8 // All rights reserved.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are met:
12 //
13 // 1. Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
15 //
16 // 2. Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
19 //
20 // 3. Neither the name of the KIT nor the names of its contributors may be
21 // used to endorse or promote products derived from this software
22 // without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE KIT AND CONTRIBUTORS “AS IS” AND ANY
25 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 // DISCLAIMED. IN NO EVENT SHALL THE KIT OR CONTRIBUTORS BE LIABLE FOR ANY
28 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // ****************************************************************************
35 // ****************************************************************************
36 // Filename: OpenGLCapture.cpp
37 // Author: Pedram Azad
38 // Date: 27.07.2008
39 // ****************************************************************************
40 
41 
42 // ****************************************************************************
43 // Includes
44 // ****************************************************************************
45 
46 #include "OpenGLCapture.h"
47 #include "Image/ImageProcessor.h"
48 #include "Image/ByteImage.h"
52 
53 
54 
55 // *****************************************************************
56 // Constructors / Destructor
57 // *****************************************************************
58 
60 {
61  m_nCameras = 0;
62 
63  width = height = 0;
65 
67  m_pCalibration = 0;
69 }
70 
72 {
73  m_nCameras = 1;
74 
75  width = calibration.GetCameraParameters().width;
76  height = calibration.GetCameraParameters().height;
78 
82 
83  m_pCalibration->Set(calibration);
84 }
85 
87 {
88  m_nCameras = 2;
89 
90  width = stereoCalibration.width;
91  height = stereoCalibration.height;
93 
96  m_pCalibration = 0;
97 
98  m_pStereoCalibration->Set(stereoCalibration);
99 }
100 
102 {
103  if (m_pCalibration)
104  delete m_pCalibration;
105 
107  delete m_pStereoCalibration;
108 
110  delete m_pOpenGLVisualizer;
111 }
112 
113 
114 // ****************************************************************************
115 // Methods
116 // ****************************************************************************
117 
118 void COpenGLCapture::Set(const CCalibration &calibration)
119 {
120  m_nCameras = 1;
121 
122  width = calibration.GetCameraParameters().width;
123  height = calibration.GetCameraParameters().height;
125 
127  {
128  delete m_pStereoCalibration;
130  }
131 
132  if (!m_pCalibration)
134 
135  if (!m_pOpenGLVisualizer)
137 
138  m_pCalibration->Set(calibration);
139 }
140 
141 
142 void COpenGLCapture::Set(const CStereoCalibration &stereoCalibration)
143 {
144  m_nCameras = 2;
145 
146  width = stereoCalibration.width;
147  height = stereoCalibration.height;
149 
150  if (m_pCalibration)
151  {
152  delete m_pCalibration;
153  m_pCalibration = 0;
154  }
155 
158 
159  if (!m_pOpenGLVisualizer)
161 
162  m_pStereoCalibration->Set(stereoCalibration);
163 }
164 
166 {
169  else if (m_pCalibration)
171  else
172  printf("error: no calibration object has been instantiated\n");
173 
174  return false;
175 }
176 
178 {
179 }
180 
182 {
183  if (ppImages[0]->width != width || ppImages[0]->height != height || ppImages[0]->type != type)
184  printf("error: image does not match COpenGLCapture::CaptureImage\n");
185 
186  if (m_nCameras == 1)
187  {
189  DrawScene(); // virtual method call
190  m_pOpenGLVisualizer->GetImage(ppImages[0]);
191  ImageProcessor::FlipY(ppImages[0], ppImages[0]);
192  }
193  else if (m_nCameras == 2)
194  {
195  if (ppImages[1]->width != width || ppImages[1]->height != height || ppImages[1]->type != type)
196  printf("error: image does not match COpenGLCapture::CaptureImage\n");
197 
198  // left camera
200  DrawScene(); // virtual method call
201  m_pOpenGLVisualizer->GetImage(ppImages[0]);
202  ImageProcessor::FlipY(ppImages[0], ppImages[0]);
203 
204  // right camera
206  DrawScene(); // virtual method call
207  m_pOpenGLVisualizer->GetImage(ppImages[1]);
208  ImageProcessor::FlipY(ppImages[1], ppImages[1]);
209  }
210 
211  return true;
212 }
bool GetImage(CByteImage *pDestinationImage)
bool InitByCalibration(const CCalibration *pCalibration, bool bActivateShading=true)
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
Definition: ByteImage.h:80
const CCalibration * GetLeftCalibration() const
Access to the instance of CCalibration for the camera model of the left camera.
GLuint GLuint GLsizei GLenum type
Definition: glext.h:3121
bool FlipY(const CByteImage *pInputImage, CByteImage *pOutputImage)
Flips the rows in a CByteImage vertically and writes the result to a CByteImage.
virtual void DrawScene()=0
const CCameraParameters & GetCameraParameters() const
Gives access to the camera parameters.
Definition: Calibration.h:268
CStereoCalibration * m_pStereoCalibration
int height
The height of the images of the stereo camera system in pixels.
CCalibration * m_pCalibration
int width
The width of the images of the stereo camera system in pixels.
Camera model and functions for a stereo camera system.
COpenGLVisualizer * m_pOpenGLVisualizer
Definition: OpenGLCapture.h:99
bool CaptureImage(CByteImage **ppImages)
GLenum GLsizei width
Definition: glext.h:3122
GLenum GLsizei GLsizei height
Definition: glext.h:3132
void Set(const CCalibration &calibration)
Initializes the camera model, given an instance of CCalibration.
void Set(const CCalibration &calibration)
Camera model parameters and functions for a single camera.
Definition: Calibration.h:125
void Set(const CStereoCalibration &stereoCalibration)
Initializes the stereo camera model, given an instance of CStereoCalibration.
const CCalibration * GetRightCalibration() const
Access to the instance of CCalibration for the camera model of the right camera.


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Mon Dec 2 2019 03:47:28