Yocto and OpenCV for I.MX

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

Yocto and OpenCV for I.MX

Jump to solution
26,009 Views
ssinfod
Contributor IV

I'm planning to use OpenCV in a Yocto distribution for a I.MX 5 or I.MX 6 board. (I have the following: I.MX 53 QSB or I.MX6 sabrelite (BD-SL-i.MX6) or Wandboard)

Do you know if that is supported ? What image should I use ?

If not what is the package to use ?

In short, I want to create a software that is recording image from a webcam or CSI camera. (and possibly doing some processing with OpenCV)

Can I do this task with Yocto and the I.MX hardware ?

Thanks

ssinfod

Labels (3)
1 Solution
9,886 Views
varsmolta
Contributor V

bitbake opencv - for building opencv

bitbake opencv-samples for building the samples.

then use gstreamer to get the frames from the camera and operate on them using opencv functions

View solution in original post

21 Replies
9,822 Views
ashab
Contributor I

Hi,

I tried building yocto (core-image-minimal) for imx6 with opencv in it. But I have encountered "unzip-native / unzip_6.0 do_compile failed" error. can any one suggest on how to overcome this problem?

Awaiting reply, Thanks in advance!

0 Kudos
Reply
9,817 Views
daiane_angolini
NXP Employee
NXP Employee

I don't know this error. Do you have the complete log?

0 Kudos
Reply
9,853 Views
alper
Contributor I

Thank you for reply.

Then i should do copy-paste after we should use bitbake opencv right?

Regards.

Alper

0 Kudos
Reply
9,853 Views
LuisCasado
NXP Employee
NXP Employee

Hi,

Add the two lines in your conf

MACHINE ??= 'imx6qsabresd'

DISTRO ?= 'poky'

PACKAGE_CLASSES ?= "package_rpm"

EXTRA_IMAGE_FEATURES = "debug-tweaks dev-pkgs"

CORE_IMAGE_EXTRA_INSTALL += "gpu-viv-bin-mx6q gpu-viv-bin-mx6q-dev"

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

USER_CLASSES ?= "buildstats image-mklibs image-prelink"

PATCHRESOLVE = "noop"

BB_DISKMON_DIRS = "\

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

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

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

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

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

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

PACKAGECONFIG_pn-qemu-native = "sdl"

ASSUME_PROVIDED += "libsdl-native"

CONF_VERSION = "1"

BB_NUMBER_THREADS = '4'

PARALLEL_MAKE = '-j 4'

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

ACCEPT_FSL_EULA = ""

LICENSE_FLAGS_WHITELIST = "commercial"

