112 lines
3.4 KiB
Ruby
112 lines
3.4 KiB
Ruby
class OpencvAT3 < Formula
|
|
desc "Open source computer vision library"
|
|
homepage "https://opencv.org/"
|
|
url "https://github.com/opencv/opencv/archive/3.4.10.tar.gz"
|
|
sha256 "1ed6f5b02a7baf14daca04817566e7c98ec668cec381e0edf534fa49f10f58a2"
|
|
license "BSD-3-Clause"
|
|
revision 4
|
|
|
|
bottle do
|
|
sha256 "890dcb6beccc060f02a7d5f594e604ac29cb10b7c5a471dd5cc2f8cdea026d5d" => :catalina
|
|
sha256 "36ed82e801b3e60ddf08592d28f03add4acbab5b26630a3856ebbafc137eaeb8" => :mojave
|
|
sha256 "3f48062f043a2208fde3360abb0cbb373674b2768218cc49aed55637fad2b5dc" => :high_sierra
|
|
end
|
|
|
|
keg_only :versioned_formula
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "ceres-solver"
|
|
depends_on "eigen"
|
|
depends_on "ffmpeg"
|
|
depends_on "gflags"
|
|
depends_on "glog"
|
|
depends_on "jpeg"
|
|
depends_on "libpng"
|
|
depends_on "libtiff"
|
|
depends_on "numpy"
|
|
depends_on "openexr"
|
|
depends_on "python@3.8"
|
|
depends_on "tbb"
|
|
|
|
resource "contrib" do
|
|
url "https://github.com/opencv/opencv_contrib/archive/3.4.10.tar.gz"
|
|
sha256 "45be02486feaa5c66efc497c463a9b9d6671aa4a125ca8ea2467b8c81201971c"
|
|
end
|
|
|
|
def install
|
|
ENV.cxx11
|
|
|
|
resource("contrib").stage buildpath/"opencv_contrib"
|
|
|
|
# Reset PYTHONPATH, workaround for https://github.com/Homebrew/homebrew-science/pull/4885
|
|
ENV.delete("PYTHONPATH")
|
|
|
|
args = std_cmake_args + %W[
|
|
-DCMAKE_OSX_DEPLOYMENT_TARGET=
|
|
-DBUILD_JASPER=OFF
|
|
-DBUILD_JPEG=ON
|
|
-DBUILD_OPENEXR=OFF
|
|
-DBUILD_PERF_TESTS=OFF
|
|
-DBUILD_PNG=OFF
|
|
-DBUILD_TESTS=OFF
|
|
-DBUILD_TIFF=OFF
|
|
-DBUILD_ZLIB=OFF
|
|
-DBUILD_opencv_hdf=OFF
|
|
-DBUILD_opencv_java=OFF
|
|
-DBUILD_opencv_text=OFF
|
|
-DOPENCV_ENABLE_NONFREE=ON
|
|
-DOPENCV_EXTRA_MODULES_PATH=#{buildpath}/opencv_contrib/modules
|
|
-DWITH_1394=OFF
|
|
-DWITH_CUDA=OFF
|
|
-DWITH_EIGEN=ON
|
|
-DWITH_FFMPEG=ON
|
|
-DWITH_GPHOTO2=OFF
|
|
-DWITH_GSTREAMER=OFF
|
|
-DWITH_JASPER=OFF
|
|
-DWITH_OPENEXR=ON
|
|
-DWITH_OPENGL=OFF
|
|
-DWITH_QT=OFF
|
|
-DWITH_TBB=ON
|
|
-DWITH_VTK=OFF
|
|
-DBUILD_opencv_python2=OFF
|
|
-DBUILD_opencv_python3=ON
|
|
-DPYTHON3_EXECUTABLE=#{Formula["python@3.8"].opt_bin}/python3
|
|
]
|
|
|
|
args << "-DENABLE_AVX=OFF" << "-DENABLE_AVX2=OFF"
|
|
args << "-DENABLE_SSE41=OFF" << "-DENABLE_SSE42=OFF" unless MacOS.version.requires_sse42?
|
|
|
|
mkdir "build" do
|
|
system "cmake", "..", *args
|
|
inreplace "modules/core/version_string.inc", "#{HOMEBREW_SHIMS_PATH}/mac/super/", ""
|
|
system "make"
|
|
system "make", "install"
|
|
system "make", "clean"
|
|
system "cmake", "..", "-DBUILD_SHARED_LIBS=OFF", *args
|
|
inreplace "modules/core/version_string.inc", "#{HOMEBREW_SHIMS_PATH}/mac/super/", ""
|
|
system "make"
|
|
lib.install Dir["lib/*.a"]
|
|
lib.install Dir["3rdparty/**/*.a"]
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.cpp").write <<~EOS
|
|
#include <opencv/cv.h>
|
|
#include <iostream>
|
|
int main() {
|
|
std::cout << CV_VERSION << std::endl;
|
|
return 0;
|
|
}
|
|
EOS
|
|
system ENV.cxx, "test.cpp", "-I#{include}", "-L#{lib}", "-o", "test"
|
|
assert_equal `./test`.strip, version.to_s
|
|
|
|
py3_version = Language::Python.major_minor_version Formula["python@3.8"].opt_bin/"python3"
|
|
ENV["PYTHONPATH"] = lib/"python#{py3_version}/site-packages"
|
|
output = shell_output(Formula["python@3.8"].opt_bin/"python3 -c 'import cv2; print(cv2.__version__)'")
|
|
assert_equal version.to_s, output.chomp
|
|
end
|
|
end
|