0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
电子发烧友
开通电子发烧友VIP会员 尊享10大特权
海量资料免费下载
精品直播免费看
优质内容免费畅学
课程9折专享价
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

怎樣用Wekinator和Arduino制作顏色分類器

454398 ? 來源:工程師吳畏 ? 2019-07-31 09:10 ? 次閱讀

電路圖

怎樣用Wekinator和Arduino制作顏色分類器

如何運(yùn)行程序

首先,在Arduino IDE的文章末尾粘貼為Arduino提供的代碼并上傳代碼。

然后您需要從Wekinator的示例頁(yè)面下載草圖。

下載源代碼以進(jìn)行處理實(shí)現(xiàn)10x10顏色網(wǎng)格。解壓縮并在處理中運(yùn)行代碼。該程序?qū)⑹褂霉P記本電腦網(wǎng)絡(luò)攝像頭,根據(jù)您在攝像頭前所做的操作,它將為Wekinator提供輸入。

Wekinator的輸出需要另一個(gè)草圖。該草圖的代碼在本文末尾。將其粘貼到處理中并運(yùn)行草圖。該草圖將從Wekinator輸出并將其發(fā)送到Arduino,LED將亮起。

兩個(gè)處理窗口應(yīng)如下所示。

現(xiàn)在打開Wekinator并進(jìn)行如下圖所示的設(shè)置。將輸入設(shè)置為100,將輸出設(shè)置為1.將類型設(shè)置為3的所有分類器,然后單擊下一步。

在前面拿一張彩色紙攝像頭并開始錄制半秒。

現(xiàn)在將班級(jí)更改為2.再次,向網(wǎng)絡(luò)攝像頭顯示另一種顏色的紙張,開始錄制半秒鐘。

現(xiàn)在將類更改為3,顯示另一種顏色的紙張,然后開始錄制半秒鐘。

之后,單擊“Train”,然后單擊“Run”?,F(xiàn)在連接到Arduino的LED將根據(jù)您在網(wǎng)絡(luò)攝像頭前顯示的顏色亮起。

ArduinoCode

#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 they should be same on both sides. */

int output;

// Initializing the pins for led‘s

int led1 = 8;

int led2 = 9;

int led3 = 10;

void setup()

{

/* Starting the serial communication because we are communicating with the

Arduino through serial. The baudrate should be same as on the processing side. */

Serial.begin(19200);

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led3, OUTPUT);

// Synchronizing the variable with the processing. The variables 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)

{

digitalWrite(led1, HIGH);

digitalWrite(led2, LOW);

digitalWrite(led3, LOW);

}

else if (output == 2)

{

digitalWrite(led1, LOW);

digitalWrite(led2, HIGH);

digitalWrite(led3, LOW);

}

else if (output == 3)

{

digitalWrite(led1, LOW);

digitalWrite(led2, LOW);

digitalWrite(led3, HIGH);

}

}

處理代碼

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;

// This variable will be syncronized with the Arduino and it 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”, 19200);

sender = new ValueSender(this, serial);

// Synchronizing the variable 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

}

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • Arduino
    +關(guān)注

    關(guān)注

    188

    文章

    6477

    瀏覽量

    188114
收藏 0人收藏

    評(píng)論

    相關(guān)推薦

    如何用SS1系列顏色傳感示教多通道顏色?

    基于白色LED光源的特性,深視智能SS1系列顏色傳感突破了傳統(tǒng)單色RGB、融合光RGB的波長(zhǎng)限制,將發(fā)射波長(zhǎng)的范圍覆蓋到整個(gè)可見光譜,最大支持檢測(cè)16種顏色。那么,我們?nèi)绾卫肧S1系列顏色
    的頭像 發(fā)表于 12-23 08:17 ?304次閱讀
    如何用SS1系列<b class='flag-5'>顏色</b>傳感<b class='flag-5'>器</b>示教多通道<b class='flag-5'>顏色</b>?

    如何用SS1系列顏色傳感設(shè)置目標(biāo)顏色?

    基于白色LED光源的特性,深視智能SS1系列顏色傳感突破了傳統(tǒng)單色RGB、融合光RGB的波長(zhǎng)限制,將發(fā)射波長(zhǎng)的范圍覆蓋到整個(gè)可見光譜,最大支持檢測(cè)16種顏色。那么,我們?nèi)绾卫?b class='flag-5'>顏色
    的頭像 發(fā)表于 11-19 01:04 ?249次閱讀
    如何用SS1系列<b class='flag-5'>顏色</b>傳感<b class='flag-5'>器</b>設(shè)置目標(biāo)<b class='flag-5'>顏色</b>?

    NE555制作點(diǎn)焊機(jī)

    NE555制作點(diǎn)焊機(jī),電路簡(jiǎn)單,容易制作。需要一個(gè)12v的鉛酸蓄電池。實(shí)際焊接效果很好。
    發(fā)表于 11-08 15:05 ?14次下載

    怎樣用THS3201實(shí)現(xiàn)輸出功率可調(diào)?

    怎樣用THS3201實(shí)現(xiàn)輸出功率可調(diào)?
    發(fā)表于 08-26 08:28

    OPA735加OPA333,怎樣用TINA TI去仿真?

    當(dāng)輸入信號(hào)VG1從7.06V慢慢變化到7.22V時(shí)。 輸出電壓Vout的變化必須是接近線性變化的。我想知道我該怎樣用TINA TI去仿真?怎樣設(shè)置那個(gè)輸入信號(hào)VG1才能達(dá)到我的目的。因?yàn)檫@個(gè)電壓源好像
    發(fā)表于 08-02 08:39

    怎樣用表測(cè)穩(wěn)壓管穩(wěn)壓值

    表是一種常用的電子測(cè)量工具,可以用來測(cè)量電壓、電流、電阻等多種參數(shù)。在測(cè)量穩(wěn)壓管的穩(wěn)壓值時(shí),我們可以使用萬表的直流電壓測(cè)量功能。以下是步驟和注意事項(xiàng): 準(zhǔn)備工具和材料 萬表 穩(wěn)壓管 電源
    的頭像 發(fā)表于 07-31 14:26 ?2058次閱讀

    怎樣用Arduino測(cè)試鋰電池容量

    本文詳細(xì)介紹了如何用Arduino測(cè)量鋰電池的容量。并附有電路圖和Arduino的程序代碼。
    的頭像 發(fā)表于 07-30 09:14 ?1091次閱讀
    <b class='flag-5'>怎樣用</b><b class='flag-5'>Arduino</b>測(cè)試鋰電池容量

    Arduino自制點(diǎn)焊機(jī)

    組裝18650電池組,要用到點(diǎn)焊機(jī),本文介紹Arduino控制點(diǎn)焊機(jī)的點(diǎn)焊時(shí)間。
    發(fā)表于 07-29 10:14 ?6次下載

    ESP32使用Arduino啟用藍(lán)牙后編譯固件過大,怎樣縮減大小呢?

    ESP32使用Arduino啟用藍(lán)牙后編譯固件過大,怎樣縮減大小,日志級(jí)別已經(jīng)最低了,分區(qū)不能動(dòng),已經(jīng)是1.9M的OTA分區(qū)配置了,怎樣還能縮減大小,藍(lán)牙功能能否裁剪
    發(fā)表于 06-28 11:27

    求助,在esp-idf中使用arduino作為組件后怎樣使用arduino的庫(kù)?

    在esp-idf中使用arduino作為組件后怎樣使用arduino的庫(kù),例如我此時(shí)需要使用arduino的第三方庫(kù)blinker,怎樣使用
    發(fā)表于 06-12 07:21

    怎樣用STM8L的PB3/TIM2_TRIG的引腳測(cè)量脈寬?

    怎樣用STM8L的PB3/TIM2_TRIG的引腳測(cè)量脈寬?
    發(fā)表于 05-07 06:55

    stm32f100怎樣用重映射功能?

    的是stm32f100c8t6b芯片,現(xiàn)在想用將PB1映射為TIM1_CH3N,在調(diào)用GPIO_PinAFConfig(GPIOB,GPIO_PinSource1,GPIO_AF_TIM1)時(shí), GPIO_PinAFConfig和GPIO_AF_TIM1都沒定義,stm32f100
    發(fā)表于 05-07 06:06

    如何用Arduino制作一個(gè)簡(jiǎn)易自動(dòng)喂魚

    如果你家里養(yǎng)有魚,并想找到一種自動(dòng)化喂食的方法,這個(gè)項(xiàng)目可能會(huì)對(duì)你有所啟發(fā)。 在這個(gè)教程中,作者將展示如何制作自己的基于Arduino的自動(dòng)喂魚,讓小魚不在餓肚子。 自動(dòng)喂魚
    發(fā)表于 03-28 11:25

    STM32F412G-DISCO怎樣用MX生成fatfs的代碼?

    STM32F412G-DISCO怎樣用MX生成fatfs的代碼? SD卡例程能跑,但mx生成的代碼不能正常運(yùn)行,我生成代碼后是不是還要配置一些東西?(我生成后只寫了測(cè)試代碼) 問題解決了,雖然我不知道我為什么不能直接使用mx生成的代碼去操作sd卡,但我通過復(fù)制粘貼例程的代碼完成了測(cè)試。
    發(fā)表于 03-12 08:15

    如何制作自己的Arduino電容計(jì)

    在這個(gè)項(xiàng)目中,您將學(xué)習(xí)如何制作自己的Arduino電容計(jì)(測(cè)量電容器的值,范圍從pF到1000的uF)。一般來說,電子愛好者喜歡設(shè)計(jì)自己的小工具而不是購(gòu)買。在這個(gè)項(xiàng)目中,我們使用兩種電容測(cè)量方法,即
    的頭像 發(fā)表于 02-25 15:10 ?1774次閱讀
    如何<b class='flag-5'>制作</b>自己的<b class='flag-5'>Arduino</b>電容計(jì)

    電子發(fā)燒友

    中國(guó)電子工程師最喜歡的網(wǎng)站

    • 2931785位工程師會(huì)員交流學(xué)習(xí)
    • 獲取您個(gè)性化的科技前沿技術(shù)信息
    • 參加活動(dòng)獲取豐厚的禮品