How can I optimize multiple stitching of images?

I am working on several lines of images in Visual Studio 2012, C ++. I changed stitching_detailed.cpp as per my requirement and gave quality results. The problem here is that it takes too much time to complete. For 10 image requires about 110 seconds .

Here where it takes most of the time:

1) Pair match - takes 55 seconds for 10 images! I use ORB to find function points. Here is the code:

vector<MatchesInfo> pairwise_matches;
BestOf2NearestMatcher matcher(false, 0.35);
matcher(features, pairwise_matches);
matcher.collectGarbage();

I tried to use this code, since I already know the sequence of images:

vector<MatchesInfo> pairwise_matches;
BestOf2NearestMatcher matcher(false, 0.35);

Mat matchMask(features.size(),features.size(),CV_8U,Scalar(0));
for (int i = 0; i < num_images -1; ++i)                                                 
    matchMask.at<char>(i,i+1) =1;                                                       
matcher(features, pairwise_matches, matchMask);                                         

matcher.collectGarbage();

(18 ), . 6 ( 4 , 6 7 - . .)

2) - 38 10 ! :

for (int img_idx = 0; img_idx < num_images; ++img_idx)
{
    printf("Compositing image #%d\n",indices[img_idx]+1);

    // Read image and resize it if necessary
    full_img = imread(img_names[img_idx]);

    Mat K;
    cameras[img_idx].K().convertTo(K, CV_32F);

    // Warp the current image
    warper->warp(full_img, K, cameras[img_idx].R, INTER_LINEAR, BORDER_REFLECT, img_warped);

    // Warp the current image mask
    mask.create(full_img.size(), CV_8U);
    mask.setTo(Scalar::all(255));
    warper->warp(mask, K, cameras[img_idx].R, INTER_NEAREST, BORDER_CONSTANT, mask_warped);

    // Compensate exposure
    compensator->apply(img_idx, corners[img_idx], img_warped, mask_warped);

    img_warped.convertTo(img_warped_s, CV_16S);
    img_warped.release();
    full_img.release();
    mask.release();

    dilate(masks_warped[img_idx], dilated_mask, Mat());
    resize(dilated_mask, seam_mask, mask_warped.size());
    mask_warped = seam_mask & mask_warped;

    // Blend the current image
    blender->feed(img_warped_s, mask_warped, corners[img_idx]);
}

Mat result, result_mask;
blender->blend(result, result_mask);

- 4160 * 3120. , . .

, . .

3) - ORB. 10 10 . 1530 .

55 + 38 + 10 = 103 + 7 = 110.

android, () . , Android? (Android-, , 2 )

. !

1: , 38 16 . .

, 110 → 85 . ; , !

EDIT 2: matchers.cpp. , . , . , . 50 .

+4
1

55 18 , , . - , , , . , , , ORB, . , , , ( , ).

, , - , - . , . - , , ( ), , .

, , . , , , , .

- , , LG Google, Nexus :) .

0

Source: https://habr.com/ru/post/1671219/


All Articles