Skip to content

Instantly share code, notes, and snippets.

@non117
non117 / get_ancestor_dir.py
Created September 28, 2012 08:38
先祖path
# -*- coding: utf-8 -*-
import os
def get_ancestor_dir(path, n):
'''
pathからn階層上のディレクトリを返す
path: ディレクトリの文字列. os.path.abspath(__file__)とかを想定.
n: 遡る階層の数
return: パスの文字列
'''
@non117
non117 / deleted.py
Created August 2, 2012 09:24
Boxnya plugin. mongodbと連携してTLのdeletedを通知するプラグイン.
# -*- coding: utf-8 -*-
from pymongo import Connection
from lib.core import Filter
class Deleted(Filter):
def init(self):
self.watch = [] # 監視対象のスクリーンネームを入れる. 空なら全部通知
addr = "localhost"
@non117
non117 / teiden.py
Created July 2, 2012 09:01
停電情報をpushするためのboxnyaプラグイン
# -*- coding: utf-8 -*-
import json
import urllib, urllib2
import time
from datetime import datetime
from lib.core import Input
class Teiden(Input):
def get_info(self):
俺の iPhone 4 (iOS 5.0.1) の JB 環境まとめ。とりあえず。
---
Sources
*Backspace Repos*
http://v.backspace.jp/repo/
*BigBoss*
http://apt.thebigboss.org/repofiles/cydia/dists/stable
@non117
non117 / scraping_template.py
Last active August 29, 2015 14:17
スクレイピングテンプレート.py
# -*- coding: utf-8 -*-
import lxml.html
import requests
from pathlib import Path
'''
urlを叩いてxpathを適用したelement[]を返すよ
'''
def getElement(url, xpath):
res = requests.get(url)
@non117
non117 / cv.py
Created January 2, 2015 09:19
cvで背景差分
# -*- coding: utf-8 -*-
import cv2
def main():
cap = cv2.VideoCapture(0)
#cap = cv2.VideoCapture('opatan.mp4')
ret, frame = cap.read()
if not ret:
return
for (int y = 0; y < depthHeight; ++y)
{
for (int x = 0; x < depthWidth; ++x)
{
int depthIndex = (y * depthWidth) + x;
byte player = bodyIndexBuffer[depthIndex];
if (player != 0xff)
{
ushort depth = depthBuffer[depthIndex];
ColorSpacePoint colorPoint = this.coordinateMapper.MapDepthPointToColorSpace(x, y, depth);
private void FrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
{
bool multiSourceFrameProcessed = false;
bool colorFrameProcessed = false;
bool depthFrameProcessed = false;
bool bodyIndexFrameProcessed = false;
MultiSourceFrame multiSourceFrame = e.FrameReference.AcquireFrame();
if (multiSourceFrame != null)
{
// private MultiSourceFrameReader multiFrameSourceReader = null;
this.multiFrameSourceReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.Body | FrameSourceTypes.BodyIndex);
this.multiFrameSourceReader.MultiSourceFrameArrived += this.FrameArrived;
@non117
non117 / kinectv2.md
Last active August 29, 2015 14:10
OUCC Advent Calendar 2014 7日目

すごいKinect たのしくラボ畜!

こんにちは. @non117 です. この記事はOUCC アドベントカレンダー 2014 7日目の記事です. 今日は私が研究で使ってるKinect v2について紹介しようと思います.

Kinectとは

KinectとはXbox 360のために開発されたNUI(ナチュラルユーザインターフェイス)の一つで, ジェスチャーや音声認識によってゲームへコマンドを入力するデバイスです. Kinectは普通のRGBカメラと赤外線カメラ, マイクを積んでおり, 人間の位置, 動き, 声などを認識することができます.

もともとはゲームの入力デバイスだったのですが, 安価な深度センサとして注目されてしまったお陰でエンタメ系の人々やガチ研究者の目についてしまいました. その結果, 有志がKinectの解析を行ったりOSSのドライバ(今はなきOpenNI)を書いたりして, 今や安価なモーションキャプチャのデファクトスタンダードとなってしまいました.