0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ESP32 WROVER CAMで画像識別ST7735バウンディングボックス

Last updated at Posted at 2024-09-22

ESP32 WROVER CAMで画像データを収集します。EdgeImpulseにてアノテーションを行い画像モデルを作成します。今回は試験的に数十件だけグー、チョキ、パーの画像を撮ります。作成した画像モデルを元にESP32 WROVER CAMにて画像識別を行うテストです。テスト中は撮影画像をリアルタイムでLCD ST7735に映し画像識別に反応したらバウンディングボックスを黄色で表示させます。

wrover_edgeimpulse_ST7735.drawio.png

  • 前回はテスト中の画像をブラウザで表示しました。

ソースコードピックアップ

#include

  • ST7735を使用するためにTFT_eSPI.hを使う
  • グーチョキパーのモデル esp32_pachokigu_inferencing.h
#include <Arduino.h>
#include <TFT_eSPI.h> // TFTディスプレイを制御するライブラリ
#include <SPI.h>
#include <esp32_pachokigu_inferencing.h>  // Edge Impulse推論用にパーチョキグーのモデル
#include "edge-impulse-sdk/dsp/image/image.hpp" 
#include "esp_camera.h" // ESP32カメラを制御するためのライブラリ

TFT_eSPI.h関連

  • TFT_eSPI\User_Setup_Select.hの修正
<User_Setup.h> //アンコメント
  • user_setup.hの修正
#define ST7735_DRIVER
...
//接続時のGPIOをを指定
#define TFT_MOSI 13
#define TFT_SCLK 14
#define TFT_CS   15  
#define TFT_DC   12 
#define TFT_RST  33 

バウンディングボックス

void loop()の中で、

....
  bool bb_found = result.bounding_boxes[0].value > 0; // 最初のバウンディングボックスが見つかったかをチェック

  for (size_t ix = 0; ix < result.bounding_boxes_count; ix++) { // バウンディングボックスの数だけループ
    auto bb = result.bounding_boxes[ix]; // バウンディングボックスを取得
    if (bb.value == 0) { // 値が0ならスキップ
      continue; // 次のループに進む
    }

    /* Create Coordinates and Size for Bounding Boxes */
    x = bb.x; // X座標を設定
    y = bb.y; // Y座標を設定
    w = bb.width * 6; // 幅を6倍にスケーリング
    h = bb.height * 5; // 高さを5倍にスケーリング

    /* Checking Sizes */
    ei_printf("BB Coord [ x: %u, y: %u, width: %u, height: %u ]\n",  bb.x, bb.y, bb.width, bb.height); // バウンディングボックスのサイズをシリアル出力

    /* Draw Bounding Boxes in Display */
    tft.drawRect(x, y, w, h, TFT_GREEN); // バウンディングボックスを緑で描画
    tft.setCursor(x, y); // カーソル位置をバウンディングボックスの位置に設定
    tft.setTextColor(TFT_GREEN); // テキスト色を緑に設定
    tft.setTextFont(4); // テキストフォントを4に設定
    tft.println(bb.label); // ラベルを表示
  }
....

結果

guと出て黄色のバウンディングボックスが出ています。学習データが少ないのでもっと多くする必要があります。WROVERでは役不足かも知れません。
20240811_200556 (1).gif

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?