ESP32S3 add AprilTag Detection

Empe_7188
Posts: 1
Joined: Thu Nov 09, 2023 10:43 am

ESP32S3 add AprilTag Detection

Postby Empe_7188 » Thu Nov 09, 2023 2:24 pm

Hello. :D
i'm try to add this function to my project. but it's not working well.
can you give me a hint?

target board is esp32s3 / 8MB psram.
use frame buffer "PIXFORMAT_GRAYSCALE", "FRAMESIZE_240X240"

add this lib "idf.py add-dependency "liux-pro/apriltag^0.0.4" by this cmd
and do full clean and build result build successfully complite.
https://components.espressif.com/compon ... o/apriltag


tf = tag16h5_create(); td = apriltag_detector_create();
when i call this function error has bean accurred.
please check "heap_caps_calloc_error.jpg" image
heap_caps_calloc_error.png
heap_caps_calloc_error.png (78.94 KiB) Viewed 638 times
so i change malloc and calloc function to heap_caps_calloc, heap_caps_malloc to allocatic in spram
after some same error keep accurred at malloc and calloc so i changed all.

after that
issue has changed.

unknown_error.png
unknown_error.png (100.35 KiB) Viewed 638 times
this is my serial window.
i can not understand what's happend.

here is my code.

Code: Select all

init function
`
void initAprilTagDecode(void)
{
    tf = tag16h5_create();
    td = apriltag_detector_create();

    apriltag_detector_add_family(td, tf);

    td->quad_decimate = 1.0; // "Decimate input image by this factor"
    td->quad_sigma = 0.0; // "Apply low-pass blur to input; negative sharpens"
    td->nthreads = 1; // "Use this many CPU threads"
    td->debug = 0; // "Enable debugging output (slow)"

    td->refine_edges = 1; // "Spend more time trying to align edges of tags"
    td->decode_sharpening = 0;

    quiet = 0; // "Reduce output"
    maxiters = 1; // "Repeat processing on input set this many times"
}

and main loop call function

{
    image_u8_t im =
    {
        .width = (int32_t)frame->width,
        .height = (int32_t)frame->height,
        .stride = (int32_t)frame->width,
        .buf = frame->buf
    };

    ESP_LOGI("APRIL", "CAM_AP_APRIL_TAG FB get");

    if (return_frambuffer) esp_camera_fb_return(frame);
    else free(frame);

    zarray_t *detections = apriltag_detector_detect(td, &im);

    for (int i = 0; i < zarray_size(detections); i++)
    {
        apriltag_detection_t *det;
        zarray_get(detections, i, &det);
        ESP_LOGE("TAG","%d, ",det->id);
    }

    apriltag_detections_destroy(detections);

    ESP_LOGI("APRIL", "CAM_AP_APRIL_TAG FB Get");
    break;
}
coude check it please?
best regards.

Who is online

Users browsing this forum: No registered users and 120 guests