Skip to content

Instantly share code, notes, and snippets.

View TakashiNakagawa's full-sized avatar

TakashiNakagawa TakashiNakagawa

View GitHub Profile
@TakashiNakagawa
TakashiNakagawa / camera.py
Created May 6, 2014 02:10
computer vision5章
#!/usr/bin/python
# -*- coding: utf-8 -*-
from numpy import *
from scipy import linalg
class Camera(object):
""" ピンホールカメラを表すクラス """
def __init__(self,P):
@TakashiNakagawa
TakashiNakagawa / load_vggdata.py
Created May 6, 2014 02:18
computer vision5章
#!/usr/bin/python
# -*- coding: utf-8 -*-
from PIL import Image
from pylab import *
import camera
# 画像を読み込む
im1 = array(Image.open('images/001.jpg'))
im2 = array(Image.open('images/002.jpg'))
@TakashiNakagawa
TakashiNakagawa / 5.1.1.merton2d.py
Created May 6, 2014 02:19
computer vision5章
#!/usr/bin/python
# -*- coding: utf-8 -*-
from PIL import Image
from pylab import *
execfile('load_vggdata.py')
# 3D点を同次座標にして射影する
X = vstack( (points3D,ones(points3D.shape[1])) )
@TakashiNakagawa
TakashiNakagawa / 5.1.2.merton3d.py
Created May 6, 2014 02:29
computer vision5章
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pylab import *
execfile('load_vggdata.py')
# 3Dの点を描画する
from mpl_toolkits.mplot3d import axes3d
fig = figure()
@TakashiNakagawa
TakashiNakagawa / read_data.py
Created July 8, 2014 02:21
データを読み込んでグラフ表示
#coding:UTF-8
import numpy as np
import matplotlib.pyplot as pl
data = np.loadtxt("result_all.txt")
separate1 = 100000
pl.plot(data[:separate1, 1], data[:separate1, 2], 'g', linewidth=10)
@TakashiNakagawa
TakashiNakagawa / ofSystemUtils.cpp
Created August 16, 2014 02:50
ダイアログから日本語を文字化けせずに読み込む方法
#include <cstdlib>
//ワイド文字列からマルチバイト文字列
//ロケール依存
void narrow(const std::wstring &src, std::string &dest) {
setlocale(LC_CTYPE, "");
char *mbs = new char[src.length() * MB_CUR_MAX + 1];
wcstombs(mbs, src.c_str(), src.length() * MB_CUR_MAX + 1);
dest = mbs;
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Offlickr
# Hugo Haas <hugo@larve.net> -- http://larve.net/people/hugo/
# Homepage: http://code.google.com/p/offlickr/
# License: GPLv2
#
# Daniel Drucker <dmd@3e.org> contributed:
# * wget patch
# * backup of videos as well
;1.11
;n < 3 f(n) = n, n >= 3 f(n) = f(n - 1) + 2f(n - 2) + 3f(n-3)
(define (func n)
(cond ((< n 3) n)
(else (+ (func (- n 1)) (* 2 (func (- n 2))) (* 3 (func (- n 3)))))))
(print (func 10))
(define (func n)
(func-iter 2 1 0 n))
;1.12 pascal's triangle
(define (func n m)
(cond ((= n 1) 1)
((= m 1) (func (- n 1) m))
((= m n) (func (- n 1) (- m 1)))
(else (+ (func (- n 1) (- m 1) ) (func (- n 1) m)))))
(print (func 5 3))
;1.12 pascal's triangle
(define (func n m)
(cond ((= n 1) 1)
((= m 1) (func (- n 1) m))
((= m n) (func (- n 1) (- m 1)))
(else (+ (func (- n 1) (- m 1) ) (func (- n 1) m)))))
(print (func 5 3))