【ESP32Cam项目1】:ESP32Cam人脸检测(ArduinoESP32底层、Python版opencv)

慈云数据 2024-04-05 技术支持 80 0


人脸检测项目效果图:

人脸检测效果视频:

            暮年的主页 - 抖音 (douyin.com)


人脸检测项目目标:

        大家好!近期拿到了便宜的ESP32Cam开发板,摄像头让我想起来人脸识别,于是ESP32Cam人脸检测项目由此诞生。后期还有其他项目:

        ESP32Cam的优势:

ESP32-CAM是安信可最新发布小尺寸的摄像头模组。该模块可以作为最小系统独立工作,尺寸仅为27*40.5*4.5mm,深度睡眠电流最低达到6mA。

ESP32-CAM可广泛应用于各种物联网场合,适用于家庭智能设备、工业无线控制、无线监控、QR无线识别,无线定位系统信号以及其它物联网应用,是物联网应用的理想解决方案

ESP32-CAM采用DIP封装,直接插上底板即可使用,实现产品的快速生产,为客户提供高可靠性的连接方式,方便应用于各种物联网硬件终端场合。

以下官网介绍:

                             ESP32-CAM摄像头开发板 | 安信可科技 (ai-thinker.com)

        1.人脸检测

        2.人脸识别(后续新的文章介绍)


人脸检测项目环境:

        1.Arduino  ESP32环境如下        

        2.Pycharm  opencv环境如下


 人脸检测项目链接

                              百度网盘 请输入提取码


人脸检测项目心路历程:

        大家一定要知道做一个东西的前提是环境要搭建好,这样做项目才能顺畅。首先就是下载软件,安装各种库和开发板管理,这些其实vscode一个软件就能做到,我仍然感觉术业有专攻,所以大家也可以下载一下。

        特此鸣谢以下博主对个人的帮助:

                ESP32-CAM摄像头+Arduino IDE+Web Server局域网显示 - 知乎 (zhihu.com)

                【开源】ESP32-cam+python 实现人脸识别(opencv)_哔哩哔哩_bilibili

                ESP32-CAM使用+源码分析 - 腾讯云开发者社区-腾讯云 (tencent.com)

     【ESP32-CAM】使用opencv获取ESP32-CAM视频流(一)_随笔_内存溢出 (outofmemory.cn)

大家没有思路的时候可以参考以上博主,别在知识的海洋迷路!

arduino配置:

硬件图:

        

                   

 建议大家购买ESP32Cam的时候开发板转接板,这个更方便自己操作。

 


 Arduino成功下载程序界面:

  ESP32Cam成功连接目标wifi串口界面:

 Pycharm配置:

 

 安装及库的安装,可以参照我以前的文章:

        (56条消息) Python安装与使用_嵌入式up的博客-CSDN博客_python安装和使用

(56条消息) 【python养成】:pip3如何安装依赖库和换国内源安装库_嵌入式up的博客-CSDN博客_pip3 换源

opencv的使用还请大家自行学习,这里不做概述,上面也有项目可以练手。

 Arduino源码:

#include 
#include 
#include 
const char* WIFI_SSID = "ESP32";  // 改成自己的wifi名称
const char* WIFI_PASS = "12345678";  // 改成自己的wifi密码
WebServer server(80);
static auto loRes = esp32cam::Resolution::find(320, 240);
static auto hiRes = esp32cam::Resolution::find(800, 600);
void handleBmp()
{
  if (!esp32cam::Camera.changeResolution(loRes)) {
    Serial.println("SET-LO-RES FAIL");
  }
  auto frame = esp32cam::capture();
  if (frame == nullptr) {
    Serial.println("CAPTURE FAIL");
    server.send(503, "", "");
    return;
  }
  Serial.printf("CAPTURE OK %dx%d %db\n", frame->getWidth(), frame->getHeight(),
                static_cast(frame->size()));
  if (!frame->toBmp()) {
    Serial.println("CONVERT FAIL");
    server.send(503, "", "");
    return;
  }
  Serial.printf("CONVERT OK %dx%d %db\n", frame->getWidth(), frame->getHeight(),
                static_cast(frame->size()));
  server.setContentLength(frame->size());
  server.send(200, "image/bmp");
  WiFiClient client = server.client();
  frame->writeTo(client);
}
void serveJpg()
{
  auto frame = esp32cam::capture();
  if (frame == nullptr) {
    Serial.println("CAPTURE FAIL");
    server.send(503, "", "");
    return;
  }
  Serial.printf("CAPTURE OK %dx%d %db\n", frame->getWidth(), frame->getHeight(),
                static_cast(frame->size()));
  server.setContentLength(frame->size());
  server.send(200, "image/jpeg");
  WiFiClient client = server.client();
  frame->writeTo(client);
}
void handleJpgLo()
{
  if (!esp32cam::Camera.changeResolution(loRes)) {
    Serial.println("SET-LO-RES FAIL");
  }
  serveJpg();
}
void handleJpgHi()
{
  if (!esp32cam::Camera.changeResolution(hiRes)) {
    Serial.println("SET-HI-RES FAIL");
  }
  serveJpg();
}
void handleJpg()
{
  server.sendHeader("Location", "/cam-hi.jpg");
  server.send(302, "", "");
}
void handleMjpeg()
{
  if (!esp32cam::Camera.changeResolution(hiRes)) {
    Serial.println("SET-HI-RES FAIL");
  }
  Serial.println("STREAM BEGIN");
  WiFiClient client = server.client();
  auto startTime = millis();
  int res = esp32cam::Camera.streamMjpeg(client);
  if (res 
微信扫一扫加客服

微信扫一扫加客服

点击启动AI问答
Draggable Icon