Reputation: 197
I have a bit of a problem when trying to use Aruco on Raspberry Pi 3.
I am using Python 3.5 on headless version of Raspbian and I followed this tutorial to install OpenCV with opencv_contrib - which as far as I understand contains all the packages:
https://www.pyimagesearch.com/2015/07/27/installing-opencv-3-0-for-both-python-2-7-and-python-3-on-your-raspberry-pi-2/
OpenCV installed without any problems, I can import it in Python and it works fine. I need to use Aruco for a project and when I try to import it I get this error:
Traceback (most recent call last):
File "<stdin>", line1, in <module>
ImportError: No module named 'cv2.aruco': 'cv2' is not a package
I had the same problem before so I flashed SD card and started with fresh installation, but it happens again. From the previous question I found here I tried to install opencv_contrib by using
pip install opencv-contrib-python
But I got the error:
Could not find a version that satisfies the requirement opencv-contrib-python (from versions: )
No matching distribution found for opencv-contrib-python
Did anybody encounter the same issue, or do you have any suggestions or how to fix that? Any help would be appreciated.
Upvotes: 1
Views: 4677
Reputation: 111
I followed the answer by Irek and have only some minor tweaks, I skipped step 3 and it worked fine, actually trying to do step 3 and I ran into issues. Also, after step 2 I run make && make install
instead of step 5. I am running this in a dockerfile building on an Ubuntu 20.04 image.
Upvotes: 0
Reputation: 197
EDIT: I found the perfect solution for the problem with installing additional modules for OpenCV. Previous solution required the manual copying of files from one github directory into another, and copied files had to be added manually into the txt file. This solution allows you to install all the modules without any copying etc. I am leaving my initial thoughts in the answer as they were, the only thing that is changing are the steps to follow. Please correct me if I did anything wrong in regards to editing, as I never had to edit my own answer before due to finding a better solution (as you may see, I'm quite new in here).
I managed to solve my problem and thought I will share my solution as a new answer, so it's easier for people to see, should anyone encounter the same problem in the future.
The solution works fine when there is only need to install few modules from opencv_contrib as it requires some copying.
The overall installation process requires following this tutorial https://www.pyimagesearch.com/2015/07/27/installing-opencv-3-0-for-both-python-2-7-and-python-3-on-your-raspberry-pi-2/
New process, after finding better solution:
Use cmake
command from the tutorial listed above to create installation files for OpenCV. My command looked like this:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
cmake -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
again make -j4
.I know it's simply duplicating a line that was included in cmake
before and I have no clue why it works after using this command again. If someone could explain why that happens, I would appreciate it and it would give me some understanding as to why it works. Again, I hope this answer helps anyone who goes through the same problem. Also, I'm sorry for editing this post twice, I thought it will be useful to show people more correct way of sorting this problem out.
Upvotes: 2