Run OpenCV on Wayland/Weston Yocto

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Run OpenCV on Wayland/Weston Yocto

3,103 Views
JD11
Contributor I

Hello,

I am a little bit new to using the Yocto build environment. I am trying to include OpenCV in a Yocto distribution for I.MX 8 board to work with the librealsense library (included the yocto layer inside build) and implement the IR sample example. I included the example in the build using Cmake. The image is built successfully and the IR_sample.cpp program is included. But when running the IR_sample app I keep getting an opencv error (see below). I see that libgtk-3.so.0 is included in my libraries but not anything referring to libgtk2. 

I thought that adding "-DWITH_QT=OFF -DWITH_GTK=ON" to cmake commands would fix the issue but that did not work and the same error occurred. I am not sure if there is some issue with using OpenCV on wayland/weston.

 

Please let me know of any good recommendations that I could try. Thanks!

----------------------------------------------------------

Error: 

terminate called after throwing an instance of 'cv::Exception'

     what():   OpenCV(4.5.2) ../../highgui/src/windo.cpp:662: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'.

Build Configuration:

BB_VERSION = 1.50.0

BUILD_SYS = x86_64-linux

NATIVELSBSTRING = universal

TARGE_SYS = aarch64-poky-linux

MACHINE = sm2s-imx8mp

DISTRO = poky

DISTRO_VERSION = 3.3

DISTRO_FEATURES = Qt5 + Wayland + Weston

 

Bitbake Recipe: 

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://CMakeLists.txt \
file://IR_sample.cpp "

S = "${WORKDIR}"

inherit pkgconfig cmake

LDFLAGS_append += "-L${WORKDIR}/lib"
TARGET_CC_ARCH += "${LDFLAGS}"

# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OECMAKE = "-DWITH_QT=OFF -DWITH_GTK=ON"

 

# Package dependency declaration
DEPENDS += "opencv librealsense2"
RDEPENDS_${PN} = "opencv librealsense2"

 

CMakeLists.txt File: 

cmake_minimum_required(VERSION 2.8)
project (IR_sample)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#Bring the headers, into the project
find_package( OpenCV REQUIRED ) # locate OpenCV in system
find_package( realsense2 REQUIRED ) # locate realsense2 in system

include_directories(include ${OpenCV_INCLUDE_DIRS} ${realsense_INCLUDE_DIR})

add_executable(IR_sample IR_sample.cpp)

target_link_libraries(IR_sample ${realsense2_LIBRARY} ${OpenCV_LIBS})

install(TARGETS IR_sample RUNTIME DESTINATION bin)

0 Kudos
4 Replies

2,498 Views
azhar
Contributor III

If you are building latest yocto bsp, add this in your local.conf file for support for GTK+.

PACKAGECONFIG:append:pn-opencv = " gtk"

3,098 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

@JD11 

Try to rebuild opencv with this config

WITH_GTK=ON -D WITH_GTK_2_X=ON

 

0 Kudos

3,080 Views
JD11
Contributor I

@Zhiming_Liu 

I attempted that config and that did not seem to work. I've included the changes I made to EXTRA_OECMAKE variable below. I believe that this is where I can add options to CMake but I am not sure if there is something I am doing wrong with the config.

Any other recommendations?

# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OECMAKE = "-DWITH_QT=OFF -DWITH_GTK=ON -DWITH_GTK_2_X=ON"

 

0 Kudos

2,641 Views
WolsYang
Contributor IV

Hi JD11,
I got the same issue on my i.mx8qxp.

Did you fix it? How?

0 Kudos