Commit 981bab9b authored by Matt Clarkson's avatar Matt Clarkson

Issue #66: Modify LoadPointSet to be similar to LoadModel3D, and provide...

Issue #66: Modify LoadPointSet to be similar to LoadModel3D, and provide associated unit test that checks loading with and without a newline at the end of the file.
parent 4111952c
......@@ -64,18 +64,27 @@ PointSet LoadPointSet(const std::string& fileName)
niftk::PointSet result;
while (!ifs.eof())
std::string line;
while (std::getline(ifs, line))
{
std::stringstream ss;
ss << line;
Point2D tmp;
ifs >> tmp.id;
ifs >> tmp.point.x;
ifs >> tmp.point.y;
ss >> tmp.id;
ss >> tmp.point.x;
ss >> tmp.point.y;
if (!ifs.bad() && !ifs.fail())
{
result.insert(IdPoint2D(tmp.id, tmp));
}
}
if (ifs.bad())
{
niftkNiftyCalThrow() << "Failed to read file:" << fileName << std::endl;
}
ifs.close();
return result;
......
......@@ -20,6 +20,7 @@ set(TEST_CASES
niftkPointUtilitiesTest
niftkPointDistortionTest
niftkLoadModelTest
niftkLoadPointsTest
niftkMatrixAverageTest
niftkStereoMatrixIOTest
niftkWarpChessboardByHomographyTest
......@@ -69,6 +70,8 @@ endforeach()
add_test(UNIT-NiftyCalExcept ${EXECUTABLE_OUTPUT_PATH}/niftkNiftyCalExceptionTest)
add_test(UNIT-LoadModelNewline ${EXECUTABLE_OUTPUT_PATH}/niftkLoadModelTest ${DATA_DIR}/Laparoscope/chessboard_13_10_3.txt 130)
add_test(UNIT-LoadModelNoNewline ${EXECUTABLE_OUTPUT_PATH}/niftkLoadModelTest ${DATA_DIR}/Laparoscope/chessboard_13_10_3_no_newline_at_end.txt 130)
add_test(UNIT-LoadPointsNewline ${EXECUTABLE_OUTPUT_PATH}/niftkLoadPointsTest ${DATA_DIR}/SimulationAprilTags/Left1.txt 35)
add_test(UNIT-LoadPointsNoNewline ${EXECUTABLE_OUTPUT_PATH}/niftkLoadPointsTest ${DATA_DIR}/SimulationAprilTags/Left1_no_newline.txt 35)
add_test(UNIT-PointUtils ${EXECUTABLE_OUTPUT_PATH}/niftkPointUtilitiesTest)
add_test(UNIT-PointDist ${EXECUTABLE_OUTPUT_PATH}/niftkPointDistortionTest ${DATA_DIR}/Laparoscope/calib.left.intrinsic.txt ${DATA_DIR}/Laparoscope/calib.left.distortion.txt 1920 1080 1098.3 267.087)
add_test(UNIT-InterpSurf1 ${EXECUTABLE_OUTPUT_PATH}/niftkInterpolateQuadraticSurfaceTest)
......
97 827.94 323.066
102 356.999 323.066
96 921.999 323.067
98 733.738 323.066
101 451.057 323.067
100 545.26 323.066
99 639.499 323.066
78 356.999 417.27
77 451.057 417.271
76 545.259 417.269
75 639.502 417.27
74 733.74 417.269
73 827.942 417.27
72 921.999 417.269
54 356.999 511.501
53 451.057 511.502
52 545.259 511.501
51 639.5 511.5
50 733.74 511.501
49 827.941 511.501
48 921.999 511.503
30 356.999 605.731
27 639.5 605.73
29 451.057 605.73
28 545.259 605.732
26 733.74 605.732
25 827.942 605.731
24 922 605.731
6 356.999 699.934
5 451.058 699.935
4 545.26 699.936
3 639.5 699.936
2 733.739 699.935
1 827.942 699.935
0 922 699.935
\ No newline at end of file
/*=============================================================================
NiftyCal: A software package for camera calibration.
Copyright (c) University College London (UCL). All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
See LICENSE.txt in the top level directory for details.
=============================================================================*/
#include "catch.hpp"
#include "niftkCatchMain.h"
#include <niftkNiftyCalTypes.h>
#include <niftkIOUtilities.h>
#include <niftkPointUtilities.h>
TEST_CASE( "Load 2D Points, check against expected number of points", "[IO]" ) {
int expectedNumberOfArguments = 3;
if (niftk::argc != expectedNumberOfArguments)
{
std::cerr << "Usage: niftkLoadPointsTest points.txt expectedNumberOfPoints" << std::endl;
REQUIRE( niftk::argc == expectedNumberOfArguments);
}
niftk::PointSet points = niftk::LoadPointSet(niftk::argv[1]);
int expectedNumberOfPoints = atoi(niftk::argv[2]);
REQUIRE(points.size() == expectedNumberOfPoints);
niftk::DumpPoints(std::cout, points);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment