怎样用openFrameworks人脸跟踪器模式控制电机

在本指南中,我们将记录四个输出的样本:
对于出现在相机前面的面部。
对于出现在相机右侧的脸部。
对于距相机一定距离的脸部。
对于出现在相机前面的物体。
安装openframeworks人脸跟踪器模式
openframeworks的安装文件,以及面部追踪功能,可在wekinator网站上找到。
图像显示wekinator网站上面部跟踪下载文件的位置ite。
下载面部跟踪文件后,解压缩并运行程序。它应激活计算机网络摄像头以跟踪用户的面部。
使用计算机网络摄像头识别面部的面部跟踪器程序的示例图像。
处理指令
在处理方面,本指南将要求使用草图,该草图将从wekinator软件接收输出数据并将其转发给arduino。
import vsync.*; // importing the library that will help us in sending and receiving the values from the arduino
import processing.serial.*; // importing the serial library
// below libraries will connect and send, receive the values from wekinator
import oscp5.*;
import netp5.*;
// creating the instances
oscp5 oscp5;
netaddress dest;
valuesender sender;
// these variables will be syncronized with the arduino and they should be same on the arduino side.
public int output;
void setup()
{
// starting the serial communication, the baudrate and the com port should be same as on the arduino side.
serial serial = new serial(this, “com10”, 115200);
sender = new valuesender(this, serial);
// synchronizing the variables as on the arduino side. the order should be same.
sender.observe(“output”);
// starting the communication with wekinator. listen on port 12000, return messages on port 6448
oscp5 = new oscp5(this, 12000);
dest = new netaddress(“127.0.0.1”, 6448);
}
// recieve osc messages from wekinator
void oscevent(oscmessage theoscmessage) {
if (theoscmessage.checkaddrpattern(“/wek/outputs”) == true) {
// receiving the output from wekinator
float value = theoscmessage.get(0).floatvalue();
// converting the output to int type
output = int(value);
}
}
void draw()
{
// nothing to be drawn for this example
}
连接直流电机到arduino
处理草图将从wekinator发送输出数据到arduino,它将相应地控制电机。
为了将电机连接到arduino,请按照下图中的位置。
查看我们的文章详细说明如何通过openframework发送和接收数据平台使用arduinoto更好地了解openframeworks如何与arduino通信。
连接到arduino uno的电机示意图。
arduino代码
#include //including the library that will help us in receiving and sending the values from processing
valuereceiver《1》 receiver; /*creating the receiver that will receive only one value.
put the number of values to synchronize in the brackets */
/* the below variable will be synchronized in the processing
and it should be same on both sides. */
int output;
//motor pins
int en_a = 11;
int in1 = 9;
int in2 = 8;
int in3 = 7;
int in4 = 6;
int en_b = 10;
void setup()
{
/* starting the serial communication because we are communicating with the
processing through serial. the baudrate should be same as on the processing side. */
serial.begin(115200);
//initializing the motor pins as output
pinmode(en_a, output);
pinmode(in1, output);
pinmode(in2, output);
pinmode(in3, output);
pinmode(in4, output);
pinmode(en_b, output);
digitalwrite(en_a, high);
digitalwrite(en_b, high);
// synchronizing the variable with the processing. the variable must be int type.
receiver.observe(output);
}
void loop()
{
// receiving the output from the processing.
receiver.sync();
// matching the received output to light up led‘s
if (output == 1)
{
//forward
digitalwrite(in1, low);
digitalwrite(in2, high);
digitalwrite(in3, low);
digitalwrite(in4, high);
}
else if (output == 2)
{
//right
digitalwrite(in1, high);
digitalwrite(in2, low);
digitalwrite(in3, low);
digitalwrite(in4, low);
}
else if (output == 3)
{
//left
digitalwrite(in1, low);
digitalwrite(in2, low);
digitalwrite(in3, high);
digitalwrite(in4, low);
}
else if (output == 4)
{
//stop
digitalwrite(in1, low);
digitalwrite(in2, low);
digitalwrite(in3, low);
digitalwrite(in4, low);
}
}
在wekinator中使用人脸检测
第一步是启动wekinator平台并更改设置以反映下图中的设置。
将输入值设置为3.
将输出值设置为1.
将输出类型指定为“all continuous”
将所有其他设置保留为默认格式。
为了启用wekinator和openframeworks平台之间的通信,您需要下载chuck编程语言,你可以在查克官方网站上这样做。
了解更多信息在安装和使用wekinator程序时,请查看我们的如何开始使用wekinator的指南。
wekinator将从openframeworks应用程序接收3个输入,然后向chuck程序发送5个不同的输出,这会提示它产生不同的声音。
wekinator软件程序中的“创建新项目”窗口。
单击“下一步”,将显示“新建项目”窗口,如下所示。
wekinator软件程序中的“new project”窗口。
将脸靠近相机记录一些测试。将分类器输出值指定为“1”。您还需要记录此移动的简短示例。
显示面部追踪器功能如何识别靠近相机的面部的示例图像。
接下来,将您的脸移到屏幕右侧,将分类输出值更改为“2”。再一次,记录运动。
显示脸部追踪器功能如何识别相机右侧脸部的示例图像。
然后将您的脸部从相机中进一步向后移动并将分类器输出更改为“3”。
人脸跟踪器功能如何识别远离相机的脸部的示例图像。
最后一步是完全退出相机视图。将分类器输出分配给’4。‘
脸部追踪器功能的示例图像未在相机视图中识别脸部。
现在,当您点击“列车”然后“运行”按钮时,电机应会在相机上的位置移动。

电瓶修复——细说电池之“胶体”2-1
等离子清洗机的工作原理是怎样的
这4种CPU错误该如何找到,没找到会有什么后果
如何让炼钢都变得智能化
TDK推出电机运行电容器(最高运行温度100 °C)
怎样用openFrameworks人脸跟踪器模式控制电机
诺基亚X7搭载骁龙710和卡尔蔡司摄像头堪称千元手机拍照王者
区块链会给未来生活带来什么样的影响
长安汽车与百度达成战略合作,共同推动汽车智能化发展
工业互联网平台“腾讯木星云”发布
一款人见人爱的chatGPT类浏览器插件
可燃气体传感器报警器:检测天然气泄漏并发出警报
常用的尺寸测量仪器之内径测量仪,它的原理分析
LD-HG12火锅底料检测仪器的产品性能介绍
臭氧传感器应用
MBI5036 恒流LED驱动芯片,让LED全彩显示屏轻松升
异体iPS细胞的安全性得到确认,异体移植效果有望大幅提升提高
宇凡微2.4G合封芯片Y54G,一芯两用超高性价比
变频器输出的直流24V电源输出了故障,怎么办?
5G+AI双引擎组合有望成为疫情后真正的“通用技术”