SK-AM62A-LP: Error in running Opencv application based on SK-AM62A-LP E3 development board

Part Number: SK-AM62A-LP

Tool/software:

Hello!
We use the default SD card image burned on the SK-AM62A-LP E3 development board,
Start the development board and run it. In the cd/usr/lib directory, you can see the libraries containing OpenCV4.9 as follows:
This is our application, as follows:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
using namespace std;
int main( )
{
cv::Mat image = cv::Mat::ones(500, 500, CV_8UC3) * 255;
std::string text = "Hello, World!";
cv::Point position(100, 250);
int font = cv::FONT_HERSHEY_SIMPLEX;
cv::Scalar color(0, 0, 0);
cv::putText(image, text, position, font, 1.5 , color, 2);
cv::imwrite("./test.jpg", image);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
It looks quite comprehensive, but when we run the OpenCV application, we encounter the following error:
 
It seems that there is not even basic imwrite and imread. Is it because the OpenCV on the board is incomplete and lacks relevant libraries?
Do we still need to configure related dependencies? Or where are some examples of OpenCV calling cameras and Gstreamer calling cameras?
Does Opencv on TI boards need to be cross compiled and ported to the board?Or should we still use Yocto for overall compilation and configuration?
It can run on this board, please help to take a look, thank you very much!
  • Hello,

    OpenCV installed in the SDK should be sufficient for an example like this. I would be curious to see your CMakeLists.txt file for this project -- would you please share this?

    A good example is under edgeai-tidl-tools --- see examples. Within the osrt_cpp examples, you can see several instances in which imwrite is used:

    It is an option to cross-compile, but this is not required here. The necessary headers, libraries, and compiler are present in the SDK within /usr. Yocto is used to create the distribution of Linux, so all the packages, tools, libraries, configurations, and so on -- it is not the right tool for your use-case here. 

    Are you using edgeai-gst-apps as your starting point for this application? I see similarities in the directory structure with apps_cpp. That project (under /opt/edgeai-gst-apps/apps_cpp) builds without any of these linking issues.

    BR,
    Reese

  • Hello, I don't know how to use edgeai-gst-apps as the starting point of the application. Where can I refer to it?
    The project I tested before was Hello world, which can be compiled and executed on the board according to the following steps:
    1) mkdir build
    2) cd build
    3) cmake ..
    4) make
    The code structure is as follows:

    The content of CMakeLists.txt in the APPS_CPP/folder is as follows:


    The content of CMakeLists.txt in the APPS_CPP/app_edgeai/src directory is as follows:

    This is our CMakeLists, please take a look, looking forward to your reply.

  • I don't know how to use edgeai-gst-apps as the starting point of the application. Where can I refer to it?

    I made an assumption based on your directory structure that you had used edgeai-gst-apps at first, and were using the common.cmake from there. I think I made an incorrect assumption here.

    For a hello-world style application, edgeai-gst-apps may be overly complex. However, it has a common.cmake file that may be useful -- it sets Library and Include paths that are known to work. 

    Could you also share the common.cmake? The cmake files you shared do not include any of the right libraries or include paths, so I assume it exists in the common.cmake file. 

    I assume you are compiling on the target. Please tell me if this is incorrect.

    BR,
    Reese

  • Hello, this is our common.cmake file; the location is as follows:

    The specific content is as follows:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    include(GNUInstallDirs)
    include(CMakePackageConfigHelpers)
    add_compile_options(-std=c++17)
    option(USE_DLR_RT "Enable DLR inference" ON)
    option(USE_TENSORFLOW_RT "Enable Tensorflow inference" ON)
    option(USE_ONNX_RT "Enable Onnx inference" ON)
    # Specific compile optios across all targets
    #add_compile_definitions(MINIMAL_LOGGING)
    IF(NOT CMAKE_BUILD_TYPE)
    SET(CMAKE_BUILD_TYPE Release)
    ENDIF()
    # Turn off output data dumps for testing by default
    OPTION(EDGEAI_ENABLE_OUTPUT_FOR_TEST "Enable Output Dumps for test" OFF)
    # Check if we got an option from command line
    if(EDGEAI_ENABLE_OUTPUT_FOR_TEST)
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Please help me take a look, thank you very much!

  • Hello,

    The CMAKE file here is helpful. I think the issue is with the set of linked libraries. Here, you are adding (from opencv) core and imgproc libraries, but I don't think this contains the imwrite function. 

    It looks like imwrite is part of libopencv_imgcodecs. Could you try adding "opencv_imgcodecs" to your  SYSTEM_LINK_LIBS (line 170)?

    As a quick check, I dumped symbols with "nm -D" for the libopencv_core.so, libopencv_imgproc.so, and libopencv_imgcodecs.so:

    Fullscreen
    1
    2
    3
    4
    5
    6
    root@am62axx-evm:/usr/lib# nm -D libopencv_core.so | grep imwrite
    root@am62axx-evm:/usr/lib# nm -D libopencv_imgproc.so | grep imwrite
    root@am62axx-evm:/usr/lib# nm -D libopencv_imgcodecs.so | grep imwrite
    000000000002a900 T _ZN2cv7imwriteERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_11_InputArrayERKSt6vectorIiSaIiEE
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    And it is defined only in imgcodecs

    BR,
    Reese