Robotpy-cscore fails to find opencv

Hello,

I’m having trouble installing robotpy-cscore. I’m following the instructions here. I’m trying to do this installation on an Ubuntu 18.04 machine.

When I give the command:

pip3 install robotpy-cscore

It fails during compilation with the error:

opencv2/opencv.hpp: No such file or directory

I installed OpenCV by following the instructions here

Following those instruction I gave the following commands:

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
git clone https://github.com/opencv/opencv.git
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j7
sudo make install

That leaves me with a /usr/local/include/opencv4/opencv2/ directory which has the opencv.hpp file in it. Can someone help me get this configured correctly so cscore can find the opencv installation?

Thanks for reading!
Joe

Simplest solution is not to specify a prefix when building OpenCV. It will install into “/usr” and then the python build should find it.

Otherwise you need to pass in extra options during the pip install. See here:

I modified my cmake command to be:
cmake -D CMAKE_BUILD_TYPE=Release ..

An excpert of the output… it looks like it will still install to /usr/local by default:

--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.6.7)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.6m.so (ver 3.6.7)
--     numpy:                       /home/ubuntu/.local/lib/python3.6/site-packages/numpy/core/include (ver 1.16.1)
--     install path:                lib/python3.6/dist-packages/cv2/python-3.6
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/FRC2019/opencv/build

Also when i use the --global-option args it gives me this warning:

pip3 install --global-option=build_ext --global-option="-I/usr/include/opencv4/" robotpy-cscore
/usr/lib/python3/dist-packages/pip/commands/install.py:212: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.

Why not clear the cached options, and then just try “cmake”. I don’t think you need the -D option.

As for the message in your second post, I believe you can ignore that, so you might be fine. Test if you can load “cv2” in Python.

If you’re on Ubuntu 18.04, I would recommend using the distro OpenCV packages and my pre-built robotpy-cscore package.

Note that CSCore does not support OpenCV 4.

Note that your original post showed that you cloned opencv from github, which would give you a version of OpenCV 4. This means it would not work with cscore at this time. You can checkout the 3.4 branch and build that if you like. However, as @auscompgeek said, you’re better off using the ubuntu prepackaged version of OpenCV.

Thanks to both of you. When I wrote the original post the forum suggested some possible related posts (very nice feature), one of which was auscompgeek’s. I did have success using his precomplied package, had me up and running the cscore examples… probably within just a few minutes. I decided to go ahead and submit the post anyway to see if I could learn how to compile it myself. I had suspected it was not compatible with opencv4 and downloaded the source for 3.x.x but when I tried to compile that my ubuntu 18.04 system it failed which is strange. I downloaded a tgz… I didn’t clone the git branch. Maybe I’ll try that. Thanks for the pre-compiled packages!

I’m having trouble installing cscore on Ubuntu 16.04. OpenCV (3.4.5) installed and works fine with Python 3.5.2. When I try to install cscore with pip, it fails telling me that I don’t have numpy installed. Obviously that statement is erroneous, as numpy is required to build OpenCV. This is on a VM that our team uses to develop vision code.

I’m using Ubuntu 16.04, because we are using the Jetson TX1, and that’s the current version supported by nVidia. We had no problems last year. Not sure if this is an intel vs. arm thing, but looking for any insight that wiser souls can offer.

This is a quirk in how pip does things now… see the build instructions:

pip3 install --no-build-isolation robotpy-cscore

I tried that, too. Had a different failure, but certainly a clue. Apparently my setuptools module was out of date (was 36.7.2 now 40.8.0).

This let it build and successfully install. Leaving this reply as a breadcrumb for others who may trip on this.

Thank you for all your hard work on this!

Glad to hear it worked! I’ve updated the documentation with a note about setuptools.