blobscannerをインストールする

ジェスチャー認識をしたかったので、blobscannerをインストールした。

GitHub - robdanet/blobscanner: Blobscanner, a Processing's library for blob detection and analysis .

からソースファイルをインストール。

cd blobscanner
mkdir library
mkdir src/blobscanner
mv src/Detector.java src/blobscanner/
jar -cf library/blobscanner.jar src/blobscanner 

そのあと、このblobscannerのフォルダごと自分が使っているProcessing/libraryのディレクトリに移動する。

Raspberry Pi の node と npm のバージョンを上げる

参考からの丸コピペだけれど、毎回探していたので、記事にする。

$ sudo -i
$ apt-get remove nodered -y
$ apt-get remove nodejs nodejs-legacy -y
$ curl -L https://git.io/n-install | bash

新しい Terminal ウィンドウを起動して、インストール終了後のダイアログにしたがってコマンドを入力する(覚えていないので割愛するけれど、bash 叩けって感じだったはず)

$ . /root/.bashrc
$ node --version
nv7.6.0
$ npm --version

参考: - How do you install newest version of node.js on Raspberry Pi? - Stack Overflow

Microsoft Cognitive Services でバイナリ送る

Microsoft が提供している Microsoft Cognitive Services の Emotion API を使ってみた。

www.microsoft.com

パラメータがいろいろあり、かなり遊べる感じだったものの、どの API のサンプルを見ても URL で画像を送っている。ただ普通にreadFile して送りつけたら InvalidImageSize という名のエラーが出て、Image size is too small or too big. とか怒られて、そこで数時間詰まったので、メモ代わりに。

どうやら chunked transfer をサポートしていないことが問題らしく(参考:botframework - Microsoft Cognitive Services Emotion API. Error: 'Image size is too small or too big.' - Stack Overflow)、sync で読めばよいという話のよう。

以下、コード。

"use strict";

const request = require('request');
const fs = require('fs');

request.post({
  url: 'https://westus.api.cognitive.microsoft.com/emotion/v1.0/recognize',
  headers: {
    'Ocp-Apim-Subscription-Key': { SUBSCRIPTION-KEY },
    'Content-Type': 'application/octet-stream'
  },  
  method: 'POST',
  body: fs.readFileSync({ IMAGE FILE })
}, (error, response) => {
  let res = JSON.parse(response.body);
  console.log(res);
});

Connecting to eduroam (WPA-EAP) with Raspberry PI

I wanted to use eduroam with my Raspberry PI.

echo -n <password-for-wifi> | iconv -t utf16le | openssl md4

and create a hash for your authentication. Save the result somewhere for we’ll use it later on.

sudo vi /etc/network/interfaces

Open file for interfaces, and rewrite the wlan0 part as below.

allow-hotplug wlan0
iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  • make sure you write DHCP, or else you’re going no where.

And of course, you need to rewrite the wpa_supplicant.conf as well.

sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

At the bottom of the file,

network={
      ssid="eduroam"
      scan_ssid=1
      key_mgmt=WPA-EAP
      eap=PEAP
      identity="<your-username>"
      password=hash:<your-hashed-password>
      phase2="MSCHAPV2"
}
sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B
history -c
sudo reboot

If above doesn’t work, try out different methods and protocols…

Reference