Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Min Ma
Created August 19, 2024

Smart Object Detect

Using Vision AI technology and TTS technology to help visually impaired people perceive target object.

22
Smart Object Detect

Things used in this project

Hardware components

Seeed Studio grove vision ai 2
×1
Seeed Studio ov5647 camera
×1
Seeed Studio XIAO ESP32S3 Sense
Seeed Studio XIAO ESP32S3 Sense
×1
Gravity: Speech Synthesis Module(Support English and Chinese)
DFRobot Gravity: Speech Synthesis Module(Support English and Chinese)
×1

Software apps and online services

Seeed Studio Fork Detection

Story

Read more

Code

TrafficSensorNet

Arduino
Arduino code for analysis and speech.
#include <Arduino.h>
#include <Seeed_Arduino_SSCMA.h>
#include "DFRobot_SpeechSynthesis.h"


//define the forward direction area between 80-140
#define LEFT 80
#define RIGHT 140 

DFRobot_SpeechSynthesis_I2C ss;
SSCMA AI;

void setup()
{
  //initial and setup Grove Vision 2
  AI.begin();

  //initial and setup Speech Synthesis module
  ss.begin(); 
  //set speech volume.
  ss.setVolume(5);
  //set speech speed. 
  ss.setSpeed(5);
  //set speech type female.
  ss.setSoundType(ss.eFemale1);
  //set speech tone.
  ss.setTone(5);
  //set speech in english word mode.
  ss.setLanguage(ss.eEnglishl);

  //initial serial for debug and monitor
  Serial.begin(9600);

  //message application started
  Serial.print("Traffic Sensor App start!");

}

void loop()
{

  String analysis = "";
  // invoke once, no filter , get image
  if (!AI.invoke(1, false, true))
  {
    analysis += String("Detected ");
    for (int i = 0; i < AI.boxes().size(); i++)
    {
      if(AI.boxes()[i].x > LEFT && AI.boxes()[i].x < RIGHT)
      {
        analysis += String(i);
        analysis += String(" target is ");
        analysis += String(AI.boxes()[i].target);
        analysis += String(" score is ");
        analysis += String(AI.boxes()[i].score);
      } 
    }
    ss.speak(analysis.c_str());
    
  }

  //interval 3 seconds.
  delay(3000);
}

Object detection

Arduino
Object detection, parse result from Vision AI 2.
#include <Arduino.h>
#include <Seeed_Arduino_SSCMA.h>
#include "DFRobot_SpeechSynthesis.h"

#define THRESHOLD 0.6
DFRobot_SpeechSynthesis_I2C ss;
SSCMA AI;

void setup()
{
  //initial and setup Grove Vision 2
  AI.begin();

  //initial and setup Speech Synthesis module
  ss.begin(); 
  //set speech volume.
  ss.setVolume(5);
  //set speech speed. 
  ss.setSpeed(5);
  //set speech type female.
  ss.setSoundType(ss.eFemale1);
  //set speech tone.
  ss.setTone(5);
  //set speech in english word mode.
  ss.setLanguage(ss.eEnglishl);

  //initial serial for debug and monitor
  Serial.begin(9600);

  //message application started
  Serial.print("Object Detect App start!");

}

void loop()
{

  String analysis = "";
  // invoke once, no filter , get image
  if (!AI.invoke(1, false, true))
  {
    analysis += String("Detected ");
    for (int i = 0; i < AI.boxes().size(); i++)
    {
      if(AI.boxes()[i].score>THRESHOLD)
      {
        analysis += String(i);
        analysis += String(" target is ");
        analysis += String(AI.boxes()[i].target);
        analysis += String(" score is ");
        analysis += String(AI.boxes()[i].score);
        analysis += String(" position is ");
        analysis += String(AI.boxes()[i].x+AI.boxes()[i].w/2);
        analysis += String(" ");
        analysis += String(AI.boxes()[i].y+AI.boxes()[i].h/2);
      } 
    }
    ss.speak(analysis.c_str());
    
  }

  //interval 3 seconds.
  delay(3000);
}

Credits

Min Ma

Min Ma

8 projects • 1 follower
Senior Software Engineer

Comments