UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
1,400 Views
Registered: ‎09-25-2018

ultra96 simple video opencv error

Jump to solution

hi,

I am using for ultra96 board for accelerate a vision algorithm, but when I try to run a simple opencv c++ code it gives me this error. this code totally run in PS(processor) part. I generated all the files using ultra96 bsp and petalinux.

please help

thanks

50285463_332251090962559_848206949483806720_n.jpg
0 Kudos
1 Solution

Accepted Solutions
Moderator
Moderator
1,059 Views
Registered: ‎04-24-2017

Re: ultra96 simple video opencv error

Jump to solution

Hi @1ymw1,

In petalinux just use the opencv recipes by default whatever is enabled from Yocto https://github.com/Xilinx/meta-petalinux/blob/rel-v2018.3/recipes-core/packagegroups/packagegroup-petalinux-opencv.bb

If you want to enable libv4l, libav configurations in opencv then you need to create a bbappend file as show below

$ mkdir -p <plnx-proj-root>/project-spec/meta-user/recipes-support/opencv
$ vim <plnx-proj-root>/project-spec/meta-user/recipes-support/opencv/opencv_%.bbappend

# opencv_%.bbappend
PACKAGECONFIG_append = "libv4l libav"

In general if you want to use libav then follow below steps.

1. Enable gstreamer packagegroup.

$ petalinux-config -c rootfs ---> Petalinux Package Groups ---> packagegroup-petalinux-gstreamer ---> [*] packagegroup-petalinux-gstreamer

2. Enable the GStreamer1.0-libav package and whitelist the license flag.

$ vim <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf

IMAGE_INSTALL_append = " gstreamer1.0-libav"
LICENSE_FLAGS_WHITELIST_append = " commercial_gstreamer1.0-libav"

3. Modify the device-tree to set the CMA(make sure you set appropriate) for video pipeline

$ vim <plnx-proj-root>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
 
 
# system-user.dtsi content
/include/ "system-conf.dtsi"
/ {
    chosen {
        bootargs = "earlycon clk_ignore_unused cma=1700M cpuidle.off=1";
        stdout-path = "serial0:115200n8";
    };
};

4. On Target use the below pipeline as example. In my case I have used File-> soft decode(libav) -> Display(using display prot).

root@zcu102-opencv:/run/media/mmcblk0p1# gst-launch-1.0 filesrc location=sintel_trailer-1080p.mp4 ! qtdemux name=demux demux.video_0 ! h264parse ! avdec_h264 ! queue max-size-bytes=0 ! kmssink bus-id=fd4a0000.zynqmp-display fullscreen-overlay=1
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:52.192526876
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
[  896.369727] PLL: shutdown
[  896.375165] PLL: enable
Freeing pipeline ...
root@zcu102-opencv:/run/media/mmcblk0p1#
I hope this will give some idea and proceed further.
 
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
13 Replies
Xilinx Employee
Xilinx Employee
1,343 Views
Registered: ‎08-20-2018

Re: ultra96 simple video opencv error

Jump to solution

Hi @1ymw1

Please try xfopencv examples,

https://github.com/Xilinx/xfopencv

Best Regards,
Nutan
-------------------------------------------------------------------------------
Please don't forget to reply, kudo and accept as a solution
Adventurer
Adventurer
1,332 Views
Registered: ‎09-25-2018

Re: ultra96 simple video opencv error

Jump to solution

hi @nutang

thanks for the reply. As far as I know, xfopencv is for use with sdsoc. But how can I use xfopencv with petalinux? (I know if I build a software platform with petalinux I can use it with sdsoc, is that what you mean?)it seems  petalinux is not capable for read video files, thats why v4l error occur. how can I enable it?

Thanks

0 Kudos
Xilinx Employee
Xilinx Employee
1,328 Views
Registered: ‎08-20-2018

Re: ultra96 simple video opencv error

Jump to solution

Hi @1ymw1

Yes, I just gave you an alternative.

Please refer https://www.xilinx.com/support/documentation/sw_manuals/xilinx2018_2/ug1144-petalinux-tools-reference-guide.pdf to enable v4l utilities in kernel 

Best Regards,
Nutan
-------------------------------------------------------------------------------
Please don't forget to reply, kudo and accept as a solution
Adventurer
Adventurer
1,273 Views
Registered: ‎09-25-2018

Re: ultra96 simple video opencv error

Jump to solution

hi @nutang

I read that document from top to bottom. But I couldnt find how to enable v4l in kernel, but instead of that I enabled v4l in rootfs(petalinux-config -c rootfs------->misc------->v4l-utils) and I enabled both v4l-utils and libv4l, but I still have the same problem.

0 Kudos
Moderator
Moderator
1,269 Views
Registered: ‎04-24-2017

Re: ultra96 simple video opencv error

Jump to solution

Hi @1ymw1,

Before running the opencv application did you verify the camera captures from command line.

v4l2-ctl --list-devices
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
Adventurer
Adventurer
1,248 Views
Registered: ‎09-25-2018

Re: ultra96 simple video opencv error

Jump to solution

hi @sandeepg

I am not trying to open a camera from opencv. I am trying to open a small video file using opencv.

Thanks

0 Kudos
Adventurer
Adventurer
1,214 Views
Registered: ‎09-25-2018

Re: ultra96 simple video opencv error

Jump to solution

hi @sandeepg , @nutang

any idea???

0 Kudos
Moderator
Moderator
1,195 Views
Registered: ‎04-24-2017

Re: ultra96 simple video opencv error

Jump to solution

Hi @1ymw1,

Can you post your application and recipe. In case if you are unable to make it public you can send it private message.

Are you sure you are parsing the video file path correctly?

Also can you try to play the avi file using ffplay.

We have caveat here if you are using gstreamer plugins to decode the video in your opencv app then Ultra96 doesn't have any video coder/decoder in this case you might need to use soft decoder like libav.

One more thing for video applications you need to reserve the cma in kernel as show below.

$ vim project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
 
 
# system-user.dtsi content
/include/ "system-conf.dtsi"
/ {
    chosen {
        bootargs = "earlycon clk_ignore_unused cma=768M ";
        stdout-path = "serial0:115200n8";
    };
};
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
Adventurer
Adventurer
1,177 Views
Registered: ‎09-25-2018

Re: ultra96 simple video opencv error

Jump to solution

hi @sandeepg,

Here is the  complete petalinux plyvideo app folder I use for play a video clip. And I have tried this with zedboard as well as ultra96. In both cases give the same error(as I have shown in above picture), but if I try with images(lena.jpg), it works without any problems. I have double checked whether the video file and plyvideo file in the same directory (usr/bin).

0 Kudos
Adventurer
Adventurer
1,161 Views
Registered: ‎09-25-2018

Re: ultra96 simple video opencv error

Jump to solution

hi @sandeepg, @nutang,

As my understanding so far(according to this post) v4l is a API for devices like camera, the existing petalinux opencv is built with v4l right? so it does not support for the files (like avi,mp4 etc). so if I want to use opencv for files I have to cross complie the opencv according to this    with ffmpeg enabled and v4l disabled right?, are there any other method to open a video file? please explain.

Thanks

0 Kudos
Adventurer
Adventurer
1,091 Views
Registered: ‎09-25-2018

Re: ultra96 simple video opencv error

Jump to solution

hi @sandeepg

can you please tell me how to include libav as you have mentioned here,

"We have caveat here if you are using gstreamer plugins to decode the video in your opencv app then Ultra96 doesn't have any video coder/decoder in this case you might need to use soft decoder like libav."

thanks

 

0 Kudos
Moderator
Moderator
1,060 Views
Registered: ‎04-24-2017

Re: ultra96 simple video opencv error

Jump to solution

Hi @1ymw1,

In petalinux just use the opencv recipes by default whatever is enabled from Yocto https://github.com/Xilinx/meta-petalinux/blob/rel-v2018.3/recipes-core/packagegroups/packagegroup-petalinux-opencv.bb

If you want to enable libv4l, libav configurations in opencv then you need to create a bbappend file as show below

$ mkdir -p <plnx-proj-root>/project-spec/meta-user/recipes-support/opencv
$ vim <plnx-proj-root>/project-spec/meta-user/recipes-support/opencv/opencv_%.bbappend

# opencv_%.bbappend
PACKAGECONFIG_append = "libv4l libav"

In general if you want to use libav then follow below steps.

1. Enable gstreamer packagegroup.

$ petalinux-config -c rootfs ---> Petalinux Package Groups ---> packagegroup-petalinux-gstreamer ---> [*] packagegroup-petalinux-gstreamer

2. Enable the GStreamer1.0-libav package and whitelist the license flag.

$ vim <plnx-proj-root>/project-spec/meta-user/conf/petalinuxbsp.conf

IMAGE_INSTALL_append = " gstreamer1.0-libav"
LICENSE_FLAGS_WHITELIST_append = " commercial_gstreamer1.0-libav"

3. Modify the device-tree to set the CMA(make sure you set appropriate) for video pipeline

$ vim <plnx-proj-root>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
 
 
# system-user.dtsi content
/include/ "system-conf.dtsi"
/ {
    chosen {
        bootargs = "earlycon clk_ignore_unused cma=1700M cpuidle.off=1";
        stdout-path = "serial0:115200n8";
    };
};

4. On Target use the below pipeline as example. In my case I have used File-> soft decode(libav) -> Display(using display prot).

root@zcu102-opencv:/run/media/mmcblk0p1# gst-launch-1.0 filesrc location=sintel_trailer-1080p.mp4 ! qtdemux name=demux demux.video_0 ! h264parse ! avdec_h264 ! queue max-size-bytes=0 ! kmssink bus-id=fd4a0000.zynqmp-display fullscreen-overlay=1
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:52.192526876
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
[  896.369727] PLL: shutdown
[  896.375165] PLL: enable
Freeing pipeline ...
root@zcu102-opencv:/run/media/mmcblk0p1#
I hope this will give some idea and proceed further.
 
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
Adventurer
Adventurer
1,040 Views
Registered: ‎09-25-2018

Re: ultra96 simple video opencv error

Jump to solution

Dear @sandeepg

you are not a human, you are a god.If you are living in LK I will find you and buy you a meal. it works prefectly now, but strangly I didnt do the thrird step you have mentioned here, but it works without device tree configuration. I use petalinux 2018.2.

thank you thank you thank you sooooo much.

0 Kudos