goodrobots / maverick

UAV Autonomous Systems Management
https://goodrobots.github.io/maverick/
MIT License
167 stars 60 forks source link

COLOR_YUV2RGBA_NV21 not working when adding any optimization flag #970

Closed davidmartos96 closed 4 years ago

davidmartos96 commented 4 years ago

I'm using the latest Android OpenCV prebuilt SDK (4.3) to create a cpp shared library (cross compiling using the NDK r21) to use from the Dart FFI on Flutter to process the camera bytes.

I'm using the COLOR_YUV2RGBA_NV21 color transformation and it works great until the .so is built with any of the O flags turned on. If code optimization is turned on, then the returned image has flickery artifacts at the bottom and at the right of the image and the B and R channels are swapped.

If I compile the shared library for linux with OpenCV 4.2 and I open a (dumped frame) of the Android camera from a Main linked with the library, it also has the same issues. I'm using CMake with -DCMAKE_BUILD_TYPE=Release. RelWithDebInfo fails as well.

This is the CMakeLists.txt file to build the shared library:

add_library( DisplayImage SHARED MyLib.cpp )
target_include_directories(MyLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

find_package( OpenCV REQUIRED )

target_link_libraries( MyLib  ${OpenCV_LIBS} )

This is the output image, weird green stripe at the bottom and it is red instead of blue. This is just a captured frame, but with the Android camera, the green stripe is flickering every frame, is not static.

image

I'm actually clueless on what could be wrong here.

Any help to know what could be going on here would be very appreciated. Thank you.

davidmartos96 commented 4 years ago

sorry, I posted here by mistake