BitmapSequenceCapture.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: BitmapSequenceCapture.cpp
37 // Author: Pedram Azad
38 // Date: 2005
39 // ****************************************************************************
40 
41 
42 // ****************************************************************************
43 // Includes
44 // ****************************************************************************
45 
46 #include <new> // for explicitly using correct new/delete operators on VC DSPs
47 
48 #include "BitmapSequenceCapture.h"
49 #include "Image/ImageProcessor.h"
50 #include "Image/ByteImage.h"
51 
52 #include <stdio.h>
53 #include <stdlib.h>
54 
55 
56 
57 // ****************************************************************************
58 // Constructor / Destructor
59 // ****************************************************************************
60 
61 CBitmapSequenceCapture::CBitmapSequenceCapture(const char *pFirstFilePathLeft, const char *pFirstFilePathBaseRight)
62 {
67 
68  m_sFirstFilePathLeft += pFirstFilePathLeft;
69  m_pLeftImage = new CByteImage();
70 
71  if (pFirstFilePathBaseRight)
72  {
73  m_sFirstFilePathRight += pFirstFilePathBaseRight;
74  m_pRightImage = new CByteImage();
75  m_bStereo = true;
76  }
77  else
78  {
79  m_pRightImage = 0;
80  m_bStereo = false;
81  }
82 
83  m_bOK = false;
84  n = 0;
85  m_nFiguresLeft = 0;
86  m_nFiguresRight = 0;
87 
88  m_sFileExtention = "";
89  nFirstImage = 0;
90 }
91 
93 {
94  if (m_pLeftImage)
95  delete m_pLeftImage;
96 
97  if (m_pRightImage)
98  delete m_pRightImage;
99 }
100 
101 
102 // ****************************************************************************
103 // Methods
104 // ****************************************************************************
105 
107 {
108  return m_bOK ? m_pLeftImage->width : -1;
109 }
110 
112 {
113  return m_bOK ? m_pLeftImage->height : -1;
114 }
115 
117 {
118  return m_bOK ? m_pLeftImage->type : (CByteImage::ImageType) -1;
119 }
120 
121 
123 {
124  m_bOK = false;
125  m_nFiguresLeft = 0;
126  m_nFiguresRight = 0;
127  n = 0;
128  nFirstImage = 0;
129 
130  const char *pFirstFilePathLeft = m_sFirstFilePathLeft.c_str();
131  bool bLookForFigures = false;
132 
133  const int nLengthMinusOne = int(m_sFirstFilePathLeft.length()) - 1;
134  for (int i = nLengthMinusOne; i >= 0; i--)
135  {
136  if (pFirstFilePathLeft[i] == '.')
137  {
138  bLookForFigures = true;
139  m_sFileExtention = "";
140  m_sFileExtention += m_sFirstFilePathLeft.substr(i + 1, 3);
141  }
142  else if (bLookForFigures)
143  {
144  if (pFirstFilePathLeft[i] < '0' || pFirstFilePathLeft[i] > '9')
145  {
146  m_sFilePathBaseLeft = "";
147  m_sFilePathBaseLeft += pFirstFilePathLeft;
148  m_sFilePathBaseLeft[i + 1] = '\0';
149  n = atoi(pFirstFilePathLeft + i + 1);
150  nFirstImage = n;
151  break;
152  }
153  else
154  m_nFiguresLeft++;
155  }
156  }
157 
159  return false;
160 
161  if (m_bStereo)
162  {
163  const char *pFirstFilePathRight = m_sFirstFilePathRight.c_str();
164  bool bLookForFigures = false;
165 
166  const int nLengthMinusOne = int(m_sFirstFilePathRight.length()) - 1;
167  for (int i = nLengthMinusOne; i >= 0; i--)
168  {
169  if (pFirstFilePathRight[i] == '.')
170  bLookForFigures = true;
171  else if (bLookForFigures)
172  {
173  if (pFirstFilePathRight[i] < '0' || pFirstFilePathRight[i] > '9')
174  {
176  m_sFilePathBaseRight += pFirstFilePathRight;
177  m_sFilePathBaseRight[i + 1] = '\0';
178  if (n != atoi(pFirstFilePathRight + i + 1))
179  return false;
180  break;
181  }
182  else
183  m_nFiguresRight++;
184  }
185  }
186 
188  return false;
189 
191  return false;
192  }
193 
194  m_bOK = true;
195 
196  return true;
197 }
198 
200 {
201 }
202 
204 {
205  if (!m_bOK)
206  return false;
207 
208  char szTemp[100];
209  char szTemp2[1000];
210 
211  sprintf(szTemp, "%%s%%.%ii.%s", m_nFiguresLeft, m_sFileExtention.c_str());
212  sprintf(szTemp2, szTemp, m_sFilePathBaseLeft.c_str(), n);
213 
214  if (!m_pLeftImage->LoadFromFile(szTemp2))
215  return false;
216 
217  if (!m_pLeftImage->IsCompatible(ppImages[0]))
218  {
219  printf("error: read image is not compatible in CBitmapSequenceCapture::CaptureImage\n");
220  return false;
221  }
222 
224 
225  if (m_bStereo)
226  {
227  sprintf(szTemp2, szTemp, m_sFilePathBaseRight.c_str(), n);
228  if (!m_pRightImage->LoadFromFile(szTemp2))
229  return false;
230 
231  if (!m_pRightImage->IsCompatible(ppImages[1]))
232  {
233  printf("error: read image is not compatible in CBitmapSequenceCapture::CaptureImage (right image)\n");
234  return false;
235  }
236 
238  }
239 
240  n++;
241 
242  return true;
243 }
244 
246 {
247  n = nFirstImage;
248 }
bool IsCompatible(const CByteImage *pImage) const
Checks whether two images are compatible or not.
Definition: ByteImage.cpp:212
int width
The width of the image in pixels.
Definition: ByteImage.h:257
GLenum GLsizei n
Definition: glext.h:4209
CBitmapSequenceCapture(const char *pFilePathBase, const char *pSecondFilePathBase=NULL)
bool LoadFromFile(const char *pFileName)
Loads an image from a file.
Definition: ByteImage.cpp:232
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
Definition: ByteImage.h:80
bool CopyImage(const CByteImage *pInputImage, CByteImage *pOutputImage, const MyRegion *pROI=0, bool bUseSameSize=false)
Copies one CByteImage to another.
int height
The height of the image in pixels.
Definition: ByteImage.h:264
ImageType
Enum specifying the supported image types.
Definition: ByteImage.h:86
void Rewind()
Set the image counter to the first image.
ImageType type
The type of the image.
Definition: ByteImage.h:292
CByteImage::ImageType GetType()
int nFirstImage
Number of the First Image.
bool CaptureImage(CByteImage **ppImages)


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:27