liux-pro / apriltag

This repo demonstrates how to use apriltag in esp-idf.
BSD 2-Clause "Simplified" License
3 stars 0 forks source link

Guru Meditation Error #1

Open ajtwlsdlqp opened 1 year ago

ajtwlsdlqp commented 1 year ago

Hello. 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.

tf = tag16h5_create(); td = apriltag_detector_create(); when i call this function error has bean accurred. 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. image

this is my serial window. i can not understand what's happend.

coude check it please? best regards.

ajtwlsdlqp commented 1 year ago

oh,

here is my code.

init function ` void initAprilTagDecode(void) { tf = tag16h5_create(); // tf = tagStandard41h12_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;

  }

`

liux-pro commented 1 year ago

Hi! image

You should call apriltag_detector_detect first, then esp_camera_fb_return . The esp_camera_fb_return tell camera driver that we don't this frame data any more, frame->buf may point to nothing after this call.

liux-pro commented 1 year ago

image what is return_frambuffer? no need free(frame). The camera driver (esp_cam)has it own memory management

ajtwlsdlqp commented 1 year ago

Hello, @liux-pro Thanks for Answer. !

I have confirmed the contents of your reply.

Here are answers to your questions and additional information. Please confirm.

  1. this is my frame_buffer init state. image

  2. This is my Init Code. image

2-1. at apCameraInit() function image do this

2-2. at apCameraLoop() function

image

what is return_frambuffer? "return_frambuffer" this fleg always "true" my code use frambuffer at another function after use april-tag decode (convert to jpg and strming) that's why use fb_return function The fb_return function can be used in other places, such as face recognition, and it has been confirmed that it operates normally.

tf = tag16h5_create(); td = apriltag_detector_create(); when i call this function error has bean accurred. image 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.

image this is my serial window. i can not understand what's happend.

Thanks for help best regards.

ajtwlsdlqp commented 1 year ago

Just Core panic'ed and after reset directly.

i can get any debug message...

Are there any suspicious symptoms or debugging methods? The component was added using the "idf.py add-dependency "liux-pro/apriltag^0.0.4" by this cmd method, and the code has been fully-cleaned and built.

liux-pro commented 1 year ago

Is your project private? Can I access all code?

ajtwlsdlqp commented 1 year ago

yes, private. for all access, i need get permission first.

If necessary, it would be possible to copy and share all parts of the code being called.

Thanks.

liux-pro commented 1 year ago

I don't have a good way to debug this. After your change, is the error show up in this line too? tf = tag16h5_create(); td = apriltag_detector_create();

Just add lot of ESP_LOGI to get which line that error at

ajtwlsdlqp commented 1 year ago

Thanks for your help. liux-pro.

Let's insert as much debugging code as possible to pinpoint where the reset occurs.

We will also prepare the source code under development so that it can be shared through git. ASAP. I think it would be of great help if you could check it out.

Thank you again.

ajtwlsdlqp commented 1 year ago

hello, @liux-pro .

Here is the open source link to the project in question. If you have time, I would appreciate it if you could review it.

https://github.com/ajtwlsdlqp/esp32s3_april-tag/tree/main

Best Regards.

ajtwlsdlqp commented 1 year ago

hello, @liux-pro .

I hope this message finds you well. I have a question regarding your project.

I was wondering if you have implemented and verified the functionality of capturing April-Tags using any camera module, analyzing the frame buffer, and identifying the content of the tag in your project.

From reviewing all the example codes and content, it appears that the analysis involves including a pre-existing image header.

I am curious to know if you have successfully implemented and tested real-time analysis, as I am currently working on implementing a similar real-time analysis feature and would like to understand if it is fundamentally achievable based on your project.

Thank you for your time and assistance.

Best regards,

liux-pro commented 1 year ago

I have try this apriltag on esp32 year ago. There is a unfinished project using this april-tag. It called cube01. For now , the code in cube01 may be really helpfull. It read camera image, find apriltag , show image on a screen.

https://github.com/liux-pro/cube01/tree/37691108d31524f0eae5719c23c90a3a7d5ff379

liux-pro commented 1 year ago

Here is a video running the code above. esp32-s3 with 8m psram, ov2640 camera, st7789 lcd screen.

https://github.com/liux-pro/apriltag/assets/20764978/ebfec0be-1d18-4db3-b72e-e1fd6ffad813

liux-pro commented 1 year ago

https://www.chiefdelphi.com/uploads/short-url/rpYAfnFwr4EIwHuIXlvLH8Sjhzz.pdf It tracking a april tag that I draw on a piece of paper, family 16h5 (id=5)

9a9d726c6fe476c1be2f7723dfbde6d

ajtwlsdlqp commented 1 year ago

@liux-pro

I will try ASAP. Really Thanks for help.

Thank you again.

ajtwlsdlqp commented 11 months ago

update.

Thanks liux_pro.

It wasn't a complete success, but There was a possibility of successful detection 2-3 times.

Although the reset phenomenon still occurs frequently, I can assure you that there has been a lot of progress compared to the previous cases where the decode function could not be executed and a reset occurred.

image

Thank you again.