發表文章

目前顯示的是有「opencv」標籤的文章

結合Mqtt&opencv人臉辨識讓伺服馬達動作

圖片
 結合Mqtt&opencv人臉辨識讓伺服馬達動作 這個主題的意義主要是運用在人臉辨別門禁上,當然要真正用在門機的門禁要複雜一些,因為還要評估效能和穩定性,但原理上大致是如此。 按照步驟如下: 1.如何訓練出一張認識的臉 https://opencv-goodcap.blogspot.com/2022/09/opencv.html 2.ESP32端 上傳至esp32 #include <WiFiClient.h> #include <PubSubClient.h> #include <Servo.h> WiFiClient espClient ; PubSubClient client ( espClient ); const char * ssid = "---" ; const char * password = "------" ; const char * mqtt_server = "192.168.--.--" ; Servo myservo ; int pos = 20 ; //如果連線至MQTT成功,即會開始接收訂閱的主題 void reconnect (){   while ( ! client . connected ()){     Serial . print ( "Attempting MQTT connection..." );     if ( client . connect ( "esp32Client" )){       Serial . println ( "connected" );       client . subscribe ( "door/close" ); //伺服馬達     } else {       Serial . print ( "failed connected is : " );       Serial . println ( client . state ());       dela...