Mosaic Mosaic::createDefault(bool try_use_gpu) { Mosaic stitcher; stitcher.setRegistrationResol(0.6); stitcher.setSeamEstimationResol(0.1); stitcher.setCompositingResol(ORIG_RESOL); stitcher.setPanoConfidenceThresh(1); stitcher.setWaveCorrection(true); stitcher.setWaveCorrectKind(detail::WAVE_CORRECT_HORIZ); stitcher.setFeaturesMatcher(makePtr<detail::BestOf2NearestMatcher>(try_use_gpu)); stitcher.setBundleAdjuster(makePtr<detail::BundleAdjusterRay>()); #ifdef HAVE_OPENCV_CUDALEGACY if (try_use_gpu && cuda::getCudaEnabledDeviceCount() > 0) { #ifdef HAVE_OPENCV_XFEATURES2D stitcher.setFeaturesFinder(makePtr<detail::SurfFeaturesFinderGpu>()); #else stitcher.setFeaturesFinder(makePtr<detail::OrbFeaturesFinder>()); #endif stitcher.setWarper(makePtr<TranslationPlaneWarperGpu>()); //stitcher.setWarper(makePtr<TranslationPlaneWarper>()); stitcher.setSeamFinder(makePtr<detail::GraphCutSeamFinderGpu>()); } else #endif { #ifdef HAVE_OPENCV_XFEATURES2D stitcher.setFeaturesFinder(makePtr<detail::SurfFeaturesFinder>()); #else stitcher.setFeaturesFinder(makePtr<detail::OrbFeaturesFinder>()); #endif stitcher.setWarper(makePtr<TranslationPlaneWarper>()); stitcher.setSeamFinder(makePtr<detail::GraphCutSeamFinder>(detail::GraphCutSeamFinderBase::COST_COLOR)); } stitcher.setExposureCompensator(makePtr<detail::BlocksGainCompensator>()); stitcher.setBlender(makePtr<detail::MultiBandBlender>(try_use_gpu, false)); stitcher.work_scale_ = 1; stitcher.seam_scale_ = 1; stitcher.seam_work_aspect_ = 1; stitcher.warped_image_scale_ = 1; return stitcher; }
int main(int argc, char *argv[]) { if (argc != 2) { cout << "Stitch putanja_do_direktorija" << endl; return -1; } //String path = "/home/stanko/ClionProjects/Stitch/data/"; String path = argv[1]; //vector<Geo> gpsLocations; std::vector<UMat> imgs = loadImages(path); //std::vector<cuda::GpuMat> imgs = convertToGpu(imgs_); Mat matching_mask = Mat::zeros(imgs.size(), imgs.size(), CV_8U); for (int i = 0; i < imgs.size() - 1; ++i) { matching_mask.at<char>(i, i+1) = 1; matching_mask.at<char>(i+1, i) = 1; } UMat matching_mask_; matching_mask.copyTo(matching_mask_); // Stitcher se inicijalizira s defaultnim parametrima // rucno namjestamo SIFT feature Mosaic stitcher = Mosaic::createDefault(false); stitcher.setFeaturesFinder(makePtr<MosaicUAV::detail::SiftFeaturesFinder>()); //stitcher.setMatchingMask(matching_mask_); stitcher.setCompositingResol(0.6); int64 t = getTickCount(); cout << "Pocinje racunanje" << endl; Mat pano; Mosaic::Status status = stitcher.stitch(imgs, pano); cout << "Trebalo je " << (getTickCount() - t) / getTickFrequency() << " s" << endl; if (status != Mosaic::OK) { cout << "Can't stitch images, error code = " << status << endl; return -1; } imwrite("result.jpg", pano); return 0; }