Build your image (bitbake <image>

And your rootfs will include all the need libraries to Run OpenCV applications.

Luis

0 Kudos
Reply
9,853 Views
alper
Contributor I

Thank you.

Alright. I want to use SDK for opencv.. Which SDK do you advice me?

Alper

0 Kudos
Reply
9,853 Views
LuisCasado
NXP Employee
NXP Employee

Hi,

You should generate and install your SDK for your image.

bitbake -c populate_sdk <image_name>

Luis

0 Kudos
Reply
9,853 Views
alper
Contributor I

Hi,

How can i enable opencv? I did bitbake opencv but i didnt see like:

  MACHINE ??= 'imx6qsabresd'

    DISTRO ?= 'poky'

    PACKAGE_CLASSES ?= "package_rpm"

    EXTRA_IMAGE_FEATURES = "debug-tweaks dev-pkgs"

    USER_CLASSES ?= "buildstats image-mklibs image-prelink"

    PATCHRESOLVE = "noop"

    BB_DISKMON_DIRS = "\

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

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

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

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

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

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

    PACKAGECONFIG_pn-qemu-native = "sdl"

    ASSUME_PROVIDED += "libsdl-native"

    CONF_VERSION = "1"


    BB_NUMBER_THREADS = '4'

    PARALLEL_MAKE = '-j 4'


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

    ACCEPT_FSL_EULA = ""


    CORE_IMAGE_EXTRA_INSTALL += "gpu-viv-bin-mx6q gpu-viv-bin-mx6q-dev"

    CORE_IMAGE_EXTRA_INSTALL += "libopencv-core-dev libopencv-highgui-dev

libopencv-imgproc-dev libopencv-objdetect-dev libopencv-ml-dev"


    LICENSE_FLAGS_WHITELIST = "commercial"

What should i do?

Regards.

Alper Kağıtcı

0 Kudos
Reply
9,853 Views
LuisCasado
NXP Employee
NXP Employee

Hello,

You can add in local.conf:

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

CORE_IMAGE_EXTRA_INSTALL += "opencv-apps opencv-dev python-opencv python-modules”

And bitbake the image.

Luis

0 Kudos
Reply
9,853 Views
andre_silva
NXP Employee
NXP Employee

you can use this tutorial to go through it step by step:

http://imxcv.blogspot.com.br/2014/02/building-opencv-24x-for-freescales-imx6.html

regards,

Andre

0 Kudos
Reply
9,853 Views
gonewithwind
Contributor I

hi Andre,

Hi, I am using imx6dlsabresd development board, not usb camera. I want to use gstreamer in opencv like that:

=======================code

int main(int, char**)
{

VideoCapture cap("gst-launch-1.0 imxv4l2src ! autovideosink ! appsink");
if(!cap.isOpened()) { // check if we succeeded
return -1;
}
for(;;)
{
Mat frame;

cap >> frame; // get a new frame from camera
imshow("original", frame);
waitKey(1);
}
// the camera will be deinitialized automatically in VideoCapture destructor
cap.release();

}

 

======================= code end.

 

but It only show a static image. not video streaming data. what happened?

and then I used code here: v4l_opencv_wrapper/camera_test.c at master · andreluizeng/v4l_opencv_wrapper · GitHub  it's working,but it's slow!

so I still want to try to use gstreamer in opencv. how can I do? why not video streaming data?

Thank you very much for your reply very soon

0 Kudos
Reply
9,852 Views
andre_silva
NXP Employee
NXP Employee

Hi Peter,

I never capture directly using Gstreamer into a cv Mat yet (since the cv capture does it for us). But you will need to capture in the correct format using gstreamer (RGB/BGR,YUV), then you will create a cv Mat and point its data pointer to the gst buffer. I recommend you creating a very small app using gstreamer first, deal with the gst buffer and just then you add cv and try to work on this data.

cheers,

Andre

0 Kudos
Reply
9,852 Views
gonewithwind
Contributor I

Hi Andre,

Thank you very much. now I directly use VPU and IPU code in mxc_vpu_test and your display code I mentioned before.

peter

9,853 Views
frank_zhang
NXP Employee
NXP Employee

Hi, Andre,

     We are working on a demo project on i.MX6qsabresd platform. We planned to use OpenCV(2.4.6) recipe in Yocto release(1.5.2 and 1.6.1) and followed the link" Computer Vision on i.MX Processors: Building OpenCV-2.4.X for Freescale's i.MX6 BSP (Yocto) "step by step. Unfortunately ,we got errors in the last step "$DISPLAY=: ./camera_test", the error is

root@imx6qsabresd:/media/sda1# ./camera_test
HIGHGUI ERROR: libv4l unable to ioctl S_FMT
HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT

Error creating capture


Do you ever have this problem or have some suggestions to us?


Many thanks!


Yao



0 Kudos
Reply
9,853 Views
andre_silva
NXP Employee
NXP Employee

Hi Yao,

answered by email.

regards,

Andre

0 Kudos
Reply
9,853 Views
manjunathjoshi
Contributor V

Hello ssinfod,

i really hope you got what you were looking for.

Because, OpenCV can be installed with addition of packages to the image you are already building. Which is the image you want to build? As Leo said you must check for the particular layer which can give you OpenCV related bitbake file. Only then you will be able to add and build.

you may find in meta-openembedded/meta-oe/recipes-support/opencv/

Regards,

Manju

0 Kudos
Reply
9,850 Views
ssinfod
Contributor IV

I found this webpage: http://packages.yoctoproject.org/

Is it the "official" list of package for the I.MX processor ?

Also, What is the package manager in Yocto ?

Finally, I don't see OpenCV in this list..

Does it mean I will have to compile OpenCV from the source on the I.MX ?

Did anybody was able to use OpenCV in Yocto ?

Thanks

ssinfod

0 Kudos
Reply
9,850 Views
LeonardoSandova
Specialist I

If you are looking for packages from a browser, I think this is the page OpenEmbedded metadata index - recipes

For the package manager, you mean the package manager inside a Linux Image produced by Yocto? otherwise it is bitbake :smileyhappy:

No idea about the OpenCV stuff...

Leo

0 Kudos
Reply
9,850 Views
ssinfod
Contributor IV

Yes, I mean the package manager inside the Linux image.

For example, in debian or ubuntu, I would type:

sudo apt-get install opencv

Then, the OS package manager (apt) would install the package OpenCV.

So, is there something equivalent in Yocto?

What is the package manager in Yocto and what are the package availables ?

ssinfod

0 Kudos
Reply
9,887 Views
varsmolta
Contributor V

bitbake opencv - for building opencv

bitbake opencv-samples for building the samples.

then use gstreamer to get the frames from the camera and operate on them using opencv functions

9,850 Views
bennygato
Contributor I

Hi varsmolta,

your answer seems to be the simplest one! I really hope I can follow your advice and install opencv, but the truth is I'm really a newbie to Yocto and linux. So please bear with me for a moment. thanks in advance!

So  I wonder where I should run "bitbake opencv", on host machine or on board (with Yocto)?

I've already build an Yocto image (fsl-image-multimedia) and can boot it on my wandboard. But I don't know what to do...

thanks!

Best,

Zoe

0 Kudos
Reply