Toybrick

rockx的人脸识别在rk1808S0上主动模式调用

daigang

中级会员

积分
209
楼主
发表于 2019-11-28 20:38:43    查看: 11057|回复: 6 | [复制链接]    打印 | 只看该作者


在编译rockx的人脸识别demo后放在rk1808S0计算棒中,结果报错。报Segmentation fault (核心已转储),
使用的是官方提供的demo,具体代码如下:
/****************************************************************************
*
*    Copyright (c) 2017 - 2019 by Rockchip Corp.  All rights reserved.
*
*    The material in this file is confidential and contains trade secrets
*    of Rockchip Corporation. This is proprietary information owned by
*    Rockchip Corporation. No part of this work may be disclosed,
*    reproduced, copied, transmitted, or used in any way for any purpose,
*    without the express written permission of Rockchip Corporation.
*
*****************************************************************************/
#include <stdio.h>
#include <memory.h>
#include <sys/time.h>
#include <stdlib.h>
#include "rockx.h"

rockx_handle_t face_det_handle;
rockx_handle_t face_5landmarks_handle;
rockx_handle_t face_recognize_handle;

int run_face_recognize(rockx_image_t *in_image, rockx_face_feature_t *out_feature) {
    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, in_image, &face_array, nullptr);
    if (ret != ROCKX_RET_SUCCESS) {
        printf("rockx_face_detect error %d\n", ret);
        return -1;
    }

    // process result
    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);
        // draw
        char score_str[8];
        memset(score_str, 0, 8);
        snprintf(score_str, 8, "%.3f", score);
    }

    /*************** FACE Landmark ***************/
    rockx_image_t out_img;
    out_img.width = 112;
    out_img.height = 112;
    out_img.pixel_format = ROCKX_PIXEL_FORMAT_RGB888;
    out_img.data = (uint8_t*)malloc(112*112*3*sizeof(char));
    for (int i = 0; i < face_array.count; i++) {
        rockx_face_align(face_5landmarks_handle, in_image, &face_array.object[i].box, nullptr, &out_img);
    }

    /*************** FACE Recognize ***************/
    rockx_face_recognize(face_recognize_handle, &out_img, out_feature);

    //printf("out_feature0 is %f \n",out_feature[n-1].feature[0]);
    //printf("out_feature1 is %f \n",out_feature[n-1].feature[1]);

    free(out_img.data);

    return 0;
}

