sminterpolate
sminterpolate copied to clipboard
ArchLinux: patched PKGBUILD for opencv2-opt AUR package
Hi. I'm providing this files for those who (heavily) depend on opencv3 and can not just replace it with the older v2. I experimented a lot and finally got your app working with the /opt
libraries from the opencv2-opt AUR package :smiley:
PKGBUILD
pkgname=butterflow
pkgver=0.2.3
pkgrel=1
pkgdesc="Make slow motion and motion interpolated videos from the command line"
arch=('x86_64')
url="https://github.com/dthpham/butterflow"
license=('custom')
makedepends=('python2-setuptools' 'opencl-headers')
depends=('python2-numpy' 'ffmpeg' 'opencv2-opt' 'ocl-icd')
optdepends=('intel-opencl-runtime: Intel processor device support'
'opencl-nvidia: NVIDIA device support'
'amdapp-sdk: AMD device suppport')
provides=('butterflow')
conflicts=('butterflow')
install=butterflow.install
source=("http://srv.dthpham.me/butterflow/releases/${pkgname}-${pkgver}.tar.gz"
"opencv2-opt.patch" "butterflow-opt.sh")
sha256sums=('83e3ce52eef57ae2e4f4b3dc98d97ab354621e4a095d9734751bd876c34b755e'
'SKIP' 'SKIP')
prepare() {
cd "${srcdir}/${pkgname}-${pkgver}"
# apply opencv2-opt patch to use the opencv2 inside /opt
# for those who need/depend on opencv3 and can not just replace it with the older version
patch -p1 < "../opencv2-opt.patch"
}
package() {
cd "${srcdir}/${pkgname}-${pkgver}"
python2 setup.py install --root="${pkgdir}/" --optimize=1
install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
# install wrapper script to set LD_LIBRARY_PATH and PYTHONPATH before launching butterflow
# note: the python script must be named exactly 'butterflow' or weird import errors occur :/
mkdir -p "${pkgdir}/usr/lib/butterflow"
mv "${pkgdir}/usr/bin/butterflow" "${pkgdir}/usr/lib/butterflow/butterflow"
install -m755 ../butterflow-opt.sh "${pkgdir}/usr/bin/butterflow"
}
opencv2-opt.patch
--- butterflow-0.2.3/setup.cfg.orig 2017-04-10 23:34:55.000000000 +0200
+++ butterflow-0.2.3/setup.cfg 2017-06-27 10:37:44.281444271 +0200
@@ -3,3 +3,7 @@
tag_date = 0
tag_svn_revision = 0
+[build_ext]
+include-dirs=/opt/opencv2/include
+library-dirs=/opt/opencv2/lib
+rpath=True
butterflow-opt.sh
#!/bin/bash
export LD_LIBRARY_PATH="/opt/opencv2/lib:$LD_LIBRARY_PATH"
export PYTHONPATH="/opt/opencv2/lib/python2.7/site-packages:$PYTHONPATH"
exec /usr/lib/butterflow/butterflow "$@"
I hope this helps some people. It took me way too long to figure this out.
I don't have access to my Arch Linux machine at this moment so I can't try this out yet, but I do think that this should be the default — with BF depending on opencv2 installed to opt so that other people can use opencv3 at the same time. When I'm able to try and verify that it works I'll update the PKGBUILD with your patches. Thanks for this.
Is there any update w.r.t. to this issue?
I have tried the proposed solution, and I was able to install BF this way alongside with opencv. But I get this error when trying to run it (first time ever user here):
frank@HomeC ~/kdenlive> butterflow -s full,spd=0.25 Megható.mkv
Traceback (most recent call last):
File "/usr/lib/butterflow/butterflow", line 11, in <module>
load_entry_point('butterflow==0.2.3', 'console_scripts', 'butterflow')()
File "/usr/lib/python2.7/site-packages/butterflow/cli.py", line 287, in main
if not args.sw and not ocl.compat_ocl_device_available():
RuntimeError: opencl call failed
Slightly offtopic: @dthpham can you provide Appimage package for BF?
Here's an alternative patch that handles numpy as well:
--- setup.py.orig 2020-05-15 13:46:33.271309422 -0500
+++ setup.py 2020-05-15 13:46:45.938100357 -0500
@@ -135,6 +135,8 @@
ocl_ext = Extension('butterflow.ocl', extra_compile_args=cxxflags,
extra_link_args=linkflags,
+ include_dirs=['/opt/opencv2/include'],
+ library_dirs=['/opt/opencv2/lib'],
libraries=mklist(cl_lib, 'opencv_core', 'opencv_ocl'),
sources=[os.path.join(pkgdir, 'ocl.cpp')], language='c++')
@@ -156,6 +158,7 @@
# fallback to the system's numpy
np_includes = '/System/Library/Frameworks/Python.framework/Versions/'\
'{}/Extras/lib/python/numpy/core/include'.format(py_ver)
+np_includes = '/usr/lib/python{}/site-packages/numpy/core/include'.format(py_ver)
# opencv-ndarray-conversion args
nddir = os.path.join(vendordir, 'opencv-ndarray-conversion')
@@ -164,7 +167,8 @@
motion_ext = Extension('butterflow.motion',
extra_compile_args=cxxflags,
extra_link_args=linkflags,
- include_dirs=mklist(nd_includes, np_includes),
+ include_dirs=mklist(nd_includes, np_includes, '/opt/opencv2/include'),
+ library_dirs=['/opt/opencv2/lib'],
libraries=['opencv_core', 'opencv_ocl',
'opencv_imgproc'],
sources=[os.path.join(pkgdir, 'motion.cpp'),