espressif / esp-dl

Espressif deep-learning library for AIoT applications
MIT License
516 stars 115 forks source link

Color Detector model's Size bias issue (AIV-657) #141

Open ajtwlsdlqp opened 8 months ago

ajtwlsdlqp commented 8 months ago

Hi.

I am using IDF version 4.4, and I have a question regarding the color detection feature. I'd like to know if this is a known bug or if there might be some misconfiguration causing the following issue:

I am capturing two frames of size 320x240 in RGB565/BMP format and attempting color detection. The functionality seems to work well. Based on the detected region's starting position, height, and width, I'm displaying the detected region on an LCD. For images that are wider, the width is accurately represented, but for images that are taller, the width is not displayed correctly; instead, it is recognized as a square shape.

Is there a way to resolve this issue? Thank you for your assistance.

Sandra-lol commented 8 months ago

Hello~ Looks like it's more of a display issue, could you check the lcd driver?

ajtwlsdlqp commented 8 months ago

@Sandra-lol Thank you for your advice.

I am not directly using an LCD but transmitting the obtained coordinates and dimensions to another device for display. I have logged the obtained coordinates' width and height values in IDF Monitor for verification. For shapes that are taller in the vertical direction, the height is not being accurately detected and is displayed as a square with the same value as the width.

Thank you for your assistance.

Sandra-lol commented 8 months ago

hello~ Since you may not be using the example from this repo, could you provide any code for better analysis?

ajtwlsdlqp commented 8 months ago

@Sandra-lol Sure, Please check my code.

` registerCamera(PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2, info.xQueueAIFrame);

static void threadCameraHandler(void arg) { // cliPrintf("threadCameraHandler \n"); while (true) { camera_fb_t frame = esp_camera_fb_get(); if (frame) { xQueueSend(xQueueFrameO, &frame, 0xFFFFFFFF); }

taskYIELD();

} }

if (xQueueReceive(info.xQueueFrameI, &frame, portMAX_DELAY)) { switch( info.cam_ap_select) { ... ... case CAM_AP_COLOR_DETECT : { latency.start();

      std::vector<std::vector<color_detect_result_t>> &results = detector_color.detect((uint16_t *)frame->buf, {(int)frame->height, (int)frame->width, 3} );

      latency.end();

      color_buff_idx = 0;
      decrease_color = 0;

      // 10 * 1
      for( int m=0; m<12; m++)
        color_info.detect_cnt[m] = 0;

      for (int i = 0; i < results.size(); ++i)
      {
        draw_color_detection_result((uint16_t *)frame->buf, (int)frame->height, (int)frame->width, results[i], draw_lcd_color[i % draw_colors_num], i);
      }
    }
    if (return_frambuffer) esp_camera_fb_return(frame);
    else free(frame);

    break;

} } `

Thank you for your assistance.