Monday, June 18, 2018

無断キャンセル 対策

予約リマインドのサービスは自動で予約の確認や前日の連絡もやってくれます。予約システムに連携できます。簡単に定型文を設定すればいいです。Text to Speech(音声合成機能)によって、設定されたメッセージを音声合成で読み上げます。興味があれば、ぜひ試してみてください。

関連のリンク
朝日新聞

Thursday, April 19, 2018

playing with facial recognition library

Deep learning and facial recognition is getting easier to implement these days. Tried to recognize japanese actresses with a face recognition library.

Instructions to build and run it in docker
1. Clone it from github
git clone https://......

2. docker build .

3. Create a directory that shared with the docker container.
mkdir face_recognition_docker

4. Run the docker image and link the new directory to the container
docker run -i -t -v ~/face_recognition_docker:/home /bin/bash

5. put images in face_recognition_docker directory. 
training data in face_recognition_docker/known_people. 
unknown image in face_recognition_docker/unknown.



6. run the command in the docker container. To know more about the parameters check the github page.
For example,
root@123456:/home# face_recognition --cpus -1 --tolerance 0.45 known_people/ unknown/
unknown/shiseido.jpg,yui
unknown/temple.jpg,yui
unknown/komatsu_u.jpg,komatsu
unknown/obama_unknown.jpg,unknown_person
unknown/obama_unknown.jpg,President_Barack_Obama

I needed to adjust the tolerance value as the pre-trained face model does not work very well on asians. You can see that face is recognized even if it is from difference angle for komatsu_u.jpg. Also unknown face is identified on the obama_unknown.jpg. Interesting result.

link
medium article
github code
docker image (didn't try)

Sunday, May 15, 2016

Facebook Messenger chat bot on AWS Lambda

Facebook and Line both announced their own messenger bot platform. Tried to develop a sample bot on AWS Lambda.
Took some time to get the HTTP request passed from AWS API Gateway to AWS Lambda function. Choose to do it in Node.js as I found an example online in medium blog.

Network diagram


Developed a simple bot that spill out the suggested recipe if you send him the ingredients.

For example, you send "Tomato egg" to the bot, it will response with recipe link and photo.



Will publish the source code soon when I have time.

Reference
Run Facebook Messenger Chat Bot on AWS Lambda (Medium.com)

Sunday, July 19, 2015

run your own high-end cloud gaming service on EC2 (Windows edition)

Stumbled upon this blog post about using AWS EC2 for gaming.

- The openvpn settings file provided are supposed to be used with TunnelBlick on Mac. Faced some problems with openvpn client in windows. Zerotier or hamachi should be easier to setup. Steam client detected the client after I connect with Zerotier.

- Streamed Final Fantasy XIII-2 and Borderlands 2. Borderlands was playable albeit a little laggy. FFXIII has some issues with the audio, constantly beeping in the background.

- Tried this on 30Mbit broadband. Will test this again when I get higher speed internet connection.

Tuesday, June 18, 2013

Android ADB devices offline

Most of the solutions found on the internet ask you to kill and restart adb server.

adb kill-server
adb start-server

unplug and plug in the mobile phone
uncheck and check the usb debugging option

This does not fix my problem.

Android 4.2.2 has a new security feature where user has to confirm the RSA signature of the computer before it is allowed to connect to the phone. Old version of ADB does not support this feature and will always show your device as offline.

Solution:-
1. Check your adb version and where your adb command points to, on my case, there is an older version of adb at /usr/bin.
adb version
Android Debug Bridge version 1.0.29

type -a adb
/usr/bin/adb

2. Delete the old adb and fastboot. Ubuntu's apt-get installed the outdated version.

cd /usr/bin
sudo rm fastboot
sudo rm adb

3. Download ADT/SDK from http://developer.android.com.
4. Update your system PATH and points to the updated adb

gedit .bashrc (ubuntu, replace with any other text editor you like)
add this to the last line of the file

export PATH=$PATH:...../adt-bundle-linux-x86_64-20130522/sdk/platform-tools (please replace it with the path to the sdk you downloaded)

5. Check your version again

type -a adb
.../adt-bundle-linux-x86_64-20130522/sdk/platform-tools/adb

adb version
Android Debug Bridge version 1.0.31

6. Plug in your phone and enjoy!

Sunday, April 21, 2013

Ambient Lighting Monitor with Android and Java

Fascinated by Arduino and Raspberry Pi recently. Found a cool application called "Ambient Lighting" which calculates the light on your monitor and changes the color of the LED accordingly. The effect is real time cinema-like movie watching experience.

Note that this video is stolen from http://brunql.github.io/ambilight/


Most of them are using LED with Arduino controller. None of the people think of using the screen of the mobile phone or tablet as a light source (they are probably too dim for the desired effect which I found out later).

This is a quick hack during the weekend, firstly take a screenshot of the current screen. It was easier than I thought using the Java built-in function of java.awt.Robot, createScreenCapture(). After that get all the Red, Green and Blue of each pixels and calculate the average color for the current screen. Ratios of the color according to the different positions such as main color on the top right or bottom left portion of the screen are ignored as my light source is limited (1 or 2 android phone) and could not display different color on each spot.

After that, I need a simple way to send the color data to the android phone. I got lazy and just use Simple Framework to serve HTTP response on configured port. For example, every time the phone send request to http://my_ip:7788, it would return the calculated average color for current screen. To make it easier, I return a simple HTML code to set the background color of the whole page with the calculated RGB value. The page will reload every 1 second using HTTP "META refresh" tag. Reload the page more frequently with javascript should result in a more realistic ambient lighting.

The result is less satisfactory than had been anticipated. The screen of the mobile phone is not as bright as expected even after manually tuning it to the maximum brightness. Probably can improve the effect after tuning the calculated color to make it look brighter. Position information should make multiple phones and tablets act as the "LED", albeit much more expensive. Just for the sake of fun as I have a couple of Android devices hanging around.

I have published the code on bitbucket and feel free to have a look if you are looking to waste some time to enhance your movie watching experience. =)

My code on bitbucket
Ambient light

Reference:
http://brunql.github.io/ambilight/
https://code.google.com/p/boblight/
https://code.google.com/p/light-pack/
http://learn.adafruit.com/adalight-diy-ambient-tv-lighting/download-and-install

Sunday, April 22, 2012

注音轉成拼音



時常看不懂Facebook上朋友寫的注音文。昨晚心血來潮用Javascript寫了一個轉換的程式。之後發現轉成拼音了仍然看不懂。驚!有待改進。

用javascript寫的原因是以後有時間可以將之變成chrome extension。Chrome extension主要是由javascript與網頁包裝而成的。那樣就可以隨時翻譯網頁上的注音文了。=)

可以把注音文貼在這裡然後按轉換的按鈕




解釋
要來喝一杯ㄇ
ㄇ念成m或ma。所以這里可以翻譯為"嗎"。(純屬猜測)

程式的流程
主要是將textarea裡的文字,呼叫javscript的string.replace()。

例:string.replace(new RegExp('ㄦ', 'g'),'er') - 將所有'ㄦ'換成拼音的'er'。

'g' 為global的意思。不那麼寫的話只有第一個matching的字體會被轉換。之後就呼叫alert()將結果顯示出來。

相關連結
注音符號列表 (維基百科)