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 "BitmapCapture.h"
00049
00050 #include "Image/ImageProcessor.h"
00051 #include "Image/ByteImage.h"
00052
00053
00054
00055
00056
00057
00058
00059 CBitmapCapture::CBitmapCapture(const char *pFilePath, const char *pSecondFilePath)
00060 {
00061 m_sFilePath = "";
00062 m_sFilePath += pFilePath;
00063
00064 m_sSecondFilePath = "";
00065 m_pLeftImage = new CByteImage();
00066
00067 if (pSecondFilePath)
00068 {
00069 m_sSecondFilePath += pSecondFilePath;
00070 m_bStereo = true;
00071 m_pRightImage = new CByteImage();
00072 }
00073 else
00074 {
00075 m_pRightImage = 0;
00076 m_bStereo = false;
00077 }
00078
00079 m_pLeftImageRGB24Split = 0;
00080 m_pRightImageRGB24Split = 0;
00081
00082 m_bOK = false;
00083 }
00084
00085 CBitmapCapture::~CBitmapCapture()
00086 {
00087 if (m_pLeftImage)
00088 delete m_pLeftImage;
00089
00090 if (m_pRightImage)
00091 delete m_pRightImage;
00092
00093 if (m_pLeftImageRGB24Split)
00094 delete m_pLeftImageRGB24Split;
00095
00096 if (m_pRightImageRGB24Split)
00097 delete m_pRightImageRGB24Split;
00098 }
00099
00100
00101
00102
00103
00104
00105 int CBitmapCapture::GetWidth()
00106 {
00107 return m_bOK ? m_pLeftImage->width : -1;
00108 }
00109
00110 int CBitmapCapture::GetHeight()
00111 {
00112 return m_bOK ? m_pLeftImage->height : -1;
00113 }
00114
00115 CByteImage::ImageType CBitmapCapture::GetType()
00116 {
00117 return m_bOK ? m_pLeftImage->type : (CByteImage::ImageType) -1;
00118 }
00119
00120
00121 bool CBitmapCapture::OpenCamera()
00122 {
00123 m_bOK = false;
00124
00125 if (!m_pLeftImage->LoadFromFile(m_sFilePath.c_str()))
00126 return false;
00127
00128 if (m_pLeftImage->type == CByteImage::eRGB24)
00129 {
00130 if (m_pLeftImageRGB24Split)
00131 delete m_pLeftImageRGB24Split;
00132
00133 m_pLeftImageRGB24Split = new CByteImage(m_pLeftImage->width, m_pLeftImage->height, CByteImage::eRGB24Split);
00134 ImageProcessor::ConvertImage(m_pLeftImage, m_pLeftImageRGB24Split);
00135 }
00136
00137 if (m_bStereo)
00138 {
00139 if (!m_pRightImage->LoadFromFile(m_sSecondFilePath.c_str()))
00140 return false;
00141
00142 if (m_pLeftImage->width != m_pRightImage->width || m_pLeftImage->height != m_pRightImage->height)
00143 return false;
00144
00145 if (m_pRightImage->type == CByteImage::eRGB24)
00146 {
00147 if (m_pRightImageRGB24Split)
00148 delete m_pRightImageRGB24Split;
00149
00150 m_pRightImageRGB24Split = new CByteImage(m_pRightImage->width, m_pRightImage->height, CByteImage::eRGB24Split);
00151 ImageProcessor::ConvertImage(m_pRightImage, m_pRightImageRGB24Split);
00152 }
00153 }
00154
00155 m_bOK = true;
00156
00157 return true;
00158 }
00159
00160 void CBitmapCapture::CloseCamera()
00161 {
00162 }
00163
00164 bool CBitmapCapture::CaptureImage(CByteImage **ppImages)
00165 {
00166 if (!m_bOK)
00167 return false;
00168
00169 if (ppImages[0]->IsCompatible(m_pLeftImage))
00170 ImageProcessor::CopyImage(m_pLeftImage, ppImages[0]);
00171 else if (ppImages[0]->IsCompatible(m_pLeftImageRGB24Split))
00172 ImageProcessor::CopyImage(m_pLeftImageRGB24Split, ppImages[0]);
00173 else
00174 {
00175 printf("error: images are not compatible in CBitmapCapture::CaptureImage\n");
00176 return false;
00177 }
00178
00179 if (m_bStereo)
00180 {
00181 if (ppImages[1]->IsCompatible(m_pRightImage))
00182 ImageProcessor::CopyImage(m_pRightImage, ppImages[1]);
00183 else if (ppImages[1]->IsCompatible(m_pRightImageRGB24Split))
00184 ImageProcessor::CopyImage(m_pRightImageRGB24Split, ppImages[1]);
00185 else
00186 {
00187 printf("error: images are not compatible in CBitmapCapture::CaptureImage\n");
00188 return false;
00189 }
00190 }
00191
00192 return true;
00193 }
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