Skip to content

Instantly share code, notes, and snippets.

@furkantektas
Last active July 6, 2017 20:45
Show Gist options
  • Save furkantektas/84d4dbcc89d93f55b30494fa0c359c86 to your computer and use it in GitHub Desktop.
Save furkantektas/84d4dbcc89d93f55b30494fa0c359c86 to your computer and use it in GitHub Desktop.
Aruco on OSX Yosemite (python3 and OpenCV 3.2.0)

Assuming you're using brew

  brew install eigen swig numpy
  brew install opencv3 --with-contrib --with-python3 --without-python 
  git clone https://github.com/fehlfarbe/python-aruco.git
  cp swigbuild.sh swigbuild.sh.org
  cp setup.py setup.py.org

In this step, you need to make some changes on setup.py and swigbuild.sh . You can find the new versions of these files in this gist.

sh swigbuild.sh python3
python3 setup.py install

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from distutils.core import setup, Extension
sourcefiles = ['aruco_wrap.cxx']
aruco_module = Extension('_aruco',
sources=sourcefiles,
language="c++",
extra_compile_args=["-std=c++11", "-Wall","-Wno-c++11-narrowing",],
include_dirs=["/usr/local/include/opencv2", "/usr/include/eigen3/", ".", "/usr/local/lib/python3.6/site-packages/numpy/core/include/","/usr/local/include/eigen3"],
libraries=["opencv_core", "opencv_imgproc", "opencv_calib3d", "opencv_highgui", "aruco"],
library_dirs=["/usr/local/lib"])
setup(name='aruco',
version='2.0',
author="""ArUco: Rafael Muñoz Salinas, Python wrappers: Marcus Degenkolbe""",
description="""ArUco Python wrappers""",
ext_modules=[aruco_module],
py_modules=["aruco"],
)
#!/bin/bash
if [ $1 == python3 ]
then
SWIG_PYTHON="python -py3"
PYTHON_INTERPRETER="python3"
else
SWIG_PYTHON="python"
PYTHON_INTERPRETER="python"
fi
# clean
rm aruco.py
rm aruco_wrap.*
rm _aruco.so
rm -r aruco/
# copy aruco source code
cp -r /usr/local/include/aruco .
# patch it
patch -p0 < namespaces.patch
# creates wrapper and builds shared library
swig -c++ -${SWIG_PYTHON} aruco.i && ${PYTHON_INTERPRETER} setup.py build_ext --inplace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment