0

I am new to Yocto project. I am using SAM9X60-EK as my target, and I want to add opencv to my image. I noticed that there is opencv included with meta-oe but when I add IMAGE_INSTALL:append = " opencv" to my core-image-sato.bbaappend file it gives me error, so I decided to write a recipee to download and install from source distribution.

I have installed the required dependency as following

IMAGE_INSTALL:append = " python3"
IMAGE_INSTALL:append = " python3-pip"
IMAGE_INSTALL:append = " python3-numpy"
IMAGE_INSTALL:append = " opencv"

here is my opencv_4.8.0.bb


SRC_URI = "file://opencv-python-4.8.0.76.tar.gz"

S = "${WORKDIR}"

 

# Add Python as a dependency

DEPENDS += "python3 cmake python3-pip"

 

do_unpack() {

    tar -xvf ${FILE_DIRNAME}/opencv-python-4.8.0.76.tar.gz -C ${S}

}

 

do_install() {

    install -d ${D}${bindir}

    cp -r ${S}/opencv-python-4.8.0.76/* ${D}${bindir}

   

    # Run the setup.py script for installation

    cd ${D}${bindir}

    python3 setup.py install --root=${D}

}

 

PACKAGES =+ "opencv_python"

FILES_${PN} += "${bindir}/setup.py"

when I run bitbake opencv I get the following error

 DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_install
| /usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
|   warnings.warn(
| Traceback (most recent call last):
|   File "/home/snishuz/.local/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 645, in setup
|     cmkr = cmaker.CMaker(cmake_executable)
|   File "/home/snishuz/.local/lib/python3.10/site-packages/skbuild/cmaker.py", line 148, in __init__
|     self.cmake_version = get_cmake_version(self.cmake_executable)
|   File "/home/snishuz/.local/lib/python3.10/site-packages/skbuild/cmaker.py", line 105, in get_cmake_version
|     raise SKBuildError(msg) from err
|
| Problem with the CMake installation, aborting build. CMake executable is cmake
| WARNING: exit code 1 from a shell command.

Edit:

After @skandigraun comment I tried to use the recipee included in meta-oe

I got the following error

Nishuthan S
  • 1,538
  • 3
  • 12
  • 30
  • When you specify `cmake` in the DEPENDS variable, it uses the cross-compiled version of cmake, which most probably not what you want. Try `cmake-native`. Or rather, are you sure you want to deal with the random errors you are generating, instead of finding out the problem you are facing with the recipe in meta-oe? Chances are, if you write the correct recipe, you will get the same error at the end of the day... – skandigraun Aug 29 '23 at 09:47
  • What if you create a bbappend for the original opencv recipe, and set `OECMAKE_CXX_LINK_FLAGS += " -latomic"` in it? – skandigraun Aug 30 '23 at 04:28
  • Are you sure you got the correct opencv recipe matching your Yocto release ? Which Yocto release are you using ? – Martin Aug 30 '23 at 09:50

1 Answers1

0

I think, you do not need to write an own custom recipe, lets try the following:

IMAGE_INSTALL:append = " python3-opencv"

I think python3-opencv is integrated in opencv general recipe. http://cgit.openembedded.org/meta-openembedded/tree/meta-oe/recipes-support/opencv/opencv_4.8.0.bb?h=master#n192

Livius
  • 198
  • 4
  • It does not work when I run `bitbake -e python3-opencv | grep ^PN=` it said nothing provides python3-opencv – Nishuthan S Aug 30 '23 at 02:47
  • Can you test `PACKAGECONFIG:pn-opencv += "python3"` and `CORE_IMAGE_EXTRA_INSTALL += "python3-opencv"` ? – Livius Aug 30 '23 at 22:15