Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include <new>
00047
00048 #include "BitmapSequenceCapture.h"
00049 #include "Image/ImageProcessor.h"
00050 #include "Image/ByteImage.h"
00051
00052 #include <stdio.h>
00053 #include <stdlib.h>
00054
00055
00056
00057
00058
00059
00060
00061 CBitmapSequenceCapture::CBitmapSequenceCapture(const char *pFirstFilePathLeft, const char *pFirstFilePathBaseRight)
00062 {
00063 m_sFilePathBaseLeft = "";
00064 m_sFilePathBaseRight = "";
00065 m_sFirstFilePathLeft = "";
00066 m_sFirstFilePathRight = "";
00067
00068 m_sFirstFilePathLeft += pFirstFilePathLeft;
00069 m_pLeftImage = new CByteImage();
00070
00071 if (pFirstFilePathBaseRight)
00072 {
00073 m_sFirstFilePathRight += pFirstFilePathBaseRight;
00074 m_pRightImage = new CByteImage();
00075 m_bStereo = true;
00076 }
00077 else
00078 {
00079 m_pRightImage = 0;
00080 m_bStereo = false;
00081 }
00082
00083 m_bOK = false;
00084 n = 0;
00085 m_nFiguresLeft = 0;
00086 m_nFiguresRight = 0;
00087
00088 m_sFileExtention = "";
00089 nFirstImage = 0;
00090 }
00091
00092 CBitmapSequenceCapture::~CBitmapSequenceCapture()
00093 {
00094 if (m_pLeftImage)
00095 delete m_pLeftImage;
00096
00097 if (m_pRightImage)
00098 delete m_pRightImage;
00099 }
00100
00101
00102
00103
00104
00105
00106 int CBitmapSequenceCapture::GetWidth()
00107 {
00108 return m_bOK ? m_pLeftImage->width : -1;
00109 }
00110
00111 int CBitmapSequenceCapture::GetHeight()
00112 {
00113 return m_bOK ? m_pLeftImage->height : -1;
00114 }
00115
00116 CByteImage::ImageType CBitmapSequenceCapture::GetType()
00117 {
00118 return m_bOK ? m_pLeftImage->type : (CByteImage::ImageType) -1;
00119 }
00120
00121
00122 bool CBitmapSequenceCapture::OpenCamera()
00123 {
00124 m_bOK = false;
00125 m_nFiguresLeft = 0;
00126 m_nFiguresRight = 0;
00127 n = 0;
00128 nFirstImage = 0;
00129
00130 const char *pFirstFilePathLeft = m_sFirstFilePathLeft.c_str();
00131 bool bLookForFigures = false;
00132
00133 const int nLengthMinusOne = int(m_sFirstFilePathLeft.length()) - 1;
00134 for (int i = nLengthMinusOne; i >= 0; i--)
00135 {
00136 if (pFirstFilePathLeft[i] == '.')
00137 {
00138 bLookForFigures = true;
00139 m_sFileExtention = "";
00140 m_sFileExtention += m_sFirstFilePathLeft.substr(i + 1, 3);
00141 }
00142 else if (bLookForFigures)
00143 {
00144 if (pFirstFilePathLeft[i] < '0' || pFirstFilePathLeft[i] > '9')
00145 {
00146 m_sFilePathBaseLeft = "";
00147 m_sFilePathBaseLeft += pFirstFilePathLeft;
00148 m_sFilePathBaseLeft[i + 1] = '\0';
00149 n = atoi(pFirstFilePathLeft + i + 1);
00150 nFirstImage = n;
00151 break;
00152 }
00153 else
00154 m_nFiguresLeft++;
00155 }
00156 }
00157
00158 if (!m_pLeftImage->LoadFromFile(m_sFirstFilePathLeft.c_str()))
00159 return false;
00160
00161 if (m_bStereo)
00162 {
00163 const char *pFirstFilePathRight = m_sFirstFilePathRight.c_str();
00164 bool bLookForFigures = false;
00165
00166 const int nLengthMinusOne = int(m_sFirstFilePathRight.length()) - 1;
00167 for (int i = nLengthMinusOne; i >= 0; i--)
00168 {
00169 if (pFirstFilePathRight[i] == '.')
00170 bLookForFigures = true;
00171 else if (bLookForFigures)
00172 {
00173 if (pFirstFilePathRight[i] < '0' || pFirstFilePathRight[i] > '9')
00174 {
00175 m_sFilePathBaseRight = "";
00176 m_sFilePathBaseRight += pFirstFilePathRight;
00177 m_sFilePathBaseRight[i + 1] = '\0';
00178 if (n != atoi(pFirstFilePathRight + i + 1))
00179 return false;
00180 break;
00181 }
00182 else
00183 m_nFiguresRight++;
00184 }
00185 }
00186
00187 if (!m_pRightImage->LoadFromFile(m_sFirstFilePathRight.c_str()))
00188 return false;
00189
00190 if (m_nFiguresLeft != m_nFiguresRight || m_pLeftImage->width != m_pRightImage->width || m_pLeftImage->height != m_pRightImage->height)
00191 return false;
00192 }
00193
00194 m_bOK = true;
00195
00196 return true;
00197 }
00198
00199 void CBitmapSequenceCapture::CloseCamera()
00200 {
00201 }
00202
00203 bool CBitmapSequenceCapture::CaptureImage(CByteImage **ppImages)
00204 {
00205 if (!m_bOK)
00206 return false;
00207
00208 char szTemp[100];
00209 char szTemp2[1000];
00210
00211 sprintf(szTemp, "%%s%%.%ii.%s", m_nFiguresLeft, m_sFileExtention.c_str());
00212 sprintf(szTemp2, szTemp, m_sFilePathBaseLeft.c_str(), n);
00213
00214 if (!m_pLeftImage->LoadFromFile(szTemp2))
00215 return false;
00216
00217 if (!m_pLeftImage->IsCompatible(ppImages[0]))
00218 {
00219 printf("error: read image is not compatible in CBitmapSequenceCapture::CaptureImage\n");
00220 return false;
00221 }
00222
00223 ImageProcessor::CopyImage(m_pLeftImage, ppImages[0]);
00224
00225 if (m_bStereo)
00226 {
00227 sprintf(szTemp2, szTemp, m_sFilePathBaseRight.c_str(), n);
00228 if (!m_pRightImage->LoadFromFile(szTemp2))
00229 return false;
00230
00231 if (!m_pRightImage->IsCompatible(ppImages[1]))
00232 {
00233 printf("error: read image is not compatible in CBitmapSequenceCapture::CaptureImage (right image)\n");
00234 return false;
00235 }
00236
00237 ImageProcessor::CopyImage(m_pRightImage, ppImages[1]);
00238 }
00239
00240 n++;
00241
00242 return true;
00243 }
00244
00245 void CBitmapSequenceCapture::Rewind()
00246 {
00247 n = nFirstImage;
00248 }
asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Thu Jun 6 2019 21:46:57