🔺1、前序文章:
【基于 Libcurl 通过 https 访问翔云 OCR 实现人脸识别】
🔺2、main.c 函数:
通过语音控制开启人脸识别,摄像头亮灯2秒拍照
此 main.c 函数仅用于 “人脸识别控制开关电磁锁” 功能调试
#include <stdio.h>
#include <string.h>
#include "equipment.h"
#include "command.h"
#include <pthread.h>
#include <unistd.h>
#include <curl/curl.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
char buf[1024] = {
'\0'}; //用于存放翔云返回的数据
struct Equipment *findEquipByName(char *name,struct Equipment *phead); //一些函数声明
struct Command *findCommandByName(char *name,struct Command *phead);
void *voiceControlThread(void *data);
char *getPicBase64FromFile(char *filePath);
size_t readData(void *ptr, size_t size, size_t nmemb, void *stream);
unsigned int postUrl();
struct Equipment *equiphead = NULL; //设备工厂链表头节点
struct Command *cmdhead = NULL; //指令控制工厂链表节点头
int main()
{
if(wiringPiSetup() == -1){
//使用wiringPi库需要初始化
printf("wiringPiSetup failed!\n");
return -1;
}
equiphead = addEleLockToLink(equiphead); //各设备加入设备工厂
cmdhead = addVoiceControlToLink(cmdhead); //各指令控制加入指令控制工厂
struct Equipment *tmpequiphead = equiphead;
while(tmpequiphead != NULL){
//设备工厂所有设备初始化
tmpequiphead->Init(tmpequiphead->pinNum);
tmpequiphead = tmpequiphead->next;
}
pthread_t voiceControl_thread;
pthread_create(&voiceControl_thread,NULL,voiceControlThread,NULL); //创建线程:语音控制
pthread_join(voiceControl_thread, NULL); //主函数等待线程退出
return 0;
}
void *voiceControlThread(void *data) //“语音控制线程”执行的函数
{
int nread;
char *temName = NULL;
struct Command *voiceHandler = NULL;
struct Equipment *linkHandler;
voiceHandler = findCommandByName("voiceControl",cmdhead); //寻找“语音控制”所在节点,返回给voiceHandler
if(voiceHandler <

本文介绍了一个基于树莓派的智能门禁系统,该系统利用语音识别控制人脸识别过程,并通过电磁锁实现门禁开关。系统使用wiringPi库进行GPIO控制,并通过Libcurl库发送HTTP请求与远程OCR服务交互。
最低0.47元/天 解锁文章
2497

被折叠的 条评论
为什么被折叠?



