diff --git a/ports/theia/CONTROL b/ports/theia/CONTROL index 56e2181a31..06dcc80c80 100644 --- a/ports/theia/CONTROL +++ b/ports/theia/CONTROL @@ -1,4 +1,4 @@ -Source: theia -Version: 0.7-d15154a-1 -Build-Depends: flann, cereal, ceres, openimageio, glew, freeglut -Description: An open source library for multiview geometry and structure from motion +Source: theia +Version: 0.7-d15154a-2 +Build-Depends: flann, cereal, ceres[suitesparse], openimageio, glew, freeglut +Description: An open source library for multiview geometry and structure from motion diff --git a/ports/theia/fix-oiio.patch b/ports/theia/fix-oiio.patch new file mode 100644 index 0000000000..7cba45db73 --- /dev/null +++ b/ports/theia/fix-oiio.patch @@ -0,0 +1,391 @@ +diff --git a/src/theia/image/image.cc b/src/theia/image/image.cc +index df6aba4..5e2b8dc 100644 +--- a/src/theia/image/image.cc ++++ b/src/theia/image/image.cc +@@ -60,18 +60,18 @@ FloatImage::FloatImage(const FloatImage& image_to_copy) { + } + + FloatImage::FloatImage(const int width, const int height, const int channels) { +- OpenImageIO::ImageSpec image_spec(width, height, channels, +- OpenImageIO::TypeDesc::FLOAT); ++ OIIO_NAMESPACE::ImageSpec image_spec(width, height, channels, ++ OIIO_NAMESPACE::TypeDesc::FLOAT); + image_.reset(image_spec); + } + + FloatImage::FloatImage(const int width, const int height, const int channels, + float* buffer) +- : image_(OpenImageIO::ImageSpec(width, height, channels, +- OpenImageIO::TypeDesc::FLOAT), ++ : image_(OIIO_NAMESPACE::ImageSpec(width, height, channels, ++ OIIO_NAMESPACE::TypeDesc::FLOAT), + reinterpret_cast(buffer)) {} + +-FloatImage::FloatImage(const OpenImageIO::ImageBuf& image) { ++FloatImage::FloatImage(const OIIO_NAMESPACE::ImageBuf& image) { + image_.copy(image); + } + +@@ -80,11 +80,11 @@ FloatImage& FloatImage::operator=(const FloatImage& image2) { + return *this; + } + +-OpenImageIO::ImageBuf& FloatImage::GetOpenImageIOImageBuf() { ++OIIO_NAMESPACE::ImageBuf& FloatImage::GetOpenImageIOImageBuf() { + return image_; + } + +-const OpenImageIO::ImageBuf& FloatImage::GetOpenImageIOImageBuf() const { ++const OIIO_NAMESPACE::ImageBuf& FloatImage::GetOpenImageIOImageBuf() const { + return image_; + } + +@@ -110,7 +110,7 @@ void FloatImage::SetXY(const int x, + DCHECK_LT(c, Channels()); + + // Set the ROI to be the precise pixel location in the correct channel. +- OpenImageIO::ImageBuf::Iterator it(image_, x, y, 0); ++ OIIO_NAMESPACE::ImageBuf::Iterator it(image_, x, y, 0); + it[c] = value; + } + +@@ -195,9 +195,9 @@ void FloatImage::ConvertToGrayscaleImage() { + // Compute luminance via a weighted sum of R,G,B (assuming Rec709 primaries + // and a linear scale) + const float luma_weights[3] = {.2126, .7152, .0722}; +- OpenImageIO::ImageBuf source = image_; ++ OIIO_NAMESPACE::ImageBuf source = image_; + image_.clear(); +- OpenImageIO::ImageBufAlgo::channel_sum(image_, source, luma_weights); ++ OIIO_NAMESPACE::ImageBufAlgo::channel_sum(image_, source, luma_weights); + } + + void FloatImage::ConvertToRGBImage() { +@@ -207,13 +207,13 @@ void FloatImage::ConvertToRGBImage() { + } + + // Copy the single grayscale channel into r, g, and b. +- const OpenImageIO::ImageBuf source(image_); +- OpenImageIO::ImageSpec image_spec(Width(), Height(), 3, +- OpenImageIO::TypeDesc::FLOAT); ++ const OIIO_NAMESPACE::ImageBuf source(image_); ++ OIIO_NAMESPACE::ImageSpec image_spec(Width(), Height(), 3, ++ OIIO_NAMESPACE::TypeDesc::FLOAT); + image_.reset(image_spec); +- OpenImageIO::ImageBufAlgo::paste(image_, 0, 0, 0, 0, source); +- OpenImageIO::ImageBufAlgo::paste(image_, 0, 0, 0, 1, source); +- OpenImageIO::ImageBufAlgo::paste(image_, 0, 0, 0, 2, source); ++ OIIO_NAMESPACE::ImageBufAlgo::paste(image_, 0, 0, 0, 0, source); ++ OIIO_NAMESPACE::ImageBufAlgo::paste(image_, 0, 0, 0, 1, source); ++ OIIO_NAMESPACE::ImageBufAlgo::paste(image_, 0, 0, 0, 2, source); + } + + FloatImage FloatImage::AsGrayscaleImage() const { +@@ -238,12 +238,12 @@ FloatImage FloatImage::AsRGBImage() const { + } + + void FloatImage::ScalePixels(float scale) { +- OpenImageIO::ImageBufAlgo::mul(image_, image_, scale); ++ OIIO_NAMESPACE::ImageBufAlgo::mul(image_, image_, scale); + } + + void FloatImage::Read(const std::string& filename) { + image_.reset(filename); +- image_.read(0, 0, true, OpenImageIO::TypeDesc::FLOAT); ++ image_.read(0, 0, true, OIIO_NAMESPACE::TypeDesc::FLOAT); + } + + void FloatImage::Write(const std::string& filename) const { +@@ -259,19 +259,19 @@ const float* FloatImage::Data() const { + + FloatImage FloatImage::ComputeGradientX() const { + float sobel_filter_x[9] = {-.125, 0, .125, -.25, 0, .25, -.125, 0, .125}; +- OpenImageIO::ImageSpec spec(3, 3, 1, OpenImageIO::TypeDesc::FLOAT); +- OpenImageIO::ImageBuf kernel_x(spec, sobel_filter_x); +- OpenImageIO::ImageBuf gradient_x; +- OpenImageIO::ImageBufAlgo::convolve(gradient_x, image_, kernel_x, false); ++ OIIO_NAMESPACE::ImageSpec spec(3, 3, 1, OIIO_NAMESPACE::TypeDesc::FLOAT); ++ OIIO_NAMESPACE::ImageBuf kernel_x(spec, sobel_filter_x); ++ OIIO_NAMESPACE::ImageBuf gradient_x; ++ OIIO_NAMESPACE::ImageBufAlgo::convolve(gradient_x, image_, kernel_x, false); + return FloatImage(gradient_x); + } + + FloatImage FloatImage::ComputeGradientY() const { + float sobel_filter_y[9] = {-.125, -.25, -.125, 0, 0, 0, .125, .25, .125}; +- OpenImageIO::ImageSpec spec(3, 3, 1, OpenImageIO::TypeDesc::FLOAT); +- OpenImageIO::ImageBuf kernel_y(spec, sobel_filter_y); +- OpenImageIO::ImageBuf gradient_y; +- OpenImageIO::ImageBufAlgo::convolve(gradient_y, image_, kernel_y, false); ++ OIIO_NAMESPACE::ImageSpec spec(3, 3, 1, OIIO_NAMESPACE::TypeDesc::FLOAT); ++ OIIO_NAMESPACE::ImageBuf kernel_y(spec, sobel_filter_y); ++ OIIO_NAMESPACE::ImageBuf gradient_y; ++ OIIO_NAMESPACE::ImageBufAlgo::convolve(gradient_y, image_, kernel_y, false); + return FloatImage(gradient_y); + } + +@@ -280,28 +280,28 @@ FloatImage FloatImage::ComputeGradient() const { + float sobel_filter_x[9] = {-.125, 0, .125, -.25, 0, .25, -.125, 0, .125}; + float sobel_filter_y[9] = {-.125, -.25, -.125, 0, 0, 0, .125, .25, .125}; + +- OpenImageIO::ImageSpec spec(3, 3, 1, OpenImageIO::TypeDesc::FLOAT); +- OpenImageIO::ImageBuf kernel_x(spec, sobel_filter_x); +- OpenImageIO::ImageBuf kernel_y(spec, sobel_filter_y); ++ OIIO_NAMESPACE::ImageSpec spec(3, 3, 1, OIIO_NAMESPACE::TypeDesc::FLOAT); ++ OIIO_NAMESPACE::ImageBuf kernel_x(spec, sobel_filter_x); ++ OIIO_NAMESPACE::ImageBuf kernel_y(spec, sobel_filter_y); + +- OpenImageIO::ImageBuf gradient, gradient_x, gradient_y; +- OpenImageIO::ImageBufAlgo::convolve(gradient_x, image_, kernel_x, false); +- OpenImageIO::ImageBufAlgo::abs(gradient_x, gradient_x); +- OpenImageIO::ImageBufAlgo::convolve(gradient_y, image_, kernel_y, false); +- OpenImageIO::ImageBufAlgo::abs(gradient_y, gradient_y); +- OpenImageIO::ImageBufAlgo::add(gradient, gradient_x, gradient_y); ++ OIIO_NAMESPACE::ImageBuf gradient, gradient_x, gradient_y; ++ OIIO_NAMESPACE::ImageBufAlgo::convolve(gradient_x, image_, kernel_x, false); ++ OIIO_NAMESPACE::ImageBufAlgo::abs(gradient_x, gradient_x); ++ OIIO_NAMESPACE::ImageBufAlgo::convolve(gradient_y, image_, kernel_y, false); ++ OIIO_NAMESPACE::ImageBufAlgo::abs(gradient_y, gradient_y); ++ OIIO_NAMESPACE::ImageBufAlgo::add(gradient, gradient_x, gradient_y); + + return FloatImage(gradient); + } + + void FloatImage::ApproximateGaussianBlur(const double sigma) { +- OpenImageIO::ImageBuf kernel; +- OpenImageIO::ImageBufAlgo::make_kernel(kernel, "gaussian", 5.0f, 5.0f); +- OpenImageIO::ImageBufAlgo::convolve(image_, image_, kernel); ++ OIIO_NAMESPACE::ImageBuf kernel; ++ OIIO_NAMESPACE::ImageBufAlgo::make_kernel(kernel, "gaussian", 5.0f, 5.0f); ++ OIIO_NAMESPACE::ImageBufAlgo::convolve(image_, image_, kernel); + } + + void FloatImage::MedianFilter(const int patch_width) { +- CHECK(OpenImageIO::ImageBufAlgo::median_filter(image_, image_, patch_width)); ++ CHECK(OIIO_NAMESPACE::ImageBufAlgo::median_filter(image_, image_, patch_width)); + } + + void FloatImage::Integrate(FloatImage* integral) const { +@@ -327,14 +327,14 @@ void FloatImage::Resize(int new_width, int new_height) { + // If the image has not been initialized then initialize it with the image + // spec. Otherwise resize the image and interpolate pixels accordingly. + if (!image_.initialized()) { +- OpenImageIO::ImageSpec image_spec(new_width, new_height, Channels(), +- OpenImageIO::TypeDesc::FLOAT); ++ OIIO_NAMESPACE::ImageSpec image_spec(new_width, new_height, Channels(), ++ OIIO_NAMESPACE::TypeDesc::FLOAT); + image_.reset(image_spec); + } else { +- OpenImageIO::ROI roi(0, new_width, 0, new_height, 0, 1, 0, Channels()); +- OpenImageIO::ImageBuf dst; +- CHECK(OpenImageIO::ImageBufAlgo::resize(dst, image_, nullptr, roi)) +- << OpenImageIO::geterror(); ++ OIIO_NAMESPACE::ROI roi(0, new_width, 0, new_height, 0, 1, 0, Channels()); ++ OIIO_NAMESPACE::ImageBuf dst; ++ CHECK(OIIO_NAMESPACE::ImageBufAlgo::resize(dst, image_, nullptr, roi)) ++ << OIIO_NAMESPACE::geterror(); + image_.copy(dst); + } + } +diff --git a/src/theia/image/image.h b/src/theia/image/image.h +index e4f22cc..29122d2 100644 +--- a/src/theia/image/image.h ++++ b/src/theia/image/image.h +@@ -64,7 +64,7 @@ class FloatImage { + + // Copy function. This is a deep copy of the image. + FloatImage(const FloatImage& image_to_copy); +- explicit FloatImage(const OpenImageIO::ImageBuf& image); ++ explicit FloatImage(const OIIO_NAMESPACE::ImageBuf& image); + FloatImage& operator=(const FloatImage& image2); + ~FloatImage() {} + +@@ -74,8 +74,8 @@ class FloatImage { + // wrapper for all algorithms. Getting a reference to the ImageBuf provides + // efficient access to the image data so that the image processing algorithms + // or other manipulations may be executed on the pixels. +- OpenImageIO::ImageBuf& GetOpenImageIOImageBuf(); +- const OpenImageIO::ImageBuf& GetOpenImageIOImageBuf() const; ++ OIIO_NAMESPACE::ImageBuf& GetOpenImageIOImageBuf(); ++ const OIIO_NAMESPACE::ImageBuf& GetOpenImageIOImageBuf() const; + + // Image information + int Rows() const; +@@ -171,7 +171,7 @@ class FloatImage { + void Resize(double scale); + + protected: +- OpenImageIO::ImageBuf image_; ++ OIIO_NAMESPACE::ImageBuf image_; + }; + } // namespace theia + +diff --git a/src/theia/image/image_test.cc b/src/theia/image/image_test.cc +index 894dc30..340488d 100644 +--- a/src/theia/image/image_test.cc ++++ b/src/theia/image/image_test.cc +@@ -53,11 +53,11 @@ RandomNumberGenerator rng(51); + std::string img_filename = THEIA_DATA_DIR + std::string("/") + FLAGS_test_img; + + #define ASSERT_IMG_EQ(oiio_img, theia_img, rows, cols) \ +- oiio_img.read(0, 0, true, OpenImageIO::TypeDesc::FLOAT); \ ++ oiio_img.read(0, 0, true, OIIO_NAMESPACE::TypeDesc::FLOAT); \ + ASSERT_EQ(oiio_img.oriented_width(), theia_img.Cols()); \ + ASSERT_EQ(oiio_img.oriented_height(), theia_img.Rows()); \ + ASSERT_EQ(oiio_img.nchannels(), theia_img.Channels()); \ +- OpenImageIO::ImageBuf::ConstIterator it(oiio_img); \ ++ OIIO_NAMESPACE::ImageBuf::ConstIterator it(oiio_img); \ + for (; !it.done(); ++it) { \ + for (int c = 0; c < oiio_img.nchannels(); c++) { \ + ASSERT_EQ(it[c], theia_img.GetXY(it.x(), it.y(), c)); \ +@@ -89,7 +89,7 @@ float Interpolate(const FloatImage& image, + + // Test that inputting the old fashioned way is the same as through our class. + TEST(Image, RGBInput) { +- OpenImageIO::ImageBuf oiio_img(img_filename.c_str()); ++ OIIO_NAMESPACE::ImageBuf oiio_img(img_filename.c_str()); + oiio_img.read(); + FloatImage theia_img(img_filename); + +@@ -102,7 +102,7 @@ TEST(Image, RGBInput) { + + // Test that width and height methods work. + TEST(Image, RGBColsRows) { +- OpenImageIO::ImageBuf oiio_img(img_filename.c_str()); ++ OIIO_NAMESPACE::ImageBuf oiio_img(img_filename.c_str()); + FloatImage theia_img(img_filename); + + int true_height = oiio_img.oriented_height(); +@@ -114,10 +114,10 @@ TEST(Image, RGBColsRows) { + + // Test that inputting the old fashioned way is the same as through our class. + TEST(Image, ConvertToGrayscaleImage) { +- OpenImageIO::ImageBuf oiio_img(img_filename.c_str()); +- OpenImageIO::ImageBuf gray_img; ++ OIIO_NAMESPACE::ImageBuf oiio_img(img_filename.c_str()); ++ OIIO_NAMESPACE::ImageBuf gray_img; + const float luma_weights[3] = {.2126, .7152, .0722}; +- OpenImageIO::ImageBufAlgo::channel_sum(gray_img, oiio_img, luma_weights); ++ OIIO_NAMESPACE::ImageBufAlgo::channel_sum(gray_img, oiio_img, luma_weights); + + FloatImage theia_img(img_filename); + theia_img.ConvertToGrayscaleImage(); +@@ -131,10 +131,10 @@ TEST(Image, ConvertToGrayscaleImage) { + } + + TEST(Image, ConvertToRGBImage) { +- OpenImageIO::ImageBuf oiio_img(img_filename.c_str()); +- OpenImageIO::ImageBuf gray_img; ++ OIIO_NAMESPACE::ImageBuf oiio_img(img_filename.c_str()); ++ OIIO_NAMESPACE::ImageBuf gray_img; + const float luma_weights[3] = {.2126, .7152, .0722}; +- OpenImageIO::ImageBufAlgo::channel_sum(gray_img, oiio_img, luma_weights); ++ OIIO_NAMESPACE::ImageBufAlgo::channel_sum(gray_img, oiio_img, luma_weights); + + // This should result in an image with the grayscale image copied in each + // channel. +@@ -148,7 +148,7 @@ TEST(Image, ConvertToRGBImage) { + + // Check that all channels have equal value and that the value is equal to the + // grayscale image. +- for (OpenImageIO::ImageBuf::ConstIterator it(gray_img); ++ for (OIIO_NAMESPACE::ImageBuf::ConstIterator it(gray_img); + !it.done(); + ++it) { + ASSERT_EQ(it[0], rgb_img.GetXY(it.x(), it.y(), 0)); +diff --git a/src/theia/sfm/exif_reader.cc b/src/theia/sfm/exif_reader.cc +index 48c049a..fea884d 100644 +--- a/src/theia/sfm/exif_reader.cc ++++ b/src/theia/sfm/exif_reader.cc +@@ -127,8 +127,8 @@ bool ExifReader::ExtractEXIFMetadata( + CameraIntrinsicsPrior* camera_intrinsics_prior) const { + CHECK_NOTNULL(camera_intrinsics_prior); + +- OpenImageIO::ImageBuf image(image_file); +- OpenImageIO::ImageSpec image_spec = image.spec(); ++ OIIO_NAMESPACE::ImageBuf image(image_file); ++ OIIO_NAMESPACE::ImageSpec image_spec = image.spec(); + + // Set the image dimensions. + camera_intrinsics_prior->image_width = image_spec.width; +@@ -154,7 +154,7 @@ bool ExifReader::ExtractEXIFMetadata( + camera_intrinsics_prior->focal_length.is_set = true; + + // Set GPS latitude. +- const OpenImageIO::ImageIOParameter* latitude = ++ const OIIO_NAMESPACE::ImageIOParameter* latitude = + image_spec.find_attribute("GPS:Latitude"); + if (latitude != nullptr) { + camera_intrinsics_prior->latitude.is_set = true; +@@ -173,7 +173,7 @@ bool ExifReader::ExtractEXIFMetadata( + } + + // Set GPS longitude. +- const OpenImageIO::ImageIOParameter* longitude = ++ const OIIO_NAMESPACE::ImageIOParameter* longitude = + image_spec.find_attribute("GPS:Longitude"); + if (longitude != nullptr) { + camera_intrinsics_prior->longitude.is_set = true; +@@ -193,7 +193,7 @@ bool ExifReader::ExtractEXIFMetadata( + + + // Set GSP altitude. +- const OpenImageIO::ImageIOParameter* altitude = ++ const OIIO_NAMESPACE::ImageIOParameter* altitude = + image_spec.find_attribute("GPS:Altitude"); + if (altitude != nullptr) { + camera_intrinsics_prior->altitude.is_set = true; +@@ -205,7 +205,7 @@ bool ExifReader::ExtractEXIFMetadata( + } + + bool ExifReader::SetFocalLengthFromExif( +- const OpenImageIO::ImageSpec& image_spec, ++ const OIIO_NAMESPACE::ImageSpec& image_spec, + CameraIntrinsicsPrior* camera_intrinsics_prior) const { + static const float kMinFocalLength = 1e-2; + +@@ -268,7 +268,7 @@ bool ExifReader::SetFocalLengthFromExif( + } + + bool ExifReader::SetFocalLengthFromSensorDatabase( +- const OpenImageIO::ImageSpec& image_spec, ++ const OIIO_NAMESPACE::ImageSpec& image_spec, + CameraIntrinsicsPrior* camera_intrinsics_prior) const { + const int max_image_dimension = std::max(image_spec.width, image_spec.height); + const float exif_focal_length = +diff --git a/src/theia/sfm/exif_reader.h b/src/theia/sfm/exif_reader.h +index 3049cf4..d9d3108 100644 +--- a/src/theia/sfm/exif_reader.h ++++ b/src/theia/sfm/exif_reader.h +@@ -74,13 +74,13 @@ class ExifReader { + // Sets the focal length from the focal plane resolution. Returns true if a + // valid focal length is found and false otherwise. + bool SetFocalLengthFromExif( +- const OpenImageIO::ImageSpec& image_spec, ++ const OIIO_NAMESPACE::ImageSpec& image_spec, + CameraIntrinsicsPrior* camera_intrinsics_prior) const; + + // Sets the focal length from a look up in the sensor width database. Returns + // true if a valid focal length is found and false otherwise. + bool SetFocalLengthFromSensorDatabase( +- const OpenImageIO::ImageSpec& image_spec, ++ const OIIO_NAMESPACE::ImageSpec& image_spec, + CameraIntrinsicsPrior* camera_intrinsics_prior) const; + + std::unordered_map sensor_width_database_; +diff --git a/src/theia/sfm/undistort_image.cc b/src/theia/sfm/undistort_image.cc +index 95a061d..ae0690e 100644 +--- a/src/theia/sfm/undistort_image.cc ++++ b/src/theia/sfm/undistort_image.cc +@@ -160,9 +160,9 @@ void RemoveImageLensDistortion(const Camera& distorted_camera, + // For each pixel in the undistorted image, find the coordinate in the + // distorted image and set the pixel color accordingly. + const int num_channels = distorted_image.Channels(); +- OpenImageIO::ImageBuf& undistorted_img = ++ OIIO_NAMESPACE::ImageBuf& undistorted_img = + undistorted_image->GetOpenImageIOImageBuf(); +- OpenImageIO::ImageBuf::Iterator undistorted_it(undistorted_img); ++ OIIO_NAMESPACE::ImageBuf::Iterator undistorted_it(undistorted_img); + for (; !undistorted_it.done(); ++undistorted_it) { + Eigen::Vector2d image_point(undistorted_it.x() + 0.5, + undistorted_it.y() + 0.5); diff --git a/ports/theia/portfile.cmake b/ports/theia/portfile.cmake index 8ac920d579..d2e4c66993 100644 --- a/ports/theia/portfile.cmake +++ b/ports/theia/portfile.cmake @@ -20,6 +20,7 @@ vcpkg_apply_patches( ${CMAKE_CURRENT_LIST_DIR}/fix-vlfeat-static.patch ${CMAKE_CURRENT_LIST_DIR}/fix-glog-error.patch ${CMAKE_CURRENT_LIST_DIR}/fix-find-suitesparse.patch + ${CMAKE_CURRENT_LIST_DIR}/fix-oiio.patch ) vcpkg_configure_cmake(