Ask Your Question
1

openCV and Pypy?

asked 2013-04-09 02:47:43 -0500

kfj gravatar image

Hi all!

I was wondering if there are any plans to make openCV available for Pypy? See

http://pypy.org/

Using openCV with Pypy would be a win-win situation: while openCV provides a vast collection of fast established vision code, Pypy can speed up infrastructure code and experimental processing routines written in Python - often by a factor of ten, but at times even much more.

Pypy is now quite mature, and it's version of numpy (called numpypy) already provides a good deal of numpy functionality.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-12-04 15:58:54 -0500

gareins gravatar image

As of Pypy 5.9, OpenCV just works. Instructions for usage in virtual environment:

  • make virtual environment with virtualenv -p /usr/bin/pypy3
  • activate venv
  • clone numpy repository and install with python setup.py build && python setup.py install
  • copy pypy library into virtual environment and change its name, so that opencv finds it with cp /usr/lib/libpypy3-c.so $VIRTUAL_ENV/libpython3.5.3.so
  • clone opencv repository and add these flags to cmake:
    • -D PYTHON_EXECUTABLE=$VIRTUAL_ENV/bin/python3
    • -D PYTHON_LIBRARY=$VIRTUAL_ENV/libpython3.5.3.so
  • make
  • copy cv2 shared object into venv's site-packages cp lib/python3/cv2.pypy3-59-x86_64-linux-gnu.so ~/.pypyenv/site-packages/
  • check installation with python -c "import cv2"
edit flag offensive delete link more

Comments

I am getting this error after following your instruction:

Python 3.5.3 (d72f9800a42b, Oct 04 2017, 12:23:49)
[PyPy 5.9.0-beta0 with GCC 6.2.0 20160901] on linux
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``JIT compilers should be written
by people who actually have faith in JIT compilers' ability to makes things go
screaming fast''
>>>> import numpy
>>>> import cv2
RPython traceback:
  File "pypy_module_cpyext_2.c", line 7091, in type_realize
  File "pypy_module_cpyext_2.c", line 13724, in _type_realize
Fatal RPython error: AssertionError
Aborted (core dumped)

Any idea?

I used OpenCV 3.3 at the moment.

Shane Carlyon gravatar imageShane Carlyon ( 2018-10-12 04:55:25 -0500 )edit

@Shane, just saying, the question is from 2013...

and opencv is NOT using pypy to build the python wrappers at all. imho, you're far better off, by either

  • do a straight pip install opencv_contrib_python
  • or build from (latest !) src (with opencv_contrib) like mentioned here

in any case, try with a more recent version than 3.3 (we're at 3.4.3 now, that's a year difference !)

berak gravatar imageberak ( 2018-10-12 05:11:52 -0500 )edit

Yeah, I already tried PyPy6.0 & OpenCV3.4, but no luck.

So I was wondering how @gareins had gotten it working.

Cheers.

Shane Carlyon gravatar imageShane Carlyon ( 2018-10-12 05:46:42 -0500 )edit
1

answered 2013-04-09 03:19:53 -0500

Since we already support a range of standard devellopment platforms (C / C++ / Java / iOS / Android / Python) and devellopers are already drowning in the tons of implementation requests that they get each day, I am not expecting this to happen very soon.

Also I think it is just the way around, creating an adaptive language from a standard language, then requesting a standard library to support this adaptive language. What would seem a lot more logical to me is pypy helping to improve the python language :) But thats my point of vision.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-09 02:47:43 -0500

Seen: 5,378 times

Last updated: Dec 04 '17