int main(int argc, char** argv) {

    rockx_ret_t ret;
    struct timeval tv;

    if( argc != 3 ){
        printf("\nUsage: mser_sample <path_to_person1_image> <path_to_person2_image>\n");
        return -1;
    }
    /*************** Creat 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);
        return -1;
    }

    // create a face landmark handle
    ret = rockx_create(&face_5landmarks_handle, ROCKX_MODULE_FACE_LANDMARK_5, nullptr, 0);
    if (ret != ROCKX_RET_SUCCESS) {
        printf("init rockx module ROCKX_MODULE_FACE_LANDMARK_68 error %d\n", ret);
        return -1;
    }

    // create a face recognize handle
    ret = rockx_create(&face_recognize_handle, ROCKX_MODULE_FACE_RECOGNIZE, nullptr, 0);
    if (ret != ROCKX_RET_SUCCESS) {
        printf("init rockx module ROCKX_MODULE_FACE_LANDMARK_68 error %d\n", ret);
        return -1;
    }

    rockx_face_feature_t out_feature1;
    rockx_face_feature_t out_feature2;

    // read image
    const char *img_path1 = argv[1];
    const char *img_path2 = argv[2];

    // read image
    rockx_image_t input_image1;
    rockx_image_read(img_path1, &input_image1, 1);

    rockx_image_t input_image2;
    rockx_image_read(img_path2, &input_image2, 1);

    run_face_recognize(&input_image1, &out_feature1);
    run_face_recognize(&input_image2, &out_feature2);

    float similarity;
    ret = rockx_face_feature_similarity(&out_feature1, &out_feature2, &similarity);
    printf("similarity is %f\n",similarity);

    //release handle
    rockx_destroy(face_det_handle);
    rockx_destroy(face_5landmarks_handle);
    rockx_destroy(face_recognize_handle);
    return 0;
}

不知道什么原因导致的报错,自己定位可能是rockx_create出错了,但没有错误信息,只有Segmentation fault (核心已转储),希望能给点指导,谢谢了。
回复

使用道具 举报

jefferyzhang

版主

积分
13574
沙发
发表于 2019-11-29 08:19:22 | 只看该作者
你发代码干嘛,log呢?段错误的堆栈信息呢?
gdb跟下log发出来呀。。。
回复

使用道具 举报

daigang

中级会员

积分
209
板凳
 楼主| 发表于 2019-11-29 09:12:08 | 只看该作者
您好,这个是使用gdb后的信息:
[toybrick@rk1808 test]$ ./rockx_face_recognition Aaron_Eckhart_0001.jpg Aaron_Sorkin_0001.jpg
Segmentation fault (核心已转储)
[toybrick@rk1808 test]$ gdb ./rockx_face_recognition Aaron_Eckhart_0001.jpg Aaron_Sorkin_0001.jpg
Excess command line arguments ignored. (Aaron_Sorkin_0001.jpg)
GNU gdb (GDB) Fedora 8.1.1-4.fc28
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./rockx_face_recognition...done.
"/home/toybrick/test/Aaron_Eckhart_0001.jpg" is not a core dump: 不可识别的文件格式
(gdb) r
Starting program: /home/toybrick/test/rockx_face_recognition
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.27-38.fc28.aarch64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Usage: mser_sample <path_to_person1_image> <path_to_person2_image>
[Inferior 1 (process 2288) exited with code 0377]
Missing separate debuginfos, use: dnf debuginfo-install libgcc-8.3.1-2.fc28.aarch64 libgomp-8.3.1-2.fc28.aarch64 libstdc++-8.3.1-2.fc28.aarch64
(gdb) r
Starting program: /home/toybrick/test/rockx_face_recognition
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Usage: mser_sample <path_to_person1_image> <path_to_person2_image>
[Inferior 1 (process 2307) exited with code 0377]
(gdb) dnf debuginfo-install glibc-2.27-38.fc28.aarch64
Undefined command: "dnf".  Try "help".
(gdb) r
Starting program: /home/toybrick/test/rockx_face_recognition
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Usage: mser_sample <path_to_person1_image> <path_to_person2_image>
[Inferior 1 (process 2385) exited with code 0377]
(gdb) r
Starting program: /home/toybrick/test/rockx_face_recognition
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Usage: mser_sample <path_to_person1_image> <path_to_person2_image>
[Inferior 1 (process 2395) exited with code 0377]
回复

使用道具 举报

daigang

中级会员

积分
209
地板
 楼主| 发表于 2019-11-29 09:29:32 | 只看该作者
我把图像路径改了,之后的报错信息:
[toybrick@rk1808 test]$ ./rockx_face_recognition
Segmentation fault (核心已转储)
[toybrick@rk1808 test]$ gdb ./rockx_face_recognition
GNU gdb (GDB) Fedora 8.1.1-4.fc28
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./rockx_face_recognition...done.
(gdb) r
Starting program: /home/toybrick/test/rockx_face_recognition
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000007fb7fd7cb4 in do_lookup_x (undef_name=undef_name@entry=0x7fb3d8ceb8 "rknn_init", new_hash=new_hash@entry=2887447761,
    old_hash=old_hash@entry=0x7fff800188, ref=0x0, result=result@entry=0x7fff800198, scope=0x7fb8000428, i=0,
    version=version@entry=0x0, flags=flags@entry=3, skip=skip@entry=0x0, type_class=type_class@entry=0,
    undef_map=undef_map@entry=0x7fb7ff0ea0) at dl-lookup.c:338
338        {
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/toybrick/test/rockx_face_recognition
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000007fb7fd7cb4 in do_lookup_x (undef_name=undef_name@entry=0x7fb3d8ceb8 "rknn_init", new_hash=new_hash@entry=2887447761,
    old_hash=old_hash@entry=0x7fff800188, ref=0x0, result=result@entry=0x7fff800198, scope=0x7fb8000428, i=0,
    version=version@entry=0x0, flags=flags@entry=3, skip=skip@entry=0x0, type_class=type_class@entry=0,
    undef_map=undef_map@entry=0x7fb7ff0ea0) at dl-lookup.c:338
338        {
(gdb)
回复

使用道具 举报

daigang

中级会员

积分
209
5#
 楼主| 发表于 2019-11-29 09:30:50 | 只看该作者
我把图像路径固定了,然后错误信息:
[toybrick@rk1808 test]$ ./rockx_face_recognition
Segmentation fault (核心已转储)
[toybrick@rk1808 test]$ gdb ./rockx_face_recognition
GNU gdb (GDB) Fedora 8.1.1-4.fc28
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./rockx_face_recognition...done.
(gdb) r
Starting program: /home/toybrick/test/rockx_face_recognition
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000007fb7fd7cb4 in do_lookup_x (undef_name=undef_name@entry=0x7fb3d8ceb8 "rknn_init", new_hash=new_hash@entry=2887447761,
    old_hash=old_hash@entry=0x7fff800188, ref=0x0, result=result@entry=0x7fff800198, scope=0x7fb8000428, i=0,
    version=version@entry=0x0, flags=flags@entry=3, skip=skip@entry=0x0, type_class=type_class@entry=0,
    undef_map=undef_map@entry=0x7fb7ff0ea0) at dl-lookup.c:338
338        {
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/toybrick/test/rockx_face_recognition
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000007fb7fd7cb4 in do_lookup_x (undef_name=undef_name@entry=0x7fb3d8ceb8 "rknn_init", new_hash=new_hash@entry=2887447761,
    old_hash=old_hash@entry=0x7fff800188, ref=0x0, result=result@entry=0x7fff800198, scope=0x7fb8000428, i=0,
    version=version@entry=0x0, flags=flags@entry=3, skip=skip@entry=0x0, type_class=type_class@entry=0,
    undef_map=undef_map@entry=0x7fb7ff0ea0) at dl-lookup.c:338
338        {

回复

使用道具 举报

kiwi

中级会员

积分
418
QQ
6#
发表于 2019-12-3 15:44:32 | 只看该作者
没有找到图像吧
回复

使用道具 举报

xindongzhang

注册会员

积分
82
7#
发表于 2020-10-10 12:50:47 | 只看该作者
在调用rockx中的rockface_feature_extract时候,蜂鸣警报会有拍照声,想请问一下rockface_feature_extract内部是否进行了蜂鸣的警报调用,谢谢版主!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表