2012-09-30 20 views
5

Ich habe zwei Bilder von zwei Kameras der gleichen Marke aufgenommen, die etwas voneinander entfernt platziert wurden und die gleiche Szene aufnehmen. Ich möchte die reale Weltrotation und Übersetzung zwischen den beiden Kameras berechnen. Um dies zu erreichen, habe ich zuerst die SIFT-Funktionen der beiden Bilder extrahiert und angepasst.Multiple-View-Geometrie

Ich habe jetzt Fundamental Matrix sowie Homographie-Matrix. Jedoch nicht in der Lage, weiter zu gehen, viel Verwirrung. Kann mir jemand helfen, die Rotation und Übersetzung zwischen zwei Kameras zu schätzen?

Ich benutze OpenCV für Merkmalsextraktion und Matching, Homographie-Berechnungen.

Antwort

5

Wenn Sie die Homographie haben, dann haben Sie auch die Rotation. Sobald Sie Homographie haben, ist es leicht, Rotation und Translationsmatrix zu erhalten.

Zum Beispiel, wenn Sie OpenCV C++ verwenden:

param[in] H 
param[out] pose 
void cameraPoseFromHomography(const Mat& H, Mat& pose) 
{ 
    pose = Mat::eye(3, 4, CV_32FC1);  // 3x4 matrix, the camera pose 
    float norm1 = (float)norm(H.col(0)); 
    float norm2 = (float)norm(H.col(1)); 
    float tnorm = (norm1 + norm2)/2.0f; // Normalization value 

    Mat p1 = H.col(0);  // Pointer to first column of H 
    Mat p2 = pose.col(0); // Pointer to first column of pose (empty) 

    cv::normalize(p1, p2); // Normalize the rotation, and copies the column to pose 

    p1 = H.col(1);   // Pointer to second column of H 
    p2 = pose.col(1);  // Pointer to second column of pose (empty) 

    cv::normalize(p1, p2); // Normalize the rotation and copies the column to pose 

    p1 = pose.col(0); 
    p2 = pose.col(1); 

    Mat p3 = p1.cross(p2); // Computes the cross-product of p1 and p2 
    Mat c2 = pose.col(2); // Pointer to third column of pose 
    p3.copyTo(c2);  // Third column is the crossproduct of columns one and two 

    pose.col(3) = H.col(2)/tnorm; //vector t [R|t] is the last column of pose 
} 

Diese Funktion berechnet de Kamera aus Homografie darstellen, in dem die Drehung enthalten ist. Für weitere theoretische Informationen folgen Sie dieser thread.

+0

Vielen Dank @Jav_Rock, Ihre Antwort hat mir geholfen, Pose zu schätzen. Für jede Bildgruppe ist die Pose-Matrix gleich, die ersten drei Spalten bilden eine Identitätsmatrix und die letzte Spalte ist leer. Hast du eine Idee dazu? – Aarambh

+0

Ich habe auch die homography-Matrix mit WarpAffine bestätigt, die die Ansicht eines Bildes korrekt auf ein anderes mappt. – Aarambh

+0

@ user1709317: 'H' und' pose' müssen vom selben Format sein. Sie werden wahrscheinlich die gewünschten Ergebnisse erhalten, wenn Sie 'CV_32FC1'->' CV_64FC1' ändern. – bjoernz