0

こんにちは、opencv が提供するステッチ クラスを使用せずにいくつかの画像をステッチしようとしています。しかし、出力は予想外です。入出力イメージで説明します。

入力1ここに画像の説明を入力

入力2ここに画像の説明を入力

期待される出力ここに画像の説明を入力

実際の出力ここに画像の説明を入力

ROI のコピーに問題があると思います。誰でも助けてください!!!

ステッチ部分の私のコードは次のとおりです-

std::vector< Point2f > points1,points2;
        for( int i = 0; i < matches1.size(); i++ )
           {
            points1.push_back( keypoints_input1[matches1[i].queryIdx ].pt );
            points2.push_back( keypoints_input2[matches1[i].trainIdx ].pt );
           }
        /* Find the Homography Matrix for current and next frame*/
         Mat H1 = findHomography( points2, points1, CV_RANSAC );
         /* Use the Homography Matrix to warp the images*/
        cv::Mat result1;
        warpPerspective(input2, result1, H1, Size(input2.cols+150, input2.rows+150),     INTER_CUBIC);
        Mat stitch_1(Size(input2.cols+150, input2.rows+150),CV_8UC3);
        Mat roi1(stitch_1, Rect(0, 0,  input1.cols, input1.rows));
       Mat roi2(stitch_1, Rect(0, 0, result1.cols, result1.rows));
    
   
       input2.copyTo(roi1);
    result1.copyTo(roi2);

どこが間違っているのか誰にも教えてもらえますか? ありがとう。

編集: input1(640,360) と input2(790,510) はサイズが異なります。

4

1 に答える 1

0

この例がお役に立てば幸いです。

さまざまな画像でテストするのは興味深いことです。

編集:

このコードを試してください:

Mat stitch_1(Size(input2.cols*2+ input1.rows,input2.rows*2),CV_8UC3);
Mat roi1(stitch_1, Rect(0, 0,  input1.cols, input1.rows));
Mat roi2(stitch_1, Rect(0, 0, result1.cols, result1.rows));
result1.copyTo(roi2);
input1.copyTo(roi1);
imshow("final", stitch_1);
于 2014-02-25T09:30:13.140 に答える