duchengyao / gpu-based-image-stitching

A simple version of "GPU based parallel optimization for real time panoramic video stitching".
73 stars 8 forks source link

Error in calling new values #8

Closed hakkirah closed 8 months ago

hakkirah commented 1 year ago

Hello, I'm experiencing an issue while using your repository. I would like to use my own image by replacing the video in the dataset folder (.mp4), the image in the asset folder (.png), and the intrinsic parameter (.yaml) with my own data. However, when I run './image-stitching' with my own data in the terminal, the output reads your old .yaml data and I encounter a CV exception error. Could you kindly assist me with this problem? Fyi: i already change the directory in the coding, but the terminal still read your data.

duchengyao commented 1 year ago

@hakkirah

Is it just the resolution error?

Please provide the log

hakkirah commented 1 year ago

ssd/ws/gpu-based-image-stitching/build$ ./image-stitching Features in image #1: 1818 Features in image #2: 1982 Features in image #3: 1463 Features in image #4: 1754 Pairwise matchingInitial camera intrinsics #1: K: [151.32067397627, 0, 548.2645944483894; 0, 113.7358642158987, 325.9501472379208; 0, 0, 1] R: [0.9951604, -0.079031013, -0.058392871; -0.0070014941, 0.53571039, -0.84437269; 0.098013289, 0.84069514, 0.53256446] Initial camera intrinsics #2: K: [152.6399996831748, 0, 547.4274334416007; 0, 114.1418996151577, 324.6308886159155; 0, 0, 1] R: [0.99448889, -0.09220086, -0.049906395; 0.0068066395, 0.53179651, -0.84684473; 0.10461985, 0.84183806, 0.52949333] Initial camera intrinsics #3: K: [153.6469959591513, 0, 559.4599605000119; 0, 3.169030248398982, 241.9021340511059; 0, 0, 1] R: [0.99159598, 0.11760357, 0.053912688; 0.00021435307, 0.41523129, -0.90971577; -0.12937208, 0.9020822, 0.41171649] Initial camera intrinsics #4: K: [151.2338596186277, 0, 549.579269749326; 0, 3.162759633738576, 241.8532427755007; 0, 0, 1] R: [0.99137861, 0.11920693, 0.054386556; -1.4227189e-05, 0.41517559, -0.90974122; -0.13102743, 0.90189731, 0.41159794] Camera #1: K: [151.32067397627, 0, 548.2645944483894; 0, 113.7358642158987, 325.9501472379208; 0, 0, 1] R: [0.9951604, -0.079031013, -0.058392871; -0.0070014941, 0.53571039, -0.84437269; 0.098013289, 0.84069514, 0.53256446] Camera #2: K: [152.6399996831748, 0, 547.4274334416007; 0, 114.1418996151577, 324.6308886159155; 0, 0, 1] R: [0.99448889, -0.09220086, -0.049906395; 0.0068066395, 0.53179651, -0.84684473; 0.10461985, 0.84183806, 0.52949333] Camera #3: K: [153.6469959591513, 0, 559.4599605000119; 0, 3.169030248398982, 241.9021340511059; 0, 0, 1] R: [0.99159598, 0.11760357, 0.053912688; 0.00021435307, 0.41523129, -0.90971577; -0.12937208, 0.9020822, 0.41171649] Camera #4: K: [151.2338596186277, 0, 549.579269749326; 0, 3.162759633738576, 241.8532427755007; 0, 0, 1] R: [0.99137861, 0.11920693, 0.054386556; -1.4227189e-05, 0.41517559, -0.90974122; -0.13102743, 0.90189731, 0.41159794] warped_image_scale: 151.98 roi test[955 x 377 from (-477, 101)] roi test[955 x 376 from (-477, 102)] roi test[955 x 316 from (-477, 162)] roi test[955 x 316 from (-477, 162)] roi test2 [image_stitcher] 1.184e-06;0.0271081;9.28e-07;36.57 terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.0.0) /media/mimos-22-216/ssd/ws/opencv/modules/core/src/umatrix.cpp:545: error: (-215:Assertion failed) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function 'UMat'

Aborted (core dumped

duchengyao commented 1 year ago

@hakkirah

I have updated code, you can try it and paste log.

I guess the error is due to the following reason:

StitchingParamGenerator did not find a suitable feature point under the current parameters, resulting in an incorrect ROI. Please use "opencv/stitching_detailed" to find the correct parameters. (see https://docs.opencv.org/4.8.0/d8/d19/tutorial_stitcher.html)

JaySlamer commented 1 year ago

@hakkirah

I have updated code, you can try it and paste log.

I guess the error is due to the following reason:

StitchingParamGenerator did not find a suitable feature point under the current parameters, resulting in an incorrect ROI. Please use "opencv/stitching_detailed" to find the correct parameters. (see https://docs.opencv.org/4.8.0/d8/d19/tutorial_stitcher.html)

我也遇到了同样的问题,我用的是数据集的4个视频,麻烦更新下dataset分支。

duchengyao commented 1 year ago

@JaySlamer

完全不是同一个问题。

此 issue 是在使用自己的数据、标定文件时发生的,自带的数据集没问题。

请用master分支跑一遍,重新开一个issue并贴上所有的log。

hakkirah commented 1 year ago

i still got the same error. The error is due to the Umat function.. is it because of my image used?

hakkirah commented 1 year ago

this is one of my camera parameter

image

as you can see my image resolution is 1104, 621.. however you used 2k resolution, do you think ROI UMat error is due to this issue? if yes, how to fix it?

duchengyao commented 1 year ago

@hakkirah

I have updated code in commit Load resolution from camchain.yaml

Please get latest code of master using git pull, and try again.

If got the same error, please upload your images and paste camera parameter (not screenshot). I'll help you debug the program.

KristinSun commented 1 year ago

for (size_t i = 0; i < numimg; i++) { cv::FileStorage fsread( "../params/camchain" + std::to_string(i) + ".yaml",

        cv::FileStorage::READ);
    if (!fs_read.isOpened()) {
        fprintf(stderr, "%s:%d:loadParams falied. 'camera.yml' does not exist\n", __FILE__, __LINE__);
        return;
    }
    cv::Mat R, K;
    fs_read["KMat"] >> K;
    K.copyTo(k_vector[i]);
    fs_read["D"] >> d_vector[i];
    fs_read["RMat"] >> R;
    R.copyTo(r_vector[i]);
    fs_read["focal"] >> cam_focal_vector[i];
    fs_read["resolution"] >> resolution;
}这段代码是直接从yaml里面读取了相机参数,方便问一下怎么把四个相机参数存进去的呢?
duchengyao commented 1 year ago

@KristinSun 你是问如何生成yaml吗?