|
@@ -19,6 +19,8 @@ package("opencv")
|
|
|
add_versions("4.2.0", "9ccb2192d7e8c03c58fee07051364d94ed7599363f3b0dce1c5e6cc11c1bb0ec")
|
|
|
add_versions("3.4.9", "b7ea364de7273cfb3b771a0d9c111b8b8dfb42ff2bcd2d84681902fb8f49892a")
|
|
|
|
|
|
+ add_patches("4.11.0", "https://github.com/opencv/opencv/commit/767dd838d3074409fd72a4d76c320b1370e95943.diff", "376dd90500ab7205084fd4298ff26137ce9678b00233ad20ca2189ef9eca3a58")
|
|
|
+
|
|
|
add_resources("4.11.0", "opencv_contrib", "https://github.com/opencv/opencv_contrib/archive/4.11.0.tar.gz", "2dfc5957201de2aa785064711125af6abb2e80a64e2dc246aca4119b19687041")
|
|
|
add_resources("4.10.0", "opencv_contrib", "https://github.com/opencv/opencv_contrib/archive/4.10.0.tar.gz", "65597f8fb8dc2b876c1b45b928bbcc5f772ddbaf97539bf1b737623d0604cba1")
|
|
|
add_resources("4.9.0", "opencv_contrib", "https://github.com/opencv/opencv_contrib/archive/4.9.0.tar.gz", "8952c45a73b75676c522dd574229f563e43c271ae1d5bbbd26f8e2b6bc1a4dae")
|
|
@@ -78,7 +80,7 @@ package("opencv")
|
|
|
end
|
|
|
end)
|
|
|
|
|
|
- on_load("linux", "macosx", "windows", "mingw@windows,msys", function (package)
|
|
|
+ on_load("android", "linux", "macosx", "windows", "mingw@windows,msys", function (package)
|
|
|
if package:is_plat("windows") then
|
|
|
local arch = "x64"
|
|
|
if package:is_arch("x86") then arch = "x86"
|
|
@@ -98,6 +100,11 @@ package("opencv")
|
|
|
local arch = (package:is_arch("x86_64") and "x64" or "x86")
|
|
|
local linkdir = (package:config("shared") and "lib" or "staticlib")
|
|
|
package:add("linkdirs", path.join(arch, "mingw", linkdir))
|
|
|
+ elseif package:is_plat("android") then
|
|
|
+ local linkdir = (package:config("shared") and "libs" or "staticlibs")
|
|
|
+ package:add("linkdirs", path.join("sdk/native", linkdir, package:targetarch()))
|
|
|
+ package:add("linkdirs", path.join("sdk/native/3rdparty/libs", package:targetarch()))
|
|
|
+ package:add("includedirs", "sdk/native/jni/include")
|
|
|
elseif package:version():ge("4.0") then
|
|
|
package:add("includedirs", "include/opencv4")
|
|
|
package:add("linkdirs", "lib", "lib/opencv4/3rdparty")
|
|
@@ -123,21 +130,22 @@ package("opencv")
|
|
|
end
|
|
|
|
|
|
if package:config("tesseract") then
|
|
|
- package:add("deps", "tesseract 4.1.3") -- Opencv need tesseract from the v4 series
|
|
|
+ package:add("deps", "tesseract 4.1.3") -- OpenCV need tesseract from the v4 series
|
|
|
end
|
|
|
end)
|
|
|
|
|
|
if on_check then
|
|
|
on_check("windows|arm64", function (package)
|
|
|
+ import("core.base.semver")
|
|
|
if package:version() and package:version():lt("4.10.0") then
|
|
|
raise("current opencv version does not support windows/arm64!")
|
|
|
end
|
|
|
local vs = package:toolchain("msvc"):config("vs")
|
|
|
- assert(tonumber(vs) >= 2022, "opencv requires Visual Studio 2022 and later for arm targets")
|
|
|
+ assert(tonumber(vs) >= 2022, "package(opencv) requires Visual Studio 2022 and later for arm targets")
|
|
|
end)
|
|
|
end
|
|
|
|
|
|
- on_install("linux", "macosx", "windows", "mingw@windows,msys", function (package)
|
|
|
+ on_install("android", "linux", "macosx", "windows", "mingw@windows,msys", function (package)
|
|
|
io.replace("cmake/OpenCVUtils.cmake", "if(PKG_CONFIG_FOUND OR PkgConfig_FOUND)", "if(NOT WIN32 AND (PKG_CONFIG_FOUND OR PkgConfig_FOUND))", {plain = true})
|
|
|
local configs = {"-DCMAKE_OSX_DEPLOYMENT_TARGET=",
|
|
|
"-DBUILD_PERF_TESTS=OFF",
|
|
@@ -174,6 +182,14 @@ package("opencv")
|
|
|
if package:is_arch("arm64") then
|
|
|
-- https://github.com/opencv/opencv/issues/25052
|
|
|
table.insert(configs, "-DCPU_NEON_FP16_SUPPORTED=OFF")
|
|
|
+ -- Newest Windows ARM worker issue
|
|
|
+ if package:has_runtime("MT", "MTd") then
|
|
|
+ table.insert(configs, "-DCPU_NEON_DOTPROD_SUPPORTED=OFF")
|
|
|
+ end
|
|
|
+ -- https://github.com/opencv/opencv/issues/24235
|
|
|
+ table.insert(configs, "-DOPENCV_SKIP_SYSTEM_PROCESSOR_DETECTION=ON")
|
|
|
+ -- Enforce ARM64 without check
|
|
|
+ table.insert(configs, "-DAARCH64=ON")
|
|
|
end
|
|
|
end
|
|
|
if package:is_cross() or (package:is_plat("mingw") and not package:is_arch(os.arch())) then
|
|
@@ -183,8 +199,19 @@ package("opencv")
|
|
|
table.insert(configs, "-DCMAKE_SYSTEM_NAME=Darwin")
|
|
|
elseif package:is_plat("linux") then
|
|
|
table.insert(configs, "-DCMAKE_SYSTEM_NAME=Linux")
|
|
|
+ elseif package:is_plat("android") then
|
|
|
+ table.insert(configs, "-DCMAKE_SYSTEM_NAME=Android")
|
|
|
+ -- from https://github.com/opencv/opencv/issues/15769#issuecomment-549570072
|
|
|
+ table.insert(configs, "-DBUILD_ANDROID_EXAMPLES=OFF")
|
|
|
+ table.insert(configs, "-DBUILD_ANDROID_PROJECTS=OFF")
|
|
|
+ end
|
|
|
+
|
|
|
+ -- In case of android we prefer to set CMAKE_ANDROID_ARCH_ABI rather than CMAKE_SYSTEM_PROCESSOR
|
|
|
+ if package:is_plat("android") then
|
|
|
+ table.insert(configs, "-DCMAKE_ANDROID_ARCH_ABI=" .. package:targetarch())
|
|
|
+ else
|
|
|
+ table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. package:targetarch())
|
|
|
end
|
|
|
- table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. package:targetarch())
|
|
|
end
|
|
|
local resourcedir = package:resourcedir("opencv_contrib")
|
|
|
if resourcedir then
|
|
@@ -227,11 +254,22 @@ package("opencv")
|
|
|
end
|
|
|
package:add("links", reallink)
|
|
|
end
|
|
|
- if package:is_plat("windows") then
|
|
|
+ if package:is_plat("android") then
|
|
|
+ for _, suffix in ipairs({"*.a", "*.so"}) do
|
|
|
+ for _, f in ipairs(os.files(path.join(package:installdir(path.join("sdk/native/3rdparty/libs", package:targetarch())), suffix))) do
|
|
|
+ package:add("links", path.basename(f):match("lib(.+)"))
|
|
|
+ end
|
|
|
+ end
|
|
|
+ elseif package:is_plat("windows") then
|
|
|
local arch = "x64"
|
|
|
if package:is_arch("x86") then arch = "x86"
|
|
|
elseif package:is_arch("arm64") then arch = "ARM64"
|
|
|
end
|
|
|
+ -- Workaround for arm64
|
|
|
+ if package:is_arch("arm64") then
|
|
|
+ os.trymv(path.join(package:installdir(), "x64"), path.join(package:installdir(), "ARM64"))
|
|
|
+ os.trymv(path.join(package:installdir(), "x86"), path.join(package:installdir(), "ARM64"))
|
|
|
+ end
|
|
|
local linkdir = (package:config("shared") and "lib" or "staticlib")
|
|
|
local vs = package:toolchain("msvc"):config("vs")
|
|
|
local vc_ver = "vc13"
|
|
@@ -250,7 +288,7 @@ package("opencv")
|
|
|
package:add("links", path.basename(f))
|
|
|
end
|
|
|
end
|
|
|
- package:addenv("PATH", "bin") -- fix path for 4.9.0/vs2022
|
|
|
+ package:addenv("PATH", "bin") -- Fix path for 4.9.0 / vs2022
|
|
|
package:addenv("PATH", path.join(arch, vc_ver, "bin"))
|
|
|
elseif package:is_plat("mingw") then
|
|
|
local arch = package:is_arch("x86_64") and "x64" or "x86"
|