You are not logged in.

#1 2019-02-10 23:48:24

uchajk
Member
Registered: 2018-05-20
Posts: 13

OpenCV with OpenGL support [SOLVED]

$ pip install opencv-contrib-python

this will not install opencv with opengl support, because apparently it is built by default WITH_OPENGL=OFF.
I went ahead and cloned opencv git and built it myself like such:

$ cmake -S /home/ucha/tmp/opencv -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/ucha/.virtualenvs/project/lib/python3.7/site-packages -D WITH_QT=ON -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=/home/ucha/tmp/opencv_contrib/modules
$ make
$ sudo make install

I thought everything went fine, but then I try to import cv2 and it says "no module named cv2".
I tried

find /home/ucha/.virtualenvs/project cv2.so

and it's nowhere to be found.
what am I doing wrong?

Last edited by uchajk (2019-02-12 03:14:43)

Offline

#2 2019-02-11 07:25:41

arojas
Developer
From: Spain
Registered: 2011-10-09
Posts: 2,098

Re: OpenCV with OpenGL support [SOLVED]

Any reason you are not using the official package?

Offline

#3 2019-02-11 11:30:18

Potomac
Member
Registered: 2011-12-25
Posts: 528

Re: OpenCV with OpenGL support [SOLVED]

Hello Uchajk,

it's not clear what you want to do, it seems you use a wrong and complex strategy for using opencv in python3 in archlinux,

you have just to install the opencv archlinux package :
https://www.archlinux.org/packages/extra/x86_64/opencv/

this archlinux package will install the opencv python module in this path :

usr/lib/python3.7/site-packages/cv2.cpython-37m-x86_64-linux-gnu.so

then run python3, and type :

import cv2
print(cv2.__version__)

you should see as output :

4.0.1

if you notice a problem with the archlinux package version of opencv then you can custom the PKGBUILD (enabling some options, note that there is already "-DWITH_OPENGL=ON" option in the cmake command, so the openGL option is already activated in the archlinux version of opencv), and rebuild the package, it's easy with makepkg command :

https://git.archlinux.org/svntogit/pack … ges/opencv

Last edited by Potomac (2019-02-11 11:38:30)

Offline

#4 2019-02-12 02:47:16

uchajk
Member
Registered: 2018-05-20
Posts: 13

Re: OpenCV with OpenGL support [SOLVED]

arojas wrote:

Any reason you are not using the official package?

I wanted to install it in my virtualenv only not globally.


Potomac wrote:

this archlinux package will install the opencv python module in this path :

is there an option to install it in my virtualenv instead? Would I just move the folder from /usr/lib/python3.7/site-packages to ~/.virtualenvs/project/lib/python3.7/site-packages ?

That worked. Thank you!

Last edited by uchajk (2019-02-12 03:13:39)

Offline

Board footer

Powered by FluxBB