Example #1
0
    def setUp(self):
        points = array([
            [-1.1, -1.1, -1.1],
            [1.4, -1.4, -1.4],
            [-1.5, 1.5, -1],
            [1, 1.8, -1],
            [-1.2, -1.2, 1.2],
            [1.3, -1.3, 1.3],
            [-1.6, 1.6, 1],
            [1, 1.7, 1],
        ])
        points = homography.make_homog(points.T)

        P = hstack((eye(3), array([[0], [0], [0]])))
        cam = camera.Camera(P)
        self.x = cam.project(points)

        r = [0.05, 0.1, 0.15]
        rot = camera.rotation_matrix(r)
        cam.P = dot(cam.P, rot)
        cam.P[:, 3] = array([1, 0, 0])
        self.x2 = cam.project(points)
        print self.x2.shape
        print self.x2

        K, R, t = cam.factor()
        self.expectedE = dot(sfm.skew(t), R)
        self.expectedE /= self.expectedE[2, 2]
Example #2
0
  def setUp(self):
    points = array([
      [-1.1, -1.1, -1.1], [ 1.4, -1.4, -1.4], [-1.5,  1.5, -1], [ 1,  1.8, -1],
      [-1.2, -1.2,  1.2], [ 1.3, -1.3,  1.3], [-1.6,  1.6,  1], [ 1,  1.7,  1],
      ])
    points = homography.make_homog(points.T)

    P = hstack((eye(3), array([[0], [0], [0]])))
    cam = camera.Camera(P)
    self.x = cam.project(points)

    r = [0.05, 0.1, 0.15]
    rot = camera.rotation_matrix(r)
    cam.P = dot(cam.P, rot)
    cam.P[:, 3] = array([1, 0, 0])
    self.x2 = cam.project(points)

    K, R, t = cam.factor()
    self.expectedE = dot(sfm.skew(t), R)
    self.expectedE /= self.expectedE[2, 2]
Example #3
0
@author: ray
"""

import camera
import numpy as np
import pylab

#load points
points = loadtxt('data/house.p3d').T
points = np.vstack((points,np.ones(points.shape[1])))


P = np.hstack((np.eye(3),np.array([[0],[0],[-10]])))
cam = camera.Camera(P)
x = cam.project(points)

# plot projection
figure()
plot(x[0],x[1],'k.')
show()

r = 0.05*np.random.rand(3)
rot = camera.rotation_matrix(r)

figure()
for t in range(20):
    cam.P = np.dot(cam.P,rot)
    x = cam.project(points)
    plot(x[0],x[1],'k')
show()
Example #4
0
"""
from PIL import Image
from numpy import *
import camera
# load points
points = loadtxt('../pcv_data/data/3D/house.p3d').T
points = vstack((points,ones(points.shape[1])))
# setup camera
P = hstack((eye(3),array([[0],[0],[-10]])))
cam = camera.Camera(P)
x = cam.project(points)
# plot projection
figure()
plot(x[0],x[1],'k.')
show()
# create transformation
r = 0.05*random.rand(3)
rot = camera.rotation_matrix(r)
# rotate camera and project
figure()
for t in range(20):
  cam.P = dot(cam.P,rot)
  x = cam.project(points)
  plot(x[0],x[1],'k.')
show()
K = array([[1000,0,500],[0,1000,300],[0,0,1]])
tmp = camera.rotation_matrix([0,0,1])[:3,:3]
Rt = hstack((tmp,array([[50],[40],[30]])))
cam = camera.Camera(dot(K,Rt))
print K,Rt
print cam.factor()
Example #5
0
File: 0519.py Project: ta-oyama/PCV
Created on Fri May 15 11:55:20 2015

@author: taiki
"""
from PIL import Image, ImageDraw
import numpy as np
from scipy import linalg
import matplotlib.pyplot as plt
import camera
import homography
import sift
#reload(camera)

#4.1.3 カメラ行列の分解
K = np.array([[1000,0,500],[0,1000,300],[0,0,1]])
tmp = camera.rotation_matrix([0,0,1])[:3,:3]
Rt = np.hstack((tmp,np.array([[50],[40],[30]])))
cam = camera.Camera(np.dot(K,Rt))

print K,Rt
print cam.factor()


#4.2.1 単純なキャリブレーション方法
def my_calibration(sz):
    row,col = sz
    fx = 2555.0*col/2592
    fy = 2586.0*row/1936
    K = np.diag([fx,fy,1])
    K[0,2] = 0.5*col
    K[1,2] = 0.5*row
Example #6
0
import camera
import numpy

K = numpy.array([[1000, 0, 500],
                 [0, 1000, 300],
                 [0, 0, 1]])
tmp = camera.rotation_matrix([0, 0, 1.0])[:3, :3]
Rt = numpy.hstack((tmp, numpy.array([[50], [40], [30]])))
cam = camera.Camera(numpy.dot(K, Rt))

print K, Rt
print cam.factor()
print cam.center()
import camera
from pylab import *
import numpy as np

# 载入点
points = loadtxt('../data/model_house/3D/house.p3d').T
points = vstack((points, ones(points.shape[1])))

# 设置照相机参数
P = hstack((eye(3), array([[0], [0], [-10]])))
cam = camera.Camera(P)
x = cam.project(points)

# 绘制投影
figure()
plot(x[0], x[1], 'k.')
show()

# 创建变换
r = 0.05 * np.random.rand(3)
rot = camera.rotation_matrix(r)
# 旋转矩阵和投影 figure()
for t in range(20):
    cam.P = dot(cam.P, rot)
    x = cam.project(points)
    plot(x[0], x[1], 'k.')

    show()