Permalink
Browse files

Better stream read excpt msg.

Fixed unit test for 3D scan when built w/o OpenCV.
  • Loading branch information...
jlblancoc committed Aug 27, 2018
1 parent 5499702 commit 01a69951d721c2e42cc4c4f9a5285518b55d2166
Showing with 29 additions and 19 deletions.
  1. +15 −16 libs/img/src/CImage.cpp
  2. +6 −1 libs/obs/src/CObservation3DRangeScan_unittest.cpp
  3. +8 −2 libs/serialization/src/CArchive.cpp
@@ -466,11 +466,10 @@ unsigned char* CImage::operator()(
if (row >= (unsigned int)ipl->height || col >= (unsigned int)ipl->width ||
channel >= (unsigned int)ipl->nChannels)
{
THROW_EXCEPTION(
format(
"Pixel coordinates/channel out of bounds: row=%u/%u col=%u/%u "
"chan=%u/%u",
row, ipl->height, col, ipl->width, channel, ipl->nChannels));
THROW_EXCEPTION(format(
"Pixel coordinates/channel out of bounds: row=%u/%u col=%u/%u "
"chan=%u/%u",
row, ipl->height, col, ipl->width, channel, ipl->nChannels));
}
#endif
@@ -1346,8 +1345,8 @@ void CImage::update_patch(
for (unsigned int i = 0; i < patch.getHeight(); i++)
{
memcpy(
&ipl_int->imageData[(i + row_) * ipl_int->widthStep +
col_ * ipl_int->nChannels],
&ipl_int->imageData
[(i + row_) * ipl_int->widthStep + col_ * ipl_int->nChannels],
&ipl_ext->imageData[i * ipl_ext->widthStep], ipl_ext->widthStep);
}
#endif
@@ -1369,11 +1368,10 @@ void CImage::extract_patch(
if ((ipl_int->width < (int)(col_ + col_num)) ||
(ipl_int->height < (int)(row_ + row_num)))
{
THROW_EXCEPTION(
format(
"Trying to extract patch out of image boundaries: Image "
"size=%ix%i, Patch size=%ux%u, extraction location=(%u,%u)",
ipl_int->width, ipl_int->height, col_num, row_num, col_, row_))
THROW_EXCEPTION(format(
"Trying to extract patch out of image boundaries: Image "
"size=%ix%i, Patch size=%ux%u, extraction location=(%u,%u)",
ipl_int->width, ipl_int->height, col_num, row_num, col_, row_))
}
patch.resize(col_num, row_num, ((IplImage*)img)->nChannels, true);
@@ -1384,8 +1382,8 @@ void CImage::extract_patch(
{
memcpy(
&ipl_ext->imageData[i * ipl_ext->widthStep],
&ipl_int->imageData[(i + row_) * ipl_int->widthStep +
col_ * ipl_int->nChannels],
&ipl_int->imageData
[(i + row_) * ipl_int->widthStep + col_ * ipl_int->nChannels],
ipl_ext->widthStep);
}
@@ -1522,8 +1520,9 @@ void CImage::cross_correlation(
{
memcpy(
&aux->imageData[i * aux->widthStep],
&im->imageData[(i + y_search_ini) * im->widthStep +
x_search_ini * im->nChannels],
&im->imageData
[(i + y_search_ini) * im->widthStep +
x_search_ini * im->nChannels],
aux->width * aux->nChannels); // widthStep); <-- JLBC:
// widthstep SHOULD NOT be used
// as the length of each row (the
@@ -15,7 +15,7 @@
#include <mrpt/io/CFileGZInputStream.h>
#include <mrpt/containers/copy_container_typecasting.h>
#include <mrpt/math/CHistogram.h>
#include <mrpt/config.h>
#include <gtest/gtest.h>
// Defined in tests/test_main.cpp
@@ -197,6 +197,10 @@ TEST(CObservation3DRangeScan, Project3D_filterMax)
}
}
// We need OPENCV to read the image internal to CObservation3DRangeScan,
// so skip this test if built without opencv.
#if MRPT_HAS_OPENCV
TEST(CObservation3DRangeScan, LoadAndCheckFloorPoints)
{
const string rawlog_fil = MRPT_GLOBAL_UNITTEST_SRC_DIR +
@@ -273,3 +277,4 @@ TEST(CObservation3DRangeScan, LoadAndCheckFloorPoints)
EXPECT_LE(bin_count[18], 700);
EXPECT_LE(bin_count[19], 20);
}
#endif
@@ -508,9 +508,15 @@ void CArchive::internal_ReadObject(
{
throw;
}
catch (std::exception&)
catch (CExceptionEOF&)
{
THROW_TYPED_EXCEPTION("Cannot read object due to EOF", CExceptionEOF);
throw;
}
catch (std::exception& e)
{
THROW_STACKED_EXCEPTION_CUSTOM_MSG2(
e, "Exception while parsing typed object '%s' from stream!\n",
strClassName.c_str());
}
catch (...)
{

0 comments on commit 01a6995

Please sign in to comment.