2013-07-30 5 views
2

PCA로 지향 경계 상자를 크립하려고합니다. 나는에 포인트를 프로젝트에 노력 PCA 구성 요소 PCA로 경계 상자

:

enter image description here

  • 레드 포인트 : 포인트 클라우드
  • 블루 벡터 이미지에서 내 결과를 볼 수 있습니다 최소, 최대 및 평균값을 얻기 위해 벡터.

    하지만 지금 내 상자를 어떻게 정의 할 수 있습니까? 어떤 아이디어?

    상자를 얻고 싶습니다 : centroid, min max 두 방향.

답변

0

비행기의 점과 선을 처리하는 방법에 관해서는 시프 팅 포인트와 선으로 투영되는 점에 관해서는 PCA, 에 대한 질문이 많지 않습니다. 은 여기 (이것의 기초를 들어, SO questions/tagged/2d+geometry, 통해보고하거나 해당 태그에 새로운 질문을 부탁드립니다.) 를 그 기초하지 않고, 그리고 약간의 파이썬이나 matlab에, 이 작은 파이썬 프로그램은 아무 의미, 하지 않습니다하지만 어쨌든 :

from __future__ import division 
import numpy as np # http://www.numpy.org/ 

def pcabox(Pointcloud, Pca1, Pca2): 
    """ Lo1, Hi1, Lo2, Hi2 = pcabox(Pointcloud, Pca1, Pca2) 
     In: Pointcloud: an N x 2 array of points 
     In: Pca1, Pca2: unit vectors at right angles, from PCA 
     Out: Lo1, Hi1, Lo2, Hi2: midpoints of the sides of a bounding box 
    """ 
     # convert inputs to numpy arrays (if they aren't already) -- 
    Pointcloud = np.asarray(Pointcloud) 
    Pca1 = np.asarray(pca1) 
    Pca2 = np.asarray(pca2) 
     # check N x 2 -- 
    assert Pointcloud.ndim == 2 and Pointcloud.shape[1] == 2, Pointcloud.shape 

    C = np.mean(Pointcloud, axis=0) # the centre of all the points 
    Pointcloud = Pointcloud - C # shift the cloud to be centred at [0 0] 

     # distances along the long axis t * Pca1 -- 
    Dist1 = np.dot(Pointcloud, Pca1) 
    Lo1 = Dist1.min() * Pca1 
    Hi1 = Dist1.max() * Pca1 
     # and along the short axis t * Pca2 -- 
    Dist2 = np.dot(Pointcloud, Pca2) 
    Lo2 = Dist2.min() * Pca2 
    Hi2 = Dist2.max() * Pca2 

    return [Lo1, Hi1, Lo2, Hi2] + C # 4 points 
+1

나는 그가 PCL (pointcloud 라이브러리)을 사용하고 있으며 대답은 pcl 클래스/기능을 사용해야한다고 생각합니다. – NKN