Toybrick

标题: RockX_SDK_V1.6.1在RK3399Pro上运行一段时间后报错 [打印本页]

作者: StarGazer    时间: 2023-9-12 14:44
标题: RockX_SDK_V1.6.1在RK3399Pro上运行一段时间后报错
系统版本
Linux bionic 4.4.194 #4 SMP Mon Nov 21 00:00:42 CST 2022 aarch64 aarch64 aarch64 GNU/Linux

Ubuntu 18.04.6 LTS


RKNN版本
D RKNNAPI: RKNN VERSION:
D RKNNAPI:   API: 1.2.0 (db63ace build: 2019-09-17 14:23:41)
D RKNNAPI:   DRV: 1.6.0 (159d2d3 build: 2021-01-12 15:23:09)
D RKNNAPI: ==============================================



程序报错输出
double free or corruption (!prev)

报错堆栈
Thread 4 "face_detection" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fae750e40 (LWP 2935)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

#0  0x0000007fb6c7e598 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x0000007fb6c7f974 in __GI_abort () at abort.c:79
#2  0x0000007fb6cb872c in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7fb6d797e0 "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x0000007fb6cbeaa4 in malloc_printerr (str=str@entry=0x7fb6d754d8 "double free or corruption (!prev)") at malloc.c:5342
#4  0x0000007fb6cc0714 in _int_free (av=0x7fa4000020, p=0x7fa4296640, have_lock=<optimized out>) at malloc.c:4311
#5  0x0000007fb750fd70 in rockx_image_release () at /home/linaro/workspace/RockX_SDK_V1.6/demo/command_line_demo/install/rockx_linux_rk3399pro/face_detection/../lib/librockx.so
#6  0x0000007fb7540d30 in  () at /home/linaro/workspace/RockX_SDK_V1.6/demo/command_line_demo/install/rockx_linux_rk3399pro/face_detection/../lib/librockx.so
#7  0x0000007fb753bdf0 in rockx_face_landmark () at /home/linaro/workspace/RockX_SDK_V1.6/demo/command_line_demo/install/rockx_linux_rk3399pro/face_detection/../lib/librockx.so
#8  0x000000555555966c in detect_face(rockx_handle_t, rockx_handle_t, rockx_handle_t, cv::Mat&, std::vector<FaceObject, std::allocator<FaceObject> >&) (face_det_handle=0x7fa4000b20, face_landmark_handle=0x7fa4004740, face_landmark5_handle=0x7fa40d3300, image=..., faceobjects=std::vector of length 0, capacity 0) at /home/linaro/workspace/RockX_SDK_V1.6/demo/command_line_demo/facedetection/scrfdface.cpp:79
#9  0x0000005555559b1c in process_camera_data() () at /home/linaro/workspace/RockX_SDK_V1.6/demo/command_line_demo/facedetection/scrfdface.cpp:227
#10 0x000000555555b58c in std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) (__f=@0x55555d03e8: 0x5555559948 <process_camera_data()>) at /usr/include/c++/7/bits/invoke.h:60
#11 0x000000555555b048 in std::__invoke<void (*)()>(void (*&&)()) (__fn=@0x55555d03e8: 0x5555559948 <process_camera_data()>) at /usr/include/c++/7/bits/invoke.h:95
#12 0x000000555555c354 in std::thread::_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x55555d03e8) at /usr/include/c++/7/thread:234
#13 0x000000555555c308 in std::thread::_Invoker<std::tuple<void (*)()> >:perator()() (this=0x55555d03e8) at /usr/include/c++/7/thread:243
#14 0x000000555555c2d4 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> > >::_M_run() (this=0x55555d03e0) at /usr/include/c++/7/thread:186
#15 0x0000007fb6eb0e94 in  () at /usr/lib/aarch64-linux-gnu/libstdc++.so.6
#16 0x0000007fb6dac088 in start_thread (arg=0x7fffffef4f) at pthread_create.c:463
#17 0x0000007fb6d1c0cc in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78



