Open TheMrIron2 opened 5 years ago
I don't have it working yet, but I was able to get butterflow to install without errors on a MacBook Pro running Mojave.
I added these lines to my ~/.profile: export PATH="/usr/local/opt/opencv@2/bin:$PATH" export LDFLAGS="-L/usr/local/opt/opencv@2/lib" export CPPFLAGS="-I/usr/local/opt/opencv@2/include"
Then ran the instructions found in Install from Source Guide.
But running the snippet at the end showed that five of the ffmpeg flags were not available. That might be my issue...
@andrewmackenzie Try installing ffmpeg from https://github.com/varenc/homebrew-ffmpeg — I cannot confirm if this works as it doesn't work on macOS Catalina yet.
I see references to butterflow all over the internet when frame interpolation comes up, so it's a bit surprising it's not just an installable Homebrew formula. If someone can get this working on a contemporary version of macOS, probably worthwhile to make it a formula.
I need help with the very last stage of this. I am not a software engineer of any kind so my nix skills aren't great, but I have managed by hook and crook to get to the last part of the process.
When I cloned the butterflow repo I made a directory in ~/ home folder called Gitrepos and cloned butterfly in there. So I am at the point of doing python setup.py install
but it cannot find things.
`/Users/angus/Gitrepos/butterflow/butterflow/ocl.cpp:9:10: fatal error: 'opencv2/core/core.hpp' file not found
My $PATH environment variable has
usr/local/opt/opencv@2/bin:
and usr/local/opt/opencv@2/include
in it.
usr/local/opt/opencv@2
is a Symlink created when opencv@2 is installed by Hombrew and I can traverse the file structure from the command line and get to opencv2/core/core.hpp file no problems ? what could be happening ?
Gus
Here's a step-by-step of worked for me on macOS 10.15 Catalina:
Install the Xcode commandline tools if you need to
xcode-select --install
note that opencv@2 depends on ffmpeg now so it gets installed automatically - see https://formulae.brew.sh/formula/opencv@2
brew install opencv@2
Install pip, which'll then let us install virtualenv
sudo easy_install pip
pip install virtualenv
Note that it'll give you the following info, which we can ignore for now WARNING: The script virtualenv is installed in '/Users/yourusername/Library/Python/2.7/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
cd to wherever you want to put your code, e.g. cd ~
, then clone the butterflow source
git clone https://github.com/dthpham/butterflow.git
Create the virtualenv - we'll just refer to the newly-install virtualenv binary directly instead of adding it to our PATH like the warning above says. Note that python
has been renamed to python2
and python3
in Catalina, as far as I know, so we want virtualenv to use python2
~/Library/Python/2.7/bin/virtualenv -p /usr/bin/python2 butterflow
Navigate into the folder
cd butterflow
Tell butterflow where the homebrew python site-packages are by using a .pth file
echo "$(brew --prefix)/lib/python2.7/site-packages" > lib/python2.7/site-packages/butterflow.pth
activate the virtualenv
source bin/activate
now we're inside the virtualenv, set the compile flags so the clang compiler knows where things are
export LDFLAGS="-L/usr/local/opt/opencv@2/lib -L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/opencv@2/include"
export PKG_CONFIG_PATH="/usr/local/opt/opencv@2/lib/pkgconfig"
export PYTHONPATH=$PYTHONPATH:$(brew --prefix)/lib/python2.7/site-packages
OK, we're hopefully ready to install! -
sudo python2 setup.py install
test that it works
butterflow --help
exit the virtualenv
deactivate
NOTE: to use butterflow outside of the virtualenv environment, you'll need to set the PYTHONPATH permanently for your shell, e.g. something like:
echo "export PYTHONPATH=$PYTHONPATH:$(brew --prefix)/lib/python2.7/site-packages" >> ~/.bash_profile
Hope that helps somebody!
Oh, I forgot to mention. If you can't compile because of a ImportError: No module named _winreg
warning or something like that (winreg doesn't exist on non-Windows platforms, so it's not too surprising that it can't be found) edit the butterflow/__init__.py
file and blank the whole thing out. I changed mine to look like this, though it can probably be totally empty:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import os
import sys
Then hopefully it should compile fine on macOS.
@ManxStef thanks, these worked for me!
If you get an error with import cv2
after all this, check #10 (all the way from 2015!)
I wonder if anyone has successfully installed this in OSX (10.14.6 (18G103)). I successfully linked the modules required but I get too many error and warning during installation.
/usr/local/opt/opencv@2/include/opencv2/opencv2/core/core.hpp:48:10: error: #include nested too deeply
#include "opencv2/core.hpp"
^
In file included from /Users/m/Labs/butterflow/butterflow/ocl.cpp:10:
/usr/local/include/opencv2/core/ocl.hpp:631:5: error: unknown type name 'CV_DEPRECATED'
CV_DEPRECATED bool read(const String& buf, const String& buildflags); // removed, use ProgramSource instead
^
/usr/local/include/opencv2/core/ocl.hpp:631:19: error: expected member name or ';' after declaration specifiers
CV_DEPRECATED bool read(const String& buf, const String& buildflags); // removed, use ProgramSource instead
~~~~~~~~~~~~~ ^
/usr/local/include/opencv2/core/ocl.hpp:632:5: error: unknown type name 'CV_DEPRECATED'
CV_DEPRECATED bool write(String& buf) const; // removed, use getBinary() method instead (RAW OpenCL binary)
^
/usr/local/include/opencv2/core/ocl.hpp:632:19: error: expected member name or ';' after declaration specifiers
CV_DEPRECATED bool write(String& buf) const; // removed, use getBinary() method instead (RAW OpenCL binary)
~~~~~~~~~~~~~ ^
/usr/local/include/opencv2/core/ocl.hpp:633:5: error: unknown type name 'CV_DEPRECATED'
CV_DEPRECATED const ProgramSource& source() const; // implementation removed
^
/usr/local/include/opencv2/core/ocl.hpp:633:19: error: expected member name or ';' after declaration specifiers
CV_DEPRECATED const ProgramSource& source() const; // implementation removed
~~~~~~~~~~~~~ ^
/usr/local/include/opencv2/core/ocl.hpp:634:5: error: unknown type name 'CV_DEPRECATED'
CV_DEPRECATED String getPrefix() const; // deprecated, implementation replaced
^
/usr/local/include/opencv2/core/ocl.hpp:634:25: error: expected ';' at end of declaration list
CV_DEPRECATED String getPrefix() const; // deprecated, implementation replaced
^
;
/usr/local/include/opencv2/core/ocl.hpp:635:5: error: unknown type name 'CV_DEPRECATED'
CV_DEPRECATED static String getPrefix(const String& buildflags); // deprecated, implementation replaced
^
/usr/local/include/opencv2/core/ocl.hpp:635:19: error: expected member name or ';' after declaration specifiers
CV_DEPRECATED static String getPrefix(const String& buildflags); // deprecated, implementation replaced
~~~~~~~~~~~~~ ^
/Users/m/Labs/butterflow/butterflow/ocl.cpp:58:11: error: unknown type name 'DeviceInfo'
const DeviceInfo& currentDevice = Context::getContext()->getDeviceInfo();
^
/Users/m/Labs/butterflow/butterflow/ocl.cpp:58:48: error: no member named 'getContext' in 'cv::ocl::Context'
const DeviceInfo& currentDevice = Context::getContext()->getDeviceInfo();
I wonder if there is any workaround available for OSX. 🤔
yes as mentioned I’ve successfully installed it on OS X with the steps above
Hi Thanks for these steps @ManxStef ! I followed it successfully until I got this error after running this command: sudo python2 setup.py install Error: /butterflow/butterflow/ocl.cpp:9:10: fatal error: 'opencv2/core/core.hpp' file not found
^~~~~~~~~~~~~~~~~~~~~~~
1 error generated. error: command 'cc' failed with exit status 1
Does anyone know how to fix that?
Bump, same error here - trying to install it on MacOS BigSur:
fatal error: 'opencv2/core/core.hpp' file not found
I followed @ManxStef directions up to
python2 setup.py install
Anyone could help? Thanks!
I'm also on mac big sur and am stuck on "fatal error: 'opencv2/core/core.hpp' file not found" I feel like I've run around the problem a bunch and just can't get my head around the issue any help would be appreciated
even with all of the other steps ( thanks @ManxStef ) I still needed to brew link opencv@2
to get beyond fatal error: 'opencv2/core/core.hpp' file not found
cc: @kirkegross @balchlab @wednesdayayay
The issue is that when one runs sudo python2 setup.py install
, setup.py can no longer find the environment variables because the shell id has changed (due to sudo).
However, on Big Sur, one no longer needs to use sudo here. However, and I am not entirely clear how or why this has happened, but in my case, I get a new error, which is :
/Users/<redacted>/butterflow/butterflow/ocl.cpp:10:10: fatal error: 'opencv2/core/ocl.hpp' file not found
It seems ocl.hpp
has mysteriously changed locations and is now found in opencv2/ocl/ocl.hpp
.
Big thanks to @ManxStef, the first part of this guide is a literal copy and paste from his Catalina guide.
Install the Xcode commandline tools if you need to
xcode-select --install
note that opencv@2 depends on ffmpeg now so it gets installed automatically - see https://formulae.brew.sh/formula/opencv@2
brew install opencv@2
Install pip, which'll then let us install virtualenv
sudo easy_install pip
pip install virtualenv
Note that it'll give you the following info, which we can ignore for now WARNING: The script virtualenv is installed in '/Users/yourusername/Library/Python/2.7/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
cd to wherever you want to put your code, e.g. cd ~
, then clone the butterflow source
git clone https://github.com/dthpham/butterflow.git
Create the virtualenv - we'll just refer to the newly-install virtualenv binary directly instead of adding it to our PATH like the warning above says. Note that python
has been renamed to python2
and python3
in Big Sur, as far as I know, so we want virtualenv to use python2
~/Library/Python/2.7/bin/virtualenv -p /usr/bin/python2 butterflow
Navigate into the folder
cd butterflow
Tell butterflow where the homebrew python site-packages are by using a .pth file
echo "$(brew --prefix)/lib/python2.7/site-packages" > lib/python2.7/site-packages/butterflow.pth
activate the virtualenv
source bin/activate
now we're inside the virtualenv, set the compile flags so the clang compiler knows where things are
export LDFLAGS="-L/usr/local/opt/opencv@2/lib -L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/opencv@2/include"
export PKG_CONFIG_PATH="/usr/local/opt/opencv@2/lib/pkgconfig"
export PYTHONPATH=$PYTHONPATH:$(brew --prefix)/lib/python2.7/site-packages
Now, because of a mysterious relocation of an opencv@2
header file, we need to make a symbolic link to where butterflow expects it to be:
ln -s /usr/local/opt/opencv@2/include/opencv2/ocl/ocl.hpp /usr/local/opt/opencv@2/include/opencv2/core/ocl.hpp
Finally, we are ready to install. Hold onto your butt:
python2 setup.py install
In the dependencies section, it says:
macOS:
Install Homebrew, then
brew install ffmpeg
andbrew install homebrew/science/opencv --with-ffmpeg
.The homebrew/science branch was deprecated as all formulae were moved elsewhere. The closest package I could find by name was
opencv@2
by simply doingbrew install opencv@2
however--with-ffmpeg
is an invalid option when I tried substituting with this.(edit: overlooked package
opencv
because I'm stupid but same invalid option error thrown)