Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Formula/o/opencv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ def install
# Avoid Accelerate.framework
ENV["OpenBLAS_HOME"] = Formula["openblas"].opt_prefix

# Reset PYTHONPATH, workaround for https://github.com/Homebrew/homebrew-science/pull/4885
ENV.delete("PYTHONPATH")

# Remove bundled libraries to make sure formula dependencies are used
libdirs = %w[ffmpeg libjasper libjpeg libjpeg-turbo libpng libtiff libwebp openexr openjpeg protobuf tbb zlib]
libdirs.each { |l| rm_r(buildpath/"3rdparty"/l) }
Expand Down Expand Up @@ -138,11 +135,6 @@ def install
-DPYTHON3_EXECUTABLE=#{which(python3)}
]

args += [
"-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON", # https://github.com/protocolbuffers/protobuf/issues/12292
"-Dprotobuf_MODULE_COMPATIBLE=ON", # https://github.com/protocolbuffers/protobuf/issues/1931
]

args += if OS.mac?
# Requires closed-source, pre-built Orbbec SDK on macOS
["-DWITH_OBSENSOR=OFF"]
Expand Down Expand Up @@ -189,14 +181,22 @@ def install

test do
(testpath/"test.cpp").write <<~CPP
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
int main() {
std::cout << CV_VERSION << std::endl;
cv::Mat img = cv::imread("#{test_fixtures("test.jpg")}", cv::IMREAD_COLOR);
if (img.empty()) {
std::cerr << "Could not read test.jpg fixture" << std::endl;
return 1;
}
return 0;
}
CPP
system ENV.cxx, "-std=c++17", "test.cpp", "-I#{include}/opencv4", "-o", "test"
system ENV.cxx, "-std=c++17", "test.cpp", "-I#{include}/opencv4", "-o", "test",
"-L#{lib}", "-lopencv_core", "-lopencv_imgcodecs"
assert_equal version.to_s, shell_output("./test").strip

output = shell_output("#{python3} -c 'import cv2; print(cv2.__version__)'")
Expand Down
Loading