diff --git a/lib/gpc/SintelOpticalFlow.hpp b/lib/gpc/SintelOpticalFlow.hpp index d73b9be..2372991 100644 --- a/lib/gpc/SintelOpticalFlow.hpp +++ b/lib/gpc/SintelOpticalFlow.hpp @@ -64,7 +64,6 @@ class SintelOpticalFlow { private: typedef typename gpc::training::Feature F; typedef typename F::GPCPatchTriplet GPCTriplet_t; - bool canDoExtraction = false; /** * @brief Checks dataset location sanity. @@ -107,9 +106,12 @@ class SintelOpticalFlow { // count images in first scene numFrames = countImages(); - canDoExtraction = true; + if (numFrames == 0) { + throw std::runtime_error( + "0 images found at specified dataset path"); + } } - SintelOpticalFlow() { canDoExtraction = false; } + SintelOpticalFlow() {} /** * @brief Extract training dataset made up of triplets (reference, positive, * negative) image patches. @@ -125,20 +127,12 @@ class SintelOpticalFlow { std::vector extractTrainingData(int numTripletsPerPair, int radiusLower, int radiusUpper) { - std::vector trainingData; - if (canDoExtraction == false) { - cout << "ERR: No path for Sintel dataset specified" << endl; - return trainingData; - } // Verify directory structure for Sintel Optical Flow dataset if (!(isDir(cleanDir) && isDir(finalDir) && isDir(flowDir) && isDir(oclDir) && isDir(invDir))) { - cout << "ERR: This does not look like the Sintel Optical Flow " - "dataset. " - "Please verify paths." - << endl; - return trainingData; + throw std::runtime_error("Directory structure invalid. "); } + std::vector trainingData; // cycle through scenes for (int sceneId = 0; sceneId < 20; sceneId++) { @@ -150,39 +144,29 @@ class SintelOpticalFlow { // Keep the necessary images ndb::Buffer oSrc, oTar, invSrc, invTar, imgL, imgR; // Get images and disparity - try { - int err = 0; - Eigen::MatrixXd u, v; - err |= getFlow(imgId, u, v); - err |= getBW(imgId, imgL, imgR); - err |= getOcclusion(imgId, oSrc); - err |= getOcclusion(imgId + 1, oTar); - err |= getInvalid(imgId, invSrc); - err |= getInvalid(imgId + 1, invTar); - if (err) - throw std::invalid_argument( - "could not open dataset file. Verify paths to " - "Sintel dataset " - "are set correctly."); - - // Get Keypoint coordinate lists for given image pair - getGroundTruthMatches(u, - v, - oSrc, - oTar, - invSrc, - invTar, - numTripletsPerPair, - radiusLower, - radiusUpper, - kptsL, - kptsR, - kptsN); - // Extract features under Feature requested - Feature.extractAllTriplets( - imgL, imgR, kptsL, kptsR, kptsN, trainingData); - } catch (const std::invalid_argument& e) { - } + Eigen::MatrixXd u, v; + getFlow(imgId, u, v); + getBW(imgId, imgL, imgR); + getOcclusion(imgId, oSrc); + getOcclusion(imgId + 1, oTar); + getInvalid(imgId, invSrc); + getInvalid(imgId + 1, invTar); + // Get Keypoint coordinate lists for given image pair + getGroundTruthMatches(u, + v, + oSrc, + oTar, + invSrc, + invTar, + numTripletsPerPair, + radiusLower, + radiusUpper, + kptsL, + kptsR, + kptsN); + // Extract features under Feature requested + Feature.extractAllTriplets( + imgL, imgR, kptsL, kptsR, kptsN, trainingData); } // image loop } // scene loop @@ -212,13 +196,10 @@ class SintelOpticalFlow { std::vector loadTrainingData(std::string path) { struct stat buffer; if (stat(path.c_str(), &buffer) != 0) { - std::vector emptyset; - cout << "ERR: No extracted training set found at given path" - << endl; - return emptyset; - } else { - return Feature.loadAllTriplets(path); + throw std::runtime_error( + "No extracted training set found at given path"); } + return Feature.loadAllTriplets(path); } private: @@ -330,7 +311,7 @@ class SintelOpticalFlow { return cnt; } else { /* could not open directory */ - std::cout << "ERR:couldn't open directory" << std::endl; + throw std::runtime_error("couldn't open directory"); return 0; } } @@ -347,8 +328,7 @@ class SintelOpticalFlow { sceneNames.end()) { selectedScene = sceneName; } else { - std::cout << "ERR:Scene with name (" << sceneName - << ") was not found" << std::endl; + throw std::runtime_error("Scene " + sceneName + " was not found"); } } @@ -375,12 +355,10 @@ class SintelOpticalFlow { * @param L left image * @param R right image * - * @return The bw. */ - int getBW(int id, ndb::Buffer& L, ndb::Buffer& R) { - int err1 = L.readPNG(makeFramePath(cleanDir, selectedScene, id)); - int err2 = R.readPNG(makeFramePath(cleanDir, selectedScene, id + 1)); - return err1 | err2; + void getBW(int id, ndb::Buffer& L, ndb::Buffer& R) { + L.readPNG(makeFramePath(cleanDir, selectedScene, id)); + R.readPNG(makeFramePath(cleanDir, selectedScene, id + 1)); } /** @@ -390,12 +368,10 @@ class SintelOpticalFlow { * @param L left image * @param R right image * - * @return 0 if success */ - int getRGB(int id, ndb::Buffer& L, ndb::Buffer& R) { - int err1 = L.readPNG(makeFramePath(cleanDir, selectedScene, id)); - int err2 = R.readPNG(makeFramePath(cleanDir, selectedScene, id + 1)); - return err1 | err2; + void getRGB(int id, ndb::Buffer& L, ndb::Buffer& R) { + L.readPNG(makeFramePath(cleanDir, selectedScene, id)); + R.readPNG(makeFramePath(cleanDir, selectedScene, id + 1)); } /** @@ -407,7 +383,7 @@ class SintelOpticalFlow { * * @return 0 if success */ - int getFlow(int id, Eigen::MatrixXd& uMat, Eigen::MatrixXd& vMat) { + void getFlow(int id, Eigen::MatrixXd& uMat, Eigen::MatrixXd& vMat) { std::ostringstream os; os << std::setw(4) << std::setfill('0') << id; std::string filename = @@ -422,8 +398,7 @@ class SintelOpticalFlow { uint8_t* fileptr = buf; size_t res = fread(buf, sizeof(uint8_t), length, readFile); if (res != length) { - cout << "Read error" << endl; - return 1; + throw std::runtime_error("Could not read flow file"); } fclose(readFile); @@ -440,7 +415,9 @@ class SintelOpticalFlow { uMat.resize(width, height); vMat.resize(width, height); - if (tag != 202021.25) cout << "TAG not found" << endl; + if (tag != 202021.25) { + throw std::runtime_error("Invalid .flo file (tag not found)"); + } // Read in flow data for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { @@ -454,7 +431,6 @@ class SintelOpticalFlow { } } delete[] fileptr; - return 0; } /** * @brief Gets the occlusion map @@ -462,10 +438,9 @@ class SintelOpticalFlow { * @param[in] id The image id * @param O image the occlusion map * - * @return 0 if success. */ - int getOcclusion(int id, ndb::Buffer& O) { - return O.readPNG(makeFramePath(oclDir, selectedScene, id)); + void getOcclusion(int id, ndb::Buffer& O) { + O.readPNG(makeFramePath(oclDir, selectedScene, id)); } /** * @brief Gets the invalid pixel map (out of frame) @@ -475,8 +450,8 @@ class SintelOpticalFlow { * * @return The invalid. */ - int getInvalid(int id, ndb::Buffer& I) { - return I.readPNG(makeFramePath(invDir, selectedScene, id)); + void getInvalid(int id, ndb::Buffer& I) { + I.readPNG(makeFramePath(invDir, selectedScene, id)); } /** diff --git a/lib/gpc/SintelStereo.hpp b/lib/gpc/SintelStereo.hpp index f50350a..3ffb9af 100644 --- a/lib/gpc/SintelStereo.hpp +++ b/lib/gpc/SintelStereo.hpp @@ -61,7 +61,6 @@ class SintelStereo { private: typedef typename gpc::training::Feature F; typedef typename F::GPCPatchTriplet GPCTriplet_t; - bool canDoExtraction = false; /** * @brief Checks dataset location sanity. * Not tested on windows @@ -102,9 +101,12 @@ class SintelStereo { // count images in first scene numFrames = countImages(); - canDoExtraction = true; + if (numFrames == 0) { + throw std::runtime_error( + "0 images found at specified dataset path"); + } } - SintelStereo() { canDoExtraction = false; } + SintelStereo() {} /** * @brief extract training dataset made up of triplets (reference, positive, * negative) image patches. @@ -119,18 +121,9 @@ class SintelStereo { int radiusLower, int radiusUpper) { std::vector trainingData; - if (canDoExtraction == false) { - cout << "ERR: No path for Sintel dataset specified" << endl; - return trainingData; - } - // Verify directory structure for Sintel Stereo dataset if (!(isDir(cleanLeftDir) && isDir(cleanRightDir) && isDir(dispDir) && isDir(oclDir) && isDir(oofDir))) { - cout << "ERR: This does not look like the Sintel Stereo dataset. " - "Please " - "verify paths." - << endl; - return trainingData; + throw std::runtime_error("Directory structure invalid. "); } // cycle through scenes @@ -145,34 +138,25 @@ class SintelStereo { // ndb::Buffer disp; ndb::RGBBuffer disp; // Get images and disparity - try { - int err = 0; - Eigen::MatrixXd u, v; - err |= getBW(imgId, imgL, imgR); - err |= getDisparity(imgId, disp); - err |= getOcclusion(imgId, occ); - err |= getInvalid(imgId, oof); - if (err) - throw std::invalid_argument( - "could not open dataset file. Verify paths to " - "Sintel dataset " - "are set correctly."); - - // Get Keypoint coordinate lists for given image pair - getGroundTruthMatches(disp, - oof, - occ, - numTripletsPerPair, - radiusLower, - radiusUpper, - kptsL, - kptsR, - kptsN); - // Extract features under Feature requested - Feature.extractAllTriplets( - imgL, imgR, kptsL, kptsR, kptsN, trainingData); - } catch (const std::invalid_argument& e) { - } + Eigen::MatrixXd u, v; + getBW(imgId, imgL, imgR); + getDisparity(imgId, disp); + getOcclusion(imgId, occ); + getInvalid(imgId, oof); + + // Get Keypoint coordinate lists for given image pair + getGroundTruthMatches(disp, + oof, + occ, + numTripletsPerPair, + radiusLower, + radiusUpper, + kptsL, + kptsR, + kptsN); + // Extract features under Feature requested + Feature.extractAllTriplets( + imgL, imgR, kptsL, kptsR, kptsN, trainingData); } // image loop } // scene loop std::mt19937 rng(12345); @@ -200,13 +184,10 @@ class SintelStereo { std::vector loadTrainingData(std::string path) { struct stat buffer; if (stat(path.c_str(), &buffer) != 0) { - std::vector emptyset; - cout << "ERR: No extracted training set found at given path" - << endl; - return emptyset; - } else { - return Feature.loadAllTriplets(path); + throw std::runtime_error( + "No extracted training set found at given path"); } + return Feature.loadAllTriplets(path); } private: @@ -270,8 +251,7 @@ class SintelStereo { return cnt; } else { /* could not open directory */ - std::cout << "ERR:couldn't open directory" << std::endl; - return 0; + throw std::runtime_error("couldn't open directory"); } } @@ -282,15 +262,12 @@ class SintelStereo { * * @return 0 if success */ - int selectScene(std::string sceneName) { + void selectScene(std::string sceneName) { if (std::find(sceneNames.begin(), sceneNames.end(), sceneName) != sceneNames.end()) { selectedScene = sceneName; - return 0; } else { - std::cout << "ERR:Scene with name (" << sceneName - << ") was not found" << std::endl; - return 1; + throw std::runtime_error("Scene " + sceneName + " was not found"); } } @@ -317,12 +294,10 @@ class SintelStereo { * @param L Left image * @param R Right image * - * @return The bw. */ - int getBW(int id, ndb::Buffer& L, ndb::Buffer& R) { - int err1 = L.readPNG(makeFramePath(cleanLeftDir, selectedScene, id)); - int err2 = R.readPNG(makeFramePath(cleanRightDir, selectedScene, id)); - return err1 | err2; + void getBW(int id, ndb::Buffer& L, ndb::Buffer& R) { + L.readPNG(makeFramePath(cleanLeftDir, selectedScene, id)); + R.readPNG(makeFramePath(cleanRightDir, selectedScene, id)); } /** @@ -332,12 +307,10 @@ class SintelStereo { * @param L Left image * @param R Right image * - * @return The rgb. */ - int getRGB(int id, ndb::Buffer& L, ndb::Buffer& R) { - int err1 = L.readPNG(makeFramePath(cleanLeftDir, selectedScene, id)); - int err2 = R.readPNG(makeFramePath(cleanRightDir, selectedScene, id)); - return err1 | err2; + void getRGB(int id, ndb::Buffer& L, ndb::Buffer& R) { + L.readPNG(makeFramePath(cleanLeftDir, selectedScene, id)); + R.readPNG(makeFramePath(cleanRightDir, selectedScene, id)); } /** @@ -346,10 +319,9 @@ class SintelStereo { * @param[in] id The image id * @param O occlusion image * - * @return 0 if succecss. */ - int getOcclusion(int id, ndb::Buffer& O) { - return O.readPNG(makeFramePath(oclDir, selectedScene, id)); + void getOcclusion(int id, ndb::Buffer& O) { + O.readPNG(makeFramePath(oclDir, selectedScene, id)); } /** * @brief Gets the disparity map @@ -357,10 +329,9 @@ class SintelStereo { * @param[in] id The image id * @param D disparity image * - * @return 0 if success. */ - int getDisparity(int id, ndb::RGBBuffer& D) { - return D.readPNGRGB(makeFramePath(dispDir, selectedScene, id)); + void getDisparity(int id, ndb::RGBBuffer& D) { + D.readPNGRGB(makeFramePath(dispDir, selectedScene, id)); } /** @@ -369,10 +340,9 @@ class SintelStereo { * @param[in] id The image id * @param I Invalid pixel map * - * @return 0 if success */ - int getInvalid(int id, ndb::Buffer& I) { - return I.readPNG(makeFramePath(oofDir, selectedScene, id)); + void getInvalid(int id, ndb::Buffer& I) { + I.readPNG(makeFramePath(oofDir, selectedScene, id)); } /** diff --git a/lib/gpc/buffer.hpp b/lib/gpc/buffer.hpp index d8f3a5a..dd6dce6 100644 --- a/lib/gpc/buffer.hpp +++ b/lib/gpc/buffer.hpp @@ -205,7 +205,7 @@ class __attribute__((aligned(32), packed)) Buffer // original sources provided by Guillaume Cottenceau under the X11 license // from http://zarb.org/~gc/html/libpng.html - int readPNG(std::string filename) { + void readPNG(std::string filename) { unsigned char header[8]; // 8 is the maximum size that can be checked png_byte colorType; png_byte bitDepth; @@ -217,34 +217,29 @@ class __attribute__((aligned(32), packed)) Buffer // open file and test for it being a png FILE* fp = fopen(filename.c_str(), "rb"); if (!fp) { - cout << "ERR: File" << filename - << " could not be opened for reading" << endl; - return 1; + throw std::runtime_error("File " + filename + + " could not be opened for reading"); } size_t res = fread(header, 1, 8, fp); if (png_sig_cmp(header, 0, 8)) { - cout << "ERR: File" << filename - << " is not recognized as a PNG file" << endl; - return 1; + throw std::runtime_error("File " + filename + + " is not recognized as a PNG file"); } // initialize stuff pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!pngPtr) { - cout << "ERR: png_create_read_struct failed" << endl; - return 1; + throw std::runtime_error("png_create_read_struct failed"); } infoPtr = png_create_info_struct(pngPtr); if (!infoPtr) { - cout << "ERR: png_create_info_struct failed" << endl; - return 1; + throw std::runtime_error("png_create_info_struct failed"); } if (setjmp(png_jmpbuf(pngPtr))) { - cout << "ERR: Error during init_io" << endl; - return 1; + throw std::runtime_error("Error during init_io"); } png_init_io(pngPtr, fp); @@ -266,8 +261,7 @@ class __attribute__((aligned(32), packed)) Buffer // read file if (setjmp(png_jmpbuf(pngPtr))) { - cout << "ERR: Error during read_image" << endl; - return 1; + throw std::runtime_error("Read error"); } rowPointers = (png_bytep*)malloc(sizeof(png_bytep) * height); @@ -327,16 +321,10 @@ class __attribute__((aligned(32), packed)) Buffer // boundary Base::conservativeResize(this->height, ALIGN16(this->width)); if (nChannels == 0 || nChannels == 4) { - cout << "ERR: found something other than gray or 3 channel color " - "image(" - << int(png_get_color_type(pngPtr, infoPtr)) << ") aborting!" - << endl; - - return 1; + throw std::runtime_error("found channel number != {1,3}"); } for (int y = 0; y < this->height; y++) free(rowPointers[y]); free(rowPointers); - return 0; } void writePNG(std::string filename) { png_byte colorType = PNG_COLOR_TYPE_GRAY; @@ -353,27 +341,34 @@ class __attribute__((aligned(32), packed)) Buffer img.conservativeResize(this->height, this->width); FILE* fp = fopen(filename.c_str(), "wb"); - if (!fp) - cout << "ERR: File" << filename - << " could not be opened for writing" << endl; + if (!fp) { + throw std::runtime_error("File " + filename + + " could not be opened for writing"); + } // init pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!pngPtr) cout << "ERR: png_create_write_struct failed" << endl; + if (!pngPtr) { + throw std::runtime_error("png_create_write_struct failed"); + } infoPtr = png_create_info_struct(pngPtr); - if (!infoPtr) cout << "ERR: png_create_info_struct failed" << endl; + if (!infoPtr) { + throw std::runtime_error("png_create_info_struct failed"); + } - if (setjmp(png_jmpbuf(pngPtr))) - cout << "ERR: Error during init_io" << endl; + if (setjmp(png_jmpbuf(pngPtr))) { + throw std::runtime_error("Error during init_io"); + } png_init_io(pngPtr, fp); // write header - if (setjmp(png_jmpbuf(pngPtr))) - cout << "ERR: Error during writing header" << endl; + if (setjmp(png_jmpbuf(pngPtr))) { + throw std::runtime_error("Error during writing header"); + } png_set_IHDR(pngPtr, infoPtr, @@ -388,8 +383,9 @@ class __attribute__((aligned(32), packed)) Buffer png_write_info(pngPtr, infoPtr); // write bytes - if (setjmp(png_jmpbuf(pngPtr))) - cout << "ERR: Error during writing bytes" << endl; + if (setjmp(png_jmpbuf(pngPtr))) { + throw std::runtime_error("Error during writing bytes"); + } // Allocate row pointers rowPointers = (png_bytep*)malloc(sizeof(png_bytep) * img.rows()); @@ -411,8 +407,9 @@ class __attribute__((aligned(32), packed)) Buffer png_write_image(pngPtr, rowPointers); // end write - if (setjmp(png_jmpbuf(pngPtr))) - cout << "ERR: Error during end of write" << endl; + if (setjmp(png_jmpbuf(pngPtr))) { + throw std::runtime_error("Error during end of write"); + } png_write_end(pngPtr, NULL); @@ -434,27 +431,34 @@ class __attribute__((aligned(32), packed)) Buffer img.conservativeResize(this->height, this->width); // create file FILE* fp = fopen(filename.c_str(), "wb"); - if (!fp) - cout << "ERR: File" << filename - << " could not be opened for writing" << endl; + if (!fp) { + throw std::runtime_error("File " + filename + + " could not be opened for writing"); + } // initialize stuff pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!pngPtr) cout << "ERR: png_create_write_struct failed" << endl; + if (!pngPtr) { + throw std::runtime_error("png_create_write_struct failed"); + } infoPtr = png_create_info_struct(pngPtr); - if (!infoPtr) cout << "ERR: png_create_info_struct failed" << endl; + if (!infoPtr) { + throw std::runtime_error("png_create_info_struct failed"); + } - if (setjmp(png_jmpbuf(pngPtr))) - cout << "ERR: Error during init_io" << endl; + if (setjmp(png_jmpbuf(pngPtr))) { + throw std::runtime_error("Error during init_io"); + } png_init_io(pngPtr, fp); // write header - if (setjmp(png_jmpbuf(pngPtr))) - cout << "ERR: Error during writing header" << endl; + if (setjmp(png_jmpbuf(pngPtr))) { + throw std::runtime_error("Error during writing header"); + } png_set_IHDR(pngPtr, infoPtr, @@ -470,7 +474,7 @@ class __attribute__((aligned(32), packed)) Buffer // write bytes if (setjmp(png_jmpbuf(pngPtr))) - cout << "ERR: Error during writing bytes" << endl; + throw std::runtime_error("Error during writing bytes"); // Allocate row pointers rowPointers = (png_bytep*)malloc(sizeof(png_bytep) * img.rows()); @@ -495,7 +499,7 @@ class __attribute__((aligned(32), packed)) Buffer // end write if (setjmp(png_jmpbuf(pngPtr))) - cout << "ERR: Error during end of write" << endl; + throw std::runtime_error("Error during end of write"); png_write_end(pngPtr, NULL); @@ -790,7 +794,7 @@ class __attribute__((aligned(32), packed)) Buffer class RGBBuffer : public Buffer { public: RGBBuffer() {} - int readPNGRGB(std::string filename) { + void readPNGRGB(std::string filename) { unsigned char header[8]; // 8 is the maximum size that can be checked png_byte colorType; png_byte bitDepth; @@ -802,33 +806,28 @@ class RGBBuffer : public Buffer { // open file and test for it being a png FILE* fp = fopen(filename.c_str(), "rb"); if (!fp) { - cout << "ERR: File" << filename - << " could not be opened for reading" << endl; - return 1; + throw runtime_error("File " + filename + + " could not be opened for reading"); } size_t res = fread(header, 1, 8, fp); if (png_sig_cmp(header, 0, 8)) { - cout << "ERR: File" << filename - << " is not recognized as a PNG file" << endl; - return 1; + throw runtime_error("File " + filename + + " could not be opened for reading"); } pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!pngPtr) { - cout << "ERR: png_create_read_struct failed" << endl; - return 1; + throw runtime_error("png_create_read_struct failed"); } infoPtr = png_create_info_struct(pngPtr); if (!infoPtr) { - cout << "ERR: png_create_info_struct failed" << endl; - return 1; + throw runtime_error("png_create_info_struct failed"); } if (setjmp(png_jmpbuf(pngPtr))) { - cout << "ERR: Error during init_io" << endl; - return 1; + throw runtime_error("Error during init_io"); } png_init_io(pngPtr, fp); @@ -847,8 +846,7 @@ class RGBBuffer : public Buffer { png_read_update_info(pngPtr, infoPtr); if (setjmp(png_jmpbuf(pngPtr))) { - cout << "ERR: Error during read_image" << endl; - return 1; + throw runtime_error("Read error"); } rowPointers = (png_bytep*)malloc(sizeof(png_bytep) * height); @@ -892,16 +890,10 @@ class RGBBuffer : public Buffer { // boundary Base::conservativeResize(this->height, ALIGN16(this->width)); if (nChannels == 0 || nChannels == 4) { - cout << "ERR: found something other than gray or 3 channel color " - "image(" - << int(png_get_color_type(pngPtr, infoPtr)) << ") aborting!" - << endl; - - return 1; + throw runtime_error("channel number not 1 or 3"); } for (int y = 0; y < this->height; y++) free(rowPointers[y]); free(rowPointers); - return 0; } }; Buffer getDisparityVisualization( diff --git a/lib/gpc/hashmatch.hpp b/lib/gpc/hashmatch.hpp index be1320d..6bad533 100644 --- a/lib/gpc/hashmatch.hpp +++ b/lib/gpc/hashmatch.hpp @@ -103,7 +103,6 @@ class OrderedLinkedList { m_size++; } else { // find insertion point ListElement* next; - // compile error when i try to do these on one line. wow. ListElement* last = NULL; next = root; diff --git a/samples/sparsematch.cpp b/samples/sparsematch.cpp index cf5932a..ed43016 100644 --- a/samples/sparsematch.cpp +++ b/samples/sparsematch.cpp @@ -42,10 +42,9 @@ int main(int argc, char** argv) { // <100K descriptors // Load images - if (simg.readPNG(leftImgPath) || timg.readPNG(rightImgPath)) { - cout << "No image data \n"; - return -1; - } + simg.readPNG(leftImgPath); + timg.readPNG(rightImgPath); + // Get learned filter for the given image dimensions. GPCForest_t::FilterMask fm = forest.readForest(forestPath, simg.cols(), simg.rows()); diff --git a/tests/test_single_matching.cpp b/tests/test_single_matching.cpp index f6a2e8c..e9e6a75 100644 --- a/tests/test_single_matching.cpp +++ b/tests/test_single_matching.cpp @@ -31,9 +31,8 @@ TEST(Approval, Inference) // <100K descriptors // Load images - if (simg.readPNG(leftImgPath) || timg.readPNG(rightImgPath)) { - throw std::runtime_error("Image load failed"); - } + simg.readPNG(leftImgPath); + timg.readPNG(rightImgPath); // Get learned filter for the given image dimensions. GPCForest_t::FilterMask fm = forest.readForest(forestPath, simg.cols(), simg.rows());