espressif / esp-dl

Espressif deep-learning library for AIoT applications
MIT License
548 stars 118 forks source link

wdt during lengthy face_detect() #33

Closed jameszah closed 3 years ago

jameszah commented 3 years ago

Hi, I'm having a problem with cpu1 watchdog timer going off during a call to face_detect(). The watchdog goes off at about 375 ms, the best I can figure using this bit of code and looking at the arduino serial monitor

        fmt2rgb888(fb->buf, fb->len, fb->format, out_res.image);
        long detstart = millis();
        Serial.println(detstart);
        out_res.net_boxes = face_detect(image_matrix, &mtmn_config);
        Serial.println(millis()-detstart);
00:04:06.515 -> 218850
00:04:06.889 -> Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1)
00:04:06.923 -> Core 1 register dump:

So the 889 ms minus 515 ms is the 374 ms that creates the wdt.

I've trained dozen of faces, and detected hundreds with this code, before I ran into this. It is a esp32-cam standard setup, with some added, and recently a with and . These are configured but not being called during the facedetect(), as it is just running in the arduino loop, with nothing on the other cpu, and no user interrupts or tasks.

My setup is below.

  config.pixel_format = PIXFORMAT_JPEG; 
  config.frame_size =  FRAMESIZE_QVGA; //  320 x 240

  config.fb_count = 2;
  config.jpeg_quality = 12; 

And I have fiddled with these mtmn parameters without success, trying to reduce the time of the detect or fail, so it doesn't exceed the watchdog.

  mtmn_config_t mtmn_config = {0};
  mtmn_config.type = FAST;
  mtmn_config.min_face = 80; 
  mtmn_config.pyramid = 0.707;
  mtmn_config.pyramid_times = 4;
  mtmn_config.p_threshold.score = 0.6;
  mtmn_config.p_threshold.nms = 0.7;
  mtmn_config.p_threshold.candidate_number = 20; 
  mtmn_config.r_threshold.score = 0.7; 
  mtmn_config.r_threshold.nms = 0.7;
  mtmn_config.r_threshold.candidate_number = 10; 
  mtmn_config.o_threshold.score = 0.7; 
  mtmn_config.o_threshold.nms = 0.7;     
  mtmn_config.o_threshold.candidate_number = 1;

It usually fails after about 50ms when there is no face, and takes 100ms to 150ms when there is a face, but sometimes looking at a face which is programmed or not programmed, it seems to run past the limit of the watchdog.

So any advice? Is there a way to command it to give up after 250 ms say? I'm keeping the faces in flash, and I have 30 faces configured. Could they be corrupted somehow? Or some strange interaction with the SPI activities? I removed the SPI and 1306, but still getting the problem.

jameszah commented 3 years ago

I seem to have lost the problem - went to some old code - fiddled with the hardware - back to the new code - cannot find problem anymore.

3 hours down the drain.