This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
CloudVisonを使って遊んでみる | |
APIに画像を渡し、結果をJSON形式で受け取る | |
''' | |
#CloudVisonのAPI keyにAPIキーを渡す。 | |
API_URL = 'https://vision.googleapis.com/v1/images:annotate?key=' | |
#APIのキー https://console.cloud.google.com で確認する。 | |
API_KEY = 'himitu' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
CloudVisonを使って遊んでみる | |
APIに画像を渡し、結果をJSON形式で受け取る | |
''' | |
#リクエスト処理に必要なライブラリ | |
import requests | |
#CloudVisonのAPI keyにAPIキーを渡す。 | |
API_URL = 'https://vision.googleapis.com/v1/images:annotate?key=' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_json_data_byHashtag(hashTag): | |
# ツイート取得用のURL | |
url = "https://api.twitter.com/1.1/search/tweets.json?" | |
#リクエストパラメータ | |
params = { | |
'q': str(hashTag), | |
'count':'100', | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
演習2 | |
文字列の入れかえとか | |
''' | |
def subject2(): | |
coffe_cup = 'WATAER' | |
print('coffe_cup=%s' % coffe_cup) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from requests_oauthlib import OAuth1Session | |
import json | |
import requests | |
#認証情報 | |
outh_key_dict = { | |
'consumer_key': 'JQW4vn3OFHmorXrf0KQziSrC3', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wiringpi as pi | |
import time | |
#割り当てるPIN番号とステッピングモータの線の関係 | |
BLUE_A1 = 4 | |
WHITE_A2 = 17 | |
YELLOW_B1 = 27 | |
RED_B2 = 22 | |
#信号をおくる間隔(秒) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
!/bin/bash | |
#キーボードとwifiドングルを交換してwifiドングルが認識されるまで余裕をもってまつ | |
sleep 40s | |
echo "lsusb ......................" | |
lsusb | |
echo "ifconfig ......................" | |
ifconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import sys | |
import termios | |
import tty | |
import socket | |
def send_order(host): | |
''' | |
キーボードから入力した文字を一文字ごと、ソケット通信で通信先に送る。 | |
qを押すと終了する。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import socket | |
import legocar_controller as LegoCar | |
def recieve_order(): | |
''' | |
クライアントsocketからデータを受け取ります。 | |
受け取るデータは、ASCの1文字を想定しています。 | |
受け取ったデータは、wirigpiを実装しているモジュールに渡します。 | |
TODO:ブロックキングのシングルスレッドで実装している。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import wiringpi as pi | |
import sys | |
class LegoCarController: | |
''' | |
レゴカーを動かすためのクラス | |
前進と後退するためのDCモーター、ステアリング処理を行うサーボモータを制御している。 | |
制御するためのGPIOは、初期処理で固定で決めている。 | |
''' |
OlderNewer