代码参照demo写的,具体如下
static void process_camera_data()
{
    std::cout << "thread process_camera_data" << std::endl;

    rockx_ret_t ret;

    rockx_handle_t face_det_handle;

    // create a face detection handle
    ret = rockx_create(&face_det_handle, ROCKX_MODULE_FACE_DETECTION, nullptr, 0);
    if (ret != ROCKX_RET_SUCCESS)
    {
        printf("init rockx module ROCKX_MODULE_FACE_DETECTION error %d\n", ret);
    }

    rockx_handle_t face_landmark_handle;
    rockx_handle_t face_landmark5_handle;

    // create a face landmark handle
    ret = rockx_create(&face_landmark_handle, ROCKX_MODULE_FACE_LANDMARK_106, nullptr, 0);
    if (ret != ROCKX_RET_SUCCESS)
    {
        printf("init rockx module ROCKX_MODULE_FACE_LANDMARK_106 error %d\n", ret);
    }

    ret = rockx_create(&face_landmark5_handle, ROCKX_MODULE_FACE_LANDMARK_5, nullptr, 0);
    if (ret != ROCKX_RET_SUCCESS)
    {
        printf("init rockx module ROCKX_MODULE_FACE_LANDMARK_5 error %d\n", ret);
    }

    while (true)
    {
        std::cout << "process_camera" << std::endl;
        if (cur_frame.empty())
        {
            std::this_thread::sleep_for(std::chrono::milliseconds(200));
            continue;
        }

        auto start = std::chrono::high_resolution_clock::now();
        cv::Mat newst_frame;
        {
            std::lock_guard<std::mutex> frame_lock(cache_mutex);
            newst_frame = cur_frame.clone();
        }
        std::vector<FaceObject> faceobjects;  
        detect_face(face_det_handle, face_landmark_handle, face_landmark5_handle, newst_frame, faceobjects);

        std::this_thread::sleep_for(std::chrono::milliseconds(200));
    }

    // release handle
    rockx_destroy(face_det_handle);
    rockx_destroy(face_landmark5_handle);
    rockx_destroy(face_landmark_handle);
}


static int detect_face(rockx_handle_t face_det_handle, rockx_handle_t face_landmark_handle, rockx_handle_t face_landmark5_handle, cv::Mat &image, std::vector<FaceObject> &faceobjects)
{
    if (image.empty())
        return -1;

    rockx_image_t input_image;
    input_image.pixel_format = ROCKX_PIXEL_FORMAT_BGR888;
    input_image.width = image.cols;
    input_image.height = image.rows;
    input_image.data = image.data;

    rockx_ret_t ret;

    /*************** FACE Detect ***************/

    // create rockx_face_array_t for store result
    rockx_object_array_t face_array;
    memset(&face_array, 0, sizeof(rockx_object_array_t));

    // detect face
    ret = rockx_face_detect(face_det_handle, &input_image, &face_array);
    if (ret != ROCKX_RET_SUCCESS)
    {
        printf("rockx_face_detect error %d\n", ret);
        return -1;
    }
    /*************** FACE Landmark ***************/

    // detect landmark for every face
    for (int i = 0; i < face_array.count; i++)
    {
        int left = face_array.object[i].box.left;
        int top = face_array.object[i].box.top;
        int right = face_array.object[i].box.right;
        int bottom = face_array.object[i].box.bottom;
        float score = face_array.object[i].score;
        printf("box=(%d %d %d %d) score=%f\n", left, top, right, bottom, score);

        rockx_face_landmark_t out_landmark5;
        memset(&out_landmark5, 0, sizeof(rockx_face_landmark_t));

        ret = rockx_face_landmark(face_landmark5_handle, &input_image, &face_array.object[i].box, &out_landmark5);

        rockx_face_angle_t out_angle;
        memset(&out_angle, 0, sizeof(rockx_face_angle_t));
        rockx_face_landmark_t out_landmark;

        ret = rockx_face_landmark106(face_landmark_handle, &input_image, &face_array.object[i].box, &out_landmark5, &out_landmark, &out_angle);

        printf("face %d:\n angle=(pitch:%f yaw:%f roll:%f)\n", i, out_angle.pitch, out_angle.yaw, out_angle.roll);
    }
    return 0;
}


作者: StarGazer    时间: 2023-9-12 14:46
我想问一下这是NPU驱动的问题,还是系统的问题,还是sdk问题,或者是这段代码的问题
作者: kispr    时间: 2023-10-11 15:10
你好 我也遇到过这个问题 请问你解决了吗?
作者: dqgwcj    时间: 2024-9-14 08:41
RockX_SDK_V1.6.1 算法在哪下载呀




欢迎光临 Toybrick (https://t.rock-chips.com/) Powered by Discuz! X3.3