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
""" | |
このプログラムは、Raspberry Pi 上でカメラ映像から物体を検出し、検出結果に基づいた説明を生成し、 | |
音声で読み上げる機能を提供します。 | |
主な機能: | |
1. カメラ映像から物体検出: YOLO モデルを使用して、カメラ映像から物体を検出し、各物体に枠とラベルを描画します。 | |
2. 検出結果の説明生成: OpenAI API を用いて、検出された物体についての説明文を生成します。 | |
3. 音声出力: gTTS (Google Text-to-Speech) を使い、生成された説明を音声で読み上げます。 | |
4. 操作方法: | |
- SPACEキー: 検出された物体に関する説明を生成し、音声で読み上げます。 |
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 cv2 | |
import openai | |
import os | |
import sys | |
import logging | |
from contextlib import contextmanager | |
from dotenv import load_dotenv | |
from ultralytics import YOLO | |
# 環境変数からAPIキーを読み込み |
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 | |
set -euf -o pipefail | |
function cleanup { | |
for pid in "${opencv_download_pid:-''}" "${contrib_download_pid:-''}" "${pip_install_pid:-''}"; do | |
if [ -z "${pid}" ]; then | |
kill "${pid}" | |
fi | |
done |
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
class ChangeColumnToUser < ActiveRecord::Migration[5.0] | |
def change | |
# 追加 | |
add_column :users, :piyo, :string | |
add_column :users, :piyo2, :string | |
# 削除 | |
remove_column :users, :piyo2, :string | |
# rename | |
rename_column :users, :name_x, :name | |
end |
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
# See | |
# http://qiita.com/jnchito/items/640f17e124ab263a54dd | |
require 'spec_helper' | |
class WeatherBot | |
def tweet_forecast | |
twitter_client.update '今日は晴れです' | |
rescue => e |
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
# ------ 実行例 | |
$ ruby rest.rb | |
id:064c0150-db48-11e4-835e-12f5ba1407e2, name:"ローン申請の 審査" | |
id:073f66b2-db36-11e4-bc81-12f5ba1407e2, name:"Assign Approver" | |
id:077a4cf8-db36-11e4-bc81-12f5ba1407e2, name:"Review Invoice" | |
id:0bd16b17-db39-11e4-b167-12f5ba1407e2, name:"Assign Approver" | |
id:0bf6a67d-db39-11e4-b167-12f5ba1407e2, name:"Review Invoice" | |
id:247d07d5-db14-11e4-9656-12f5ba1407e2, name:"Prepare Bank Transfer" | |
id:304be6fb-db4e-11e4-b444-12f5ba1407e2, name:"Assign Approver" | |
id:3079fbeb-db4e-11e4-b444-12f5ba1407e2, name:"Approve Invoice" |
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
$ rake -T routes | |
rake routes # Print out all defined routes in match order, with names | |
rake routes:csv # Print out all defined routes in CSV format | |
$ rake routes:csv | |
Prefix, Verb, URI Pattern, Controller#Action | |
data, GET, /data(.:format), data#index | |
, POST, /data(.:format), data#create | |
new_datum, GET, /data/new(.:format), data#new | |
edit_datum, GET, /data/:id/edit(.:format), data#edit |
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 | |
File.open(ARGV[0], "r:utf-8" ) do |f| | |
while line = f.gets | |
line2 = '' | |
line.chars do |c| | |
line2 += c | |
code = c.ord | |
line2 += ' ' unless 0 <= code && code <= 255 | |
end |
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 | |
# See Book "http://ptgmedia.pearsoncmg.com/images/9780321942043/samplepages/9780321942043.pdf" | |
# "From Mathematics to Generic Programming" | |
def odd?(n) | |
(n & 1) == 1 | |
end | |
def half(n) | |
n >> 1 | |
end |
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
# See http://keibakuroku.jp/category/brain-teaser | |
def pi_1(len) | |
count = 0 | |
k, a, b, a1, b1 = 2, 4, 1, 12, 4 | |
while TRUE | |
# Next approximation | |
p, q, k = k*k, 2*k+1, k+1 | |
a, b, a1, b1 = a1, b1, p * a + q * a1, p * b + q * b1 |
NewerOlder