Monday, April 25, 2016

UPDATE - Building OpenCV-2.4.X for Freescale's i.MX6 BSP (Yocto)

Just updating some information of an old post:  http://imxcv.blogspot.com.br/2014/02/building-opencv-24x-for-freescales-imx6.html

you can base your local.conf on the following one:


 
MACHINE ??= 'imx6qpsabreauto'

DISTRO ?= 'fsl-imx-fb'

PACKAGE_CLASSES ?= "package_rpm"

EXTRA_IMAGE_FEATURES = "debug-tweaks"

USER_CLASSES ?= "buildstats image-mklibs"

PATCHRESOLVE = "noop"

BB_DISKMON_DIRS = "\

    STOPTASKS,${TMPDIR},1G,100K \

    STOPTASKS,${DL_DIR},1G,100K \

    STOPTASKS,${SSTATE_DIR},1G,100K \

    STOPTASKS,/tmp,100M,100K \

    ABORT,${TMPDIR},100M,1K \

    ABORT,${DL_DIR},100M,1K \

    ABORT,${SSTATE_DIR},100M,1K \

    ABORT,/tmp,10M,1K"

PACKAGECONFIG_append_pn-qemu-native = " sdl"

PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"

ASSUME_PROVIDED += "libsdl-native"

CONF_VERSION = "1"



DL_DIR ?= "${BSPDIR}/downloads/"

ACCEPT_FSL_EULA = "1"



CORE_IMAGE_EXTRA_INSTALL += "libopencv-core-dev libopencv-imgproc-dev libopencv-objdetect-dev libopencv-ml-dev libopencv-calib3d-dev libopencv-highgui-dev"



LICENSE_FLAGS_WHITELIST = "commercial"


that will solve mostly of your issues.

EOF !

3 comments:

  1. rm-poky-linux-gnueabi-g++: fatal error: no input files
    compilation terminated.
    /bin/sh: 1: /opt/fsl-imx-fb/3.14.52-1.1.0/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/opencv: Permission denied
    when I compile the test.cpp,it ouccerd.
    and my makefile is writen like this:
    #before buildint it don't forget to export ROOTF_DIR and TOOLCHAIN (only if they are uncommented here)
    export SDKTARGETSYSROOT =/opt/fsl-imx-fb/3.14.52-1.1.0/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
    APPNAME = readpicture
    DESTDIR = ../bin
    SRCDIR = ../src

    CXX = $(CROSS_COMPILE)g++
    DEL_FILE = rm -rf
    CP_FILE = cp -rf

    ROOTFS_DIR = $(SDKTARGETSYSROOT)

    TARGET_PATH_LIB = $(ROOTFS_DIR)/usr/lib
    TARGET_PATH_INCLUDE = $(ROOTFS_DIR)/usr/include;$(ROOTFS_DIR)/usr/include/opencv;$(ROOTFS_DIR)/usr/include/opencv2;$(ROOTFS_DIR)/usr/include/c++




    # x11 flags
    ifeq ($(EGL_FLAVOR),x11)
    CFLAGS = -DLINUX -DUSE_SOC_MX6 -Wall -O2 -fsigned-char -march=armv7-a -mfpu=neon -mfloat-abi=hard \
    -DEGL_USE_X11 -DGPU_TYPE_VIV -DGL_GLEXT_PROTOTYPES -DENABLE_GPU_RENDER_20 \
    -I. -I$(TARGET_PATH_INCLUDE) \
    -I$(TARGET_PATH_INCLUDE)/glib-2.0 -I$(TARGET_PATH_LIB)/glib-2.0/include \
    -I$(TARGET_PATH_INCLUDE)/libxml2 \

    LFLAGS = -Wl,--library-path=$(TARGET_PATH_LIB),-rpath-link=$(TARGET_PATH_LIB) -lm \
    -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml \
    -L/usr/lib \
    -lusb-1.0 -lfreenect \
    -lEGL -lGLESv2 -lpthread



    # fb flags
    else
    CFLAGS = -DLINUX -DUSE_SOC_MX6 -Wall -O2 -fsigned-char -march=armv7-a -mfpu=neon -mfloat-abi=hard \
    -DEGL_API_FB -DGPU_TYPE_VIV -DGL_GLEXT_PROTOTYPES -DENABLE_GPU_RENDER_20 \
    -I. -I$(TARGET_PATH_INCLUDE) \
    -I$(TARGET_PATH_INCLUDE)/glib-2.0 -I$(TARGET_PATH_LIB)/glib-2.0/include \
    -I$(TARGET_PATH_INCLUDE)/libxml2 \

    LFLAGS = -Wl,--library-path=$(TARGET_PATH_LIB),-rpath-link=$(TARGET_PATH_LIB) -lm \
    -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml \
    -L/usr/lib \
    -lusb-1.0 -lfreenect \
    -lEGL -lGLESv2 -lpthread


    endif


    OBJECTS = $(APPNAME).o

    first: all

    all: $(APPNAME)

    $(APPNAME): $(OBJECTS)
    $(CXX) $(LFLAGS) -o $(DESTDIR)/$(APPNAME) $(OBJECTS)

    $(APPNAME).o: $(APPNAME).cpp
    $(CXX) $(CFLAGS) -c -o $(APPNAME).o $(APPNAME).cpp


    clean:
    $(DEL_FILE) $(SRCDIR)/$(OBJECTS)
    $(DEL_FILE) $(DESTDIR)/$(OBJECTS)
    $(DEL_FILE) $(DESTDIR)/*~ $(DESTDIR)/*.core
    $(DEL_FILE) $(DESTDIR)/$(APPNAME)

    distclean: clean
    $(DEL_FILE) $(DESTDIR)/$(APPNAME)

    install: all
    #${CP_FILE} $(SRCDIR)/$(APPNAME) $(DESTDIR)/$(APPNAME)
    #${CP_FILE} $(DESTDIR)/$(APPNAME) $(ROOTFS_DIR)/home/opencv

    ReplyDelete
  2. Hi,

    you don't need to export SDKTARGETSYSROOT , you just need to export ROOTFS_DIR and source the environment-setup script located at your /opt/poky... toolchain folder.

    ReplyDelete
  3. Dear,
    I am trying to run a simple Camera example using opencv and Yocto.
    I have built Yocto Krogoth for our custom board running i.MX6 and everything is fine. I added the opencv packages as you described in your post and I can see them in the final image.

    Finally, I downloaded your sample application (https://github.com/andreluizeng/opencv-camera-test---i.MX6-Yocto) and tryied to compile it, but I got C++ errors:
    http://pastebin.com/YY9eWBpi

    I edited the Makefile to use the G++ compiler from the SDK generate by Yocto (changing from $(CC) to $(CXX)). I could go further and I am getting a missing header error:
    usr/include/opencv2/core/hal/interface.h:19:19: fatal error: cstddef: No such file or directory

    I could see that Krogoth is enforcing opencv3.1 (2.4 is blacklisted). Could it be an issue?

    Thank you!

    ReplyDelete