2017-08-10 20:46:09 +00:00
|
|
|
class Opencv < Formula
|
|
|
|
desc "Open source computer vision library"
|
|
|
|
homepage "http://opencv.org/"
|
|
|
|
url "https://github.com/opencv/opencv/archive/3.3.0.tar.gz"
|
|
|
|
sha256 "95029eb5578af3b20b8c7f8f6f59db1b827c2d5aaaa74b6becb1de647cbdda5a"
|
2017-08-25 17:54:12 +00:00
|
|
|
revision 3
|
2017-08-10 20:46:09 +00:00
|
|
|
|
2017-08-20 17:19:11 +00:00
|
|
|
bottle do
|
|
|
|
sha256 "6d62ac40e7c800770f66c4671befc324167b89ebe6b050ceceafc8033a2bca02" => :sierra
|
|
|
|
sha256 "981a7a7b7ee4d6539556843b4a42d7bc45e0af84cb80e2c84556dda70fea0d29" => :el_capitan
|
|
|
|
sha256 "b4034120207584e69f1a6be81d993ce0da6800fd1675fd8d83f7cc03801318e3" => :yosemite
|
|
|
|
end
|
|
|
|
|
2017-08-10 20:46:09 +00:00
|
|
|
depends_on "cmake" => :build
|
|
|
|
depends_on "pkg-config" => :build
|
|
|
|
depends_on "eigen"
|
|
|
|
depends_on "ffmpeg"
|
|
|
|
depends_on "jpeg"
|
|
|
|
depends_on "libpng"
|
|
|
|
depends_on "libtiff"
|
|
|
|
depends_on "openexr"
|
2017-08-25 17:54:12 +00:00
|
|
|
depends_on :python
|
|
|
|
depends_on :python3
|
|
|
|
depends_on "numpy"
|
2017-08-10 20:46:09 +00:00
|
|
|
|
|
|
|
needs :cxx11
|
|
|
|
|
|
|
|
resource "contrib" do
|
|
|
|
url "https://github.com/opencv/opencv_contrib/archive/3.3.0.tar.gz"
|
|
|
|
sha256 "e94acf39cd4854c3ef905e06516e5f74f26dddfa6477af89558fb40a57aeb444"
|
|
|
|
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")
|
|
|
|
|
2017-08-25 17:54:12 +00:00
|
|
|
py_prefix = `python-config --prefix`.chomp
|
|
|
|
py_lib = "#{py_prefix}/lib"
|
|
|
|
|
|
|
|
py3_config = `python3-config --configdir`.chomp
|
|
|
|
py3_include = `python3 -c "import distutils.sysconfig as s; print(s.get_python_inc())"`.chomp
|
|
|
|
py3_version = Language::Python.major_minor_version "python3"
|
|
|
|
|
2017-08-10 20:46:09 +00:00
|
|
|
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_java=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=OFF
|
|
|
|
-DWITH_VTK=OFF
|
2017-08-25 17:54:12 +00:00
|
|
|
-DBUILD_opencv_python2=ON
|
|
|
|
-DBUILD_opencv_python3=ON
|
|
|
|
-DPYTHON2_EXECUTABLE=#{which "python"}
|
|
|
|
-DPYTHON2_LIBRARY=#{py_lib}/libpython2.7.dylib
|
|
|
|
-DPYTHON2_INCLUDE_DIR=#{py_prefix}/include/python2.7
|
|
|
|
-DPYTHON3_EXECUTABLE=#{which "python3"}
|
|
|
|
-DPYTHON3_LIBRARY=#{py3_config}/libpython#{py3_version}.dylib
|
|
|
|
-DPYTHON3_INCLUDE_DIR=#{py3_include}
|
2017-08-10 20:46:09 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
if build.bottle?
|
2017-08-25 17:54:12 +00:00
|
|
|
args += %w[-DENABLE_SSE41=OFF -DENABLE_SSE42=OFF -DENABLE_AVX=OFF
|
|
|
|
-DENABLE_AVX2=OFF]
|
2017-08-10 20:46:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
mkdir "build" do
|
|
|
|
system "cmake", "..", *args
|
|
|
|
system "make"
|
|
|
|
system "make", "install"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
(testpath/"test.cpp").write <<-EOS.undent
|
|
|
|
#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
|
|
|
|
|
2017-08-25 17:54:12 +00:00
|
|
|
["python", "python3"].each do |python|
|
|
|
|
output = shell_output("#{python} -c 'import cv2; print(cv2.__version__)'")
|
|
|
|
assert_equal version.to_s, output.chomp
|
2017-08-10 20:46:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|