cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
astromorgan
Observer
Observer
1,397 Views
Registered: ‎09-11-2019

OpenCV Neon optimization on PetaLinux 2019.1

Jump to solution

I'm building PetaLinux for the Zynq 7020. I have used the "petalinux-configure -c rootfs" to add opencv to the build, and this works fine.

When I run opencv applications in PetaLinux, I see that there is no NEON acceleration support. For example, running " std::cout << cv::getBuildInformation() << std::endl;" in my C++ app results in the following output:

General configuration for OpenCV 3.4.3 =====================================
  Version control:               unknown

  <snip>
CPU/HW features:
Baseline: NEON
requested: DETECT
disabled: VFPV3 NEON
<snip>

We would like to build OpenCV with NEON support enabled. How can we do that?

 

0 Kudos
Reply
1 Solution

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

Hi @astromorgan ,

All the compiler flags can be passed from recipes using EXTRA_OEMAKE or CMAKE options as shown 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 content
EXTRA_OECMAKE_append_zynq = " -DENABLE_NEON=ON -DENABLE_VFPV3=ON"

Now cleanall opencv and rebuild.

$ petalinux-build -c opencv -x cleanall
$ petalinux-build -c opencv
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
4 Replies
sandeepg
Moderator
Moderator
1,373 Views
Registered: ‎04-24-2017

Hi @astromorgan ,

By default we enable neon for Zynq-7000 in petalinux https://github.com/Xilinx/meta-xilinx/blob/rel-v2019.1/meta-xilinx-bsp/conf/machine/include/tune-zynq.inc#L1

Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
Reply
astromorgan
Observer
Observer
1,366 Views
Registered: ‎09-11-2019

Hi Sandeep,

 

I understand that NEON is enabled in PetaLinux OS in general. It looks to me like OpenCV doesn't use NEON unless it's compiled to. See here: https://docs.opencv.org/master/d0/d76/tutorial_arm_crosscompile_with_cmake.html

 

That page indicates there are two build flags (-DENABLE_NEON=ON and -DENABLE_VFPV3=ON) that need to be passed to the OpenCV library compilation to cause OpenCV to use the NEON co-processor. It looks like that isn't being done by default in PetaLinux 2019.1. Is there a way to add that compiler flag to the OpenCV recipe for PetaLinux?

 

Thanks,

Morgan

0 Kudos
Reply
sandeepg
Moderator
Moderator
1,361 Views
Registered: ‎04-24-2017

Hi @astromorgan ,

All the compiler flags can be passed from recipes using EXTRA_OEMAKE or CMAKE options as shown 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 content
EXTRA_OECMAKE_append_zynq = " -DENABLE_NEON=ON -DENABLE_VFPV3=ON"

Now cleanall opencv and rebuild.

$ petalinux-build -c opencv -x cleanall
$ petalinux-build -c opencv
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
astromorgan
Observer
Observer
1,289 Views
Registered: ‎09-11-2019

Thanks Sandeep. That worked great.

0 Kudos
Reply