Opencv install beaglebone ai

hi. problem install opencv2. (beagle bone ai )please help

sudo pip3 install opencv-python
[sudo] password for debian:
Collecting opencv-python
Downloading https://files.pythonhosted.org/packages/77/f5/49f034f8d109efcf9b7e98fbc051878b83b2f02a1c73f92bbd37f317288e/opencv-python-4.4.0.42.tar.gz (88.9MB)
99% |████████████████████████████████| 88.9MB 487kB/s eta 0:00:01Exception:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/pip/basecommand.py”, line 215, in main
status = self.run(options, args)
File “/usr/lib/python3/dist-packages/pip/commands/install.py”, line 353, in run
wb.build(autobuilding=True)
File “/usr/lib/python3/dist-packages/pip/wheel.py”, line 749, in build
self.requirement_set.prepare_files(self.finder)
File “/usr/lib/python3/dist-packages/pip/req/req_set.py”, line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File “/usr/lib/python3/dist-packages/pip/req/req_set.py”, line 620, in _prepare_file
session=self.session, hashes=hashes)
File “/usr/lib/python3/dist-packages/pip/download.py”, line 821, in unpack_url
hashes=hashes
File “/usr/lib/python3/dist-packages/pip/download.py”, line 659, in unpack_http_url
hashes)
File “/usr/lib/python3/dist-packages/pip/download.py”, line 902, in _download_http_url
_download_url(resp, link, content_file, hashes)
File “/usr/lib/python3/dist-packages/pip/download.py”, line 603, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File “/usr/lib/python3/dist-packages/pip/utils/hashes.py”, line 46, in check_against_chunks
for chunk in chunks:
File “/usr/lib/python3/dist-packages/pip/download.py”, line 571, in written_chunks
for chunk in chunks:
File “/usr/lib/python3/dist-packages/pip/utils/ui.py”, line 139, in iter
for x in it:
File “/usr/lib/python3/dist-packages/pip/download.py”, line 560, in resp_read
decode_content=False):
File “/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/response.py”, line 432, in stream
data = self.read(amt=amt, decode_content=decode_content)
File “/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/response.py”, line 380, in read
data = self._fp.read(amt)
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py”, line 63, in read
self._close()
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py”, line 50, in _close
self.__callback(self.__buf.getvalue())
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/controller.py”, line 275, in cache_response
self.serializer.dumps(request, response, body=body),
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py”, line 55, in dumps
“body”: _b64_encode_bytes(body),
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py”, line 12, in _b64_encode_bytes
return base64.b64encode(b).decode(“ascii”)
File “/usr/lib/python3.5/base64.py”, line 59, in b64encode
encoded = binascii.b2a_base64(s)[:-1]
MemoryError

Just do it with: sudo apt-get install python3-opencv This will take just a few seconds.

It’s a massive headache to do it via pip3 install. The first speedbump you’ve hit is basically an out-of-memory error, which can be fixed by deallocating memory from the C66/EVE systems. You then get into issues installing prerequisites and have to wait while it builds things from scratch.

hi thanks. reply

debian@beaglebone:~$ sudo apt-get install python3-opencv
Reading package lists… Done
Building dependency tree
Reading state information… Done
python3-opencv is already the newest version (3.2.0+dfsg-4.1rcnee0~stretch+20180817).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
debian@beaglebone:~$ python3
Python 3.7.3 (default, Jan 24 2021, 20:27:33)
[GCC 6.3.0 20170516] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘cv2’

debian@beaglebone:~$ sudo pip3 uninstall python3-opencv
Cannot uninstall requirement python3-opencv, not installed
debian@beaglebone:~$

I have a setup script for each of my beaglebone/rasberry pi’s

You may find it helpful. Comment out or modify any part you don’t find useful:

In case you are new to Linux, after you create the file on beagle bone, do the following to run.

Option 1;
chmod setup.sh +x
./setup.sh

Option 2:
bash setup.sh

(Obviously, you can name the file anything you want)

Also, you may want to look at what I’m installing and swap out things you want (i.e. editors vim vs nano). If you don’t want to change your hostname, then delete those lines.

This creates a 1g swapfile, I don’t think you have any hope of compiling cv on a beaglebone without one.

Lastly, the script is idempotent, so you can run it again without harm.

#!/bin/bash

if (hostname) | grep -iq “beaglebone-ai”; then
echo “hostname already set to ‘beaglebone-ai’ continuing”
else
echo “setting hostname to ‘beaglebone-ai’ then rebooting”
sudo hostnamectl set-hostname beaglebone-ai
sudo sed -i.bak ‘s/beaglebone/beaglebone-ai/g’ /etc/hosts
sudo shutdown -r now
fi

if [ -e /swapfile ]; then
echo “Found swapfile, not creating.”
else
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sh -c “echo -e ‘\n/swapfile swap swap defaults 0 0\n’>> /etc/fstab”
echo “swapfile created.”
fi

#Set timeszone to EST
#To list timezones: timedatectl list-timezones
sudo timedatectl set-timezone America/New_York

#Update and Upgrade
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove

#INSTALL THE DEPENDENCIES

#Build tools and useful commands:
sudo apt-get install -y build-essential cmake vim curl software-properties-common nmap htop iftop tree

#Media I/O:
sudo apt-get install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev

#Video I/O:p
sudo apt-get install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev libdigest-sha-perl

#Parallelism and linear algebra libraries:
sudo apt-get install -y libtbb-dev libeigen3-dev

#Python:
sudo apt-get install -y python3-dev python3-tk python3-numpy python3-pip
pip3 install --upgrade pip
pip3 install scikit-build
pip3 install opencv-python

#Adafruit BBIO Library:
pip3 install Adafruit_BBIO

#v4l2 Library:
pip3 install v4l2

I will test
Thankyou