Skip to content

Instantly share code, notes, and snippets.

@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)を書いたりして, 今や安価なモーションキャプチャのデファクトスタンダードとなってしまいました.

// private MultiSourceFrameReader multiFrameSourceReader = null;
this.multiFrameSourceReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.Body | FrameSourceTypes.BodyIndex);
this.multiFrameSourceReader.MultiSourceFrameArrived += this.FrameArrived;
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)
{
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);
@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
@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 / snipet.md
Last active February 21, 2016 14:28
golangお勉強

ifのよくあるパターン

break, continue, goto, returnで抜ける

f, err := os.Open(name)
if err != nil {
    return err
}
d, err := f.Stat()
if err != nil {
 return err
@non117
non117 / OCRClient.swift
Created October 26, 2016 13:41
OCRくん
//
// OCRClient.swift
// ReceiptManager
//
// Created by non on 2016/10/10.
// Copyright © 2016年 non. All rights reserved.
//
import Foundation
import Alamofire
@non117
non117 / frontModel.md
Last active December 14, 2016 13:57
fluxでのmodelのデータ構造について

背景

  • リストでチェックボックスのついてるやつをReact + Fluxでつくる
  • このときのjsレイヤのデータ構造をどうするか

問題

  • 単純にリストにするとアクションを適用するオブジェクトを選ぶのにfilterしないといけないのでは?

こんなAction

{
@non117
non117 / Task.js
Last active March 30, 2017 11:06
redux design models
import { PropTypes } from 'react';
import { Record } from 'immutable';
import { recordOf } from 'react-immutable-proptypes';
const TaskRecord = new Record({
id: undefined,
name: '',
deadline: undefined,
checked: false,
});