-
Notifications
You must be signed in to change notification settings - Fork 4
Home
pix_opencv
is a computer vision library for Puredata and Gem.
It's free and open-source and it uses OpenCV.
It is based on work by Yves Degoyon and Lluis Gomez i Bigorda.
You need to have puredata and Gem installed on your system. And you need to know where they are…
You also need a compiling toolchain, e.g. GCC on Linux/Mac or Microsoft Visual C++ on Windows.
You can download a source tarball here : https://github.com/avilleret/pix_opencv/releases.
The is a pix_opencv
folder in the externals folder of the Puredata SVN repository.
This is the primary version of pix_opencv
but as it is quite hard to maintain this version, I decided to fork it in Githud. Thus the latest sources are here : https://github.com/avilleret/pix_opencv
You can clone it :
git clone https://github.com/avilleret/pix_opencv
or fork it, or even download a snapshot.
The SVN repository will be updated on each release.
The easiest way to get it is to install it from the repository :
sudo apt-get install libopencv-*
The easiest way is to get from some packaging repository like Macports, fink or homebrew. with fink :
sudo fink install opencv-dev
with macport :
sudo port install opencv
with homebrew :
brew install opencv
Download the binary release on opencv.org You can follow the quickstart guide on opencv.org to setup environment variables.
Go to the fresh created folder, i.e. « pix_opencv ».
If you cloned the git repo, you first have to run ./autogen.sh
.
Then run those commands :
cd pix_opencv
./configure
make
If you see something like « can’t find m_pd.h », you need to tweak pd’s path with this command :
configure --with-pd=/path/to/pd
If you see something like « can’t find Base/GemPixObj.h », you need to tweak Gem’s path with this command :
configure --with-gem=/path/to/gem
You can combine options like :
configure --with-pd=/path/to/pd --with-gem=/path/to/gem
To see more option, run configure --help
.
On Mac OSX, depending on how pd
and Gem
are installed, you may have to add some options to ./configure
.
For example, on my MacBookPro under 10.9 I configure with this line :
./configure --with-pd=/Applications/Pd-extended.app/Contents/Resources/include/pdextended/ --with-gem=/Applications/Pd-extended.app/Contents/Resources/include/Gem/ CXXFLAGS="-arch i386" LDFLAGS="-arch i386"
The -arch i386
flag is needed since my OSX is 64bit whereas my Pdextended in 32bit.
Also I have to manually point to pd
and Gem
sources.
Then you can install the package in the pd/extra
directory with sudo make install
.
When using Homebrew you can install three different versions of OpenCV:
brew install opencv
installs opencv4
brew install opencv@3
installs opencv3
brew install opencv@2
installs opencv3
At the time of this writing I have been unable to get pix_opencv to compile against any of them but below will document attempts.
More recent builds against Pd vanilla x64 AND to find OpenCV v4 installed with Homebrew we might do something like this:
./configure OPENCV_CFLAGS="-I/usr/local/Cellar/opencv/4.2.0_3/include/opencv4" OPENCV_LIBS="-L/usr/local/Cellar/opencv/4.2.0_3/lib" CXXFLAGS="-std=c++11" --with-pd=/Applications/Pd.app/Contents/Resources/src/ --with-gem=/Users/megrimm/Documents/Pd/externals/Gem/stuff/include/Gem/
Unfortunately at this time pix_opencv builds fail against OpenCV4 and we are not sure when/if this will work. BUT in case you do want to attempt such a thing the above ./configure line will at least find OpenCV for you.
If you have a different version of opencv you have to modify the line accordingly to find your headers. To figure out what version you have you can do:
$ brew info opencv
You can then just change that first part to reflect where your install is.
Also, the below line is an example of how to configure if your Pd app has not been renemed and Gem is installed via deken to your Pd.app extras folder.
./configure OPENCV_CFLAGS="-I/usr/local/Cellar/opencv/4.3.0/include/opencv4" OPENCV_LIBS="-L/usr/local/Cellar/opencv/4.3.0/lib" CXXFLAGS="-std=c++11" --with-pd=/Applications/Pd-0.50-2.app/Contents/Resources/src/ --with-gem=/Applications/Pd-0.50-2.app/Contents/Resources/extra/Gem/include/Gem
You need Visual C++ (at least the free express edition) to build pix_opencv on Windows. There is a solution in build/vs2010 folder. It was made with Visual C++ Express 2010 and surely need some tweaks before producing any DLL. You need to change the include and the library paths. The include must contain the following :
- puredata include (pd-extended) or src (vanilla) folder : path\to\pd\src or path\to\pd-extended\include
- Gem include folder : path\to\Gem
- OpenCV include path, wich is ususally $(OPENCV_DIR)....\include if you setup OPENCV_DIR according to Windows quickstart guide on opencv.org.
From the pix_opencv
directory :
git submodule init
git submodule update
cd FaceTrakcer
make
Then re-run ./configure
and make
to add pix_opencv_facetracker
.
Some OpenCV feature are non-free, this mean the licence doesn't allow packaging for these.
Anyway, you can use them but you have to build OpenCV library yourself.
Refer to opencv website to learn how to build it.
Then you can re-run ./configure
and make
to add non-free feature support.
Currently, only pix_opencv_surf
is affected by this.
make dist
This archive is called "pix_opencv-VERSION". This archive must contains all sources files and headers, the build mechanism, and all other files needed to build it.
make libdir
This archive is called "pix_opencv-VERSION-TARGET". This archive must contains binary of VERSION for TARGET architecture.
Open the pix_opencv-help.pd
patch.
It shows an overview of all available externals.
And this tests the creation of each external.