2013-08-21 34 views
5

私はPointGrey Ladybug3カメラを持っています。パノラマ(マルチ)カメラ(360°カメラと1つのカメラを見上げる5台のカメラ)です。 私はすべてのキャリブレーションと整流を行ったので、最終的には6つの画像のすべてのピクセルから、グローバルフレームで3次元の位置にあることがわかります。 今私がやることは、この3dポイントをパノラマ画像に変換することです。最も一般的には、次のような半径方向(正距円筒)投影である:すべての3Dの点について Radial Porjectionopencvを使用して3次元ポイントからパノラマ画像を作成する

(X、Y、Z)は、θを見つけることが可能だと同様に座標PHI:

Radial Picture Equation

私の質問は、opencvでこれを自動的に行うことができますか?または私が手動でこれを行う場合、シータのピクセルの束をイメージに変換する最良の方法は何ですか?

公式のladybug SDKは、このすべての操作にOpenGLを使用していますが、opencvでこれを実行できるかどうかは疑問でした。私はこの問題を解決するために使用されるアプローチは、以下であった

おかげで、

ホセ

答えて

4

  1. 所望の出力サイズの空の画像を作成します。
  2. 出力画像のすべてのピクセルについて、シータ座標とΦ座標を検索します。 (Linearly)Thetaは-PiからPiに、φは0からPiになります。
  3. 投影半径Rを設定し、θ、phi、Rから3D座標を見つけます。
  4. 3D点が表示されているカメラの数を求めます。対応するピクセル位置。
  5. ピクセルが主点に近いイメージのピクセルをコピーします。

    cv::Mat panoramic; 
    panoramic=cv::Mat::zeros(PANO_HEIGHT,PANO_WIDTH,CV_8UC3); 
    double theta, phi; 
    double R=calibration.getSphereRadius(); 
    int result; 
    
    double dRow=0; 
    double dCol=0; 
    
    for(int y = 0; y!= PANO_HEIGHT; y++){ 
        for(int x = 0; x !=PANO_WIDTH ; x++) { 
          //Rescale to [-pi, pi] 
         theta=-(2*PI*x/(PANO_WIDTH-1)-PI); //Sign change needed. 
          phi=PI*y/(PANO_HEIGHT-1); 
    
         //From theta and phi find the 3D coordinates. 
         double globalZ=R*cos(phi); 
          double globalX=R*sin(phi)*cos(theta); 
         double globalY=R*sin(phi)*sin(theta); 
    
    
         float minDistanceCenter=5000; // Doesn't depend on the image. 
    
         float distanceCenter; 
    
         //From the 3D coordinates, find in how many camera falls the point! 
         for(int cam = 0; cam!= 6; cam++){ 
          result=calibration.ladybugXYZtoRC(globalX, globalY, globalZ, cam, dRow, dCol); 
          if (result==0){ //The 3d point is visible from this camera 
           cv::Vec3b intensity = image[cam].at<cv::Vec3b>(dRow,dCol); 
           distanceCenter=sqrt(pow(dRow-imageHeight/2,2)+pow(dCol-imageWidth/2,2)); 
           if (distanceCenter<minDistanceCenter) { 
            panoramic.ptr<unsigned char>(y,x)[0]=intensity.val[0]; 
            panoramic.ptr<unsigned char>(y,x)[1]=intensity.val[1]; 
            panoramic.ptr<unsigned char>(y,x)[2]=intensity.val[2]; 
    
            minDistanceCenter=distanceCenter; 
           } 
          } 
         } 
    
        } 
    } 
    
    :または他の有効な基準が...

私のコードは次のようになります

関連する問題