当前位置: 首页>>代码示例>>C++>>正文


C++ Stitcher::stitch方法代码示例

本文整理汇总了C++中Stitcher::stitch方法的典型用法代码示例。如果您正苦于以下问题:C++ Stitcher::stitch方法的具体用法?C++ Stitcher::stitch怎么用?C++ Stitcher::stitch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stitcher的用法示例。


在下文中一共展示了Stitcher::stitch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: imread

OCL_PERF_TEST_P(stitch, b12, TEST_DETECTORS)
{
    UMat pano;

    vector<Mat> imgs;
    imgs.push_back( imread( getDataPath("stitching/b1.png") ) );
    imgs.push_back( imread( getDataPath("stitching/b2.png") ) );

    Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
    Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
            ? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
            : makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);

    declare.iterations(20);

    while(next())
    {
        Stitcher stitcher = Stitcher::createDefault();
        stitcher.setFeaturesFinder(featuresFinder);
        stitcher.setFeaturesMatcher(featuresMatcher);
        stitcher.setWarper(makePtr<SphericalWarper>());
        stitcher.setRegistrationResol(WORK_MEGAPIX);

        startTimer();
        stitcher.stitch(imgs, pano);
        stopTimer();
    }

    EXPECT_NEAR(pano.size().width, 1124, 50);
    EXPECT_NEAR(pano.size().height, 644, 30);

    SANITY_CHECK_NOTHING();
}
开发者ID:Jazmann,项目名称:opencv,代码行数:33,代码来源:perf_stitch.cpp

示例2: main

int main(int argc, char* argv[])
{
    {
        QApplication a(argc, argv);
        qtExample::MainWindow w;
        w.show();

        return a.exec();
    }


    std::chrono::steady_clock::time_point start_stitch = std::chrono::steady_clock::now();
    int retval = parseCmdArgs(argc, argv);
    if (retval) return -1;

    Mat pano;
    Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
    Stitcher::Status status = stitcher.stitch(imgs, pano);

    if (status != Stitcher::OK)
    {
        cout << "Can't stitch images, error code = " << int(status) << endl;
        return -1;
    }

    imwrite(result_name, pano);

    std::chrono::steady_clock::time_point end_end_stitch = std::chrono::steady_clock::now();

    std::cout << "Stitching took: " << std::chrono::duration_cast<std::chrono::milliseconds>(end_end_stitch - start_stitch).count() << " ms" << std::endl;
    return 0;
}
开发者ID:kingofthebongo2008,项目名称:opencv2,代码行数:32,代码来源:stitching.cpp

示例3: main

int main(int argc, char* argv[])
{
//	int retval = parseCmdArgs(argc, argv);
//	if (retval) return -1;

	Mat img1 = imread("DJI_0001.jpg");
	Mat img2 = imread("DJI_0002.jpg");
	if (img1.cols == 0 || img2.cols == 0) {
		cout << "Error reading file "<< endl;
		return -1;
	}
	imgs.push_back(img1);
	imgs.push_back(img2);

	Mat pano;
	Stitcher stitcher = Stitcher::createDefault();
	Stitcher::Status status = stitcher.stitch(imgs, pano);

	if (status != Stitcher::OK)
	{
		cout << "Can't stitch images, error code = " << int(status) << endl;
		return -1;
	}

	namedWindow("result");
	imwrite("pano.jpg", pano);
//	imshow("result", pano);
	return 0;
}
开发者ID:zlthinker,项目名称:opencv_exercise,代码行数:29,代码来源:main.cpp

示例4: stitch

int stitch()
{
	Mat a,b,c, stitched; 

	//a = imread("asd.jpg"); 
	//b = imread("bsd.jpg"); 
	//c = imread("csd.jpg"); 

	/*
	a = imread("test1.jpg"); 
	b = imread("test2.jpg"); 
	c = imread("test3.jpg"); 

	a = imread("1.jpg"); 
	b = imread("2.jpg"); 
	c = imread("3.jpg"); 

	a = imread("input1.jpg"); 
	b = imread("input2.jpg"); 
	*/
	
	a = imread("scene1.png"); 
	b = imread("scene2.png"); 


	//resize(a, a, Size(0,0), 0.4, 0.4);
	//resize(b, b, Size(0,0), 0.4, 0.4); 
	//resize(c, c, Size(0,0), 0.4, 0.4); 

	vector<Mat> imgs; 
	imgs.push_back(a); 
	//imgs.push_back(c); 
	imgs.push_back(b); 


	imshow("a", a); 
	imshow("b", b); 
	//imshow("c", c); 

	Stitcher stitcher = Stitcher::createDefault(); 
	Stitcher::Status status = stitcher.stitch(imgs, stitched); 
	if(status == Stitcher::OK)
	{
		//resize(stitched, stitched, Size(0,0), 0.3, 0.3); 
		imshow("stitched", stitched); 
	}
	else if(status == Stitcher::ERR_NEED_MORE_IMGS)
	{
		cout << "want more images" << endl; 
	}
	else
	{
		cout << "what?" << endl; 
	}


	waitKey(12345678); 

	return 0; 
}
开发者ID:karstenBehrendt,项目名称:various_scripts,代码行数:60,代码来源:opencvVeryBasicStitching.cpp

示例5: main

void main()
{
	vector< Mat > vImg;
	Mat rImg;

	auto image_paths = get_all_files_names_within_folder(".");

	for (auto path : image_paths) {
		if (path.find(".jpg") != string::npos) {
			cout << path << endl;
			vImg.push_back(imread(path));
		}
	}

	Stitcher stitcher = Stitcher::createDefault();


	unsigned long AAtime = 0, BBtime = 0; //check processing time  
	AAtime = getTickCount(); //check processing time  

	Stitcher::Status status = stitcher.stitch(vImg, rImg);

	BBtime = getTickCount(); //check processing time   
	printf("%.2lf sec \n", (BBtime - AAtime) / getTickFrequency()); //check processing time  

	if (Stitcher::OK == status) {
		namedWindow("Stitching Result", WINDOW_NORMAL | CV_WINDOW_KEEPRATIO);
		imshow("Stitching Result", rImg);
		waitKey(0);
	}

	else
		cout << "Stitching failed:" << status << endl;
}
开发者ID:daranday,项目名称:vision-projects,代码行数:34,代码来源:Stitcher.cpp

示例6: main

int main() {
    vector<Mat> images;

    // Read images 
    for(directory_iterator i(DATA_FOLDER_5), end_iter; i != end_iter; i++) {
        string im_name = i->path().filename().string();
        string filename = string(DATA_FOLDER_5) + im_name;
        Mat im = imread(filename);
        if(!im.empty()) 
            images.push_back(im);
    }

    cout << "Read " << images.size() << " images" << endl << "Now making panorama..." << endl;

    Mat panorama;

    Stitcher stitcher = Stitcher::createDefault();
    stitcher.stitch(images, panorama);

    namedWindow("Panorama", CV_WINDOW_NORMAL);
    imshow("Panorama", panorama);

    while(char(waitKey(1)) != 'q') {}

    return 0;
}
开发者ID:jinpeng,项目名称:practicalOpenCV,代码行数:26,代码来源:code11-5.cpp

示例7: stitch

bool stitch (const cv::vector <cv::Mat> & images, cv::Mat &result) {
    Stitcher stitcher = Stitcher::createDefault(false);//don't need gpu
    Stitcher::Status status = stitcher.stitch(images, result);
    
    if (status != Stitcher::OK) {
        return false;
    }
    return true;
}
开发者ID:DJI-Mobile-SDK-Tutorials,项目名称:iOS-PanoramaDemo,代码行数:9,代码来源:StitchingWrapper.cpp

示例8: Init

void VideoProcessor::Init(std::string filename)
{
	///生成全景图
	cv::VideoCapture cap;
	cap.open(filename);
	if (!cap.isOpened())
	{
		std::cout << "全景图-视频打开失败!" << std::endl;
		return ;
	}
	cv::Mat frame;//存储当前帧
	std::vector<cv::Mat> backImages;//存储背景的子图
	int count = 0;
	while (true)
	{
		++count;
		cap.read(frame);
		if (frame.empty())
		{
			std::cout << "全景图-图像读取失败" << std::endl;
			return;
		}

		if (count > 600 && ( count==650||count % 100 == 1 || count == 1152) && count < 1200)
		//if (count==5||count==370||count==400||count==445||count==490||count==540||count==600)
		{
			backImages.push_back(frame.clone());
		}
		if (count >= 1200)
		{
			break;
		}
	}
	std::cout << "子图个数:" << backImages.size() << "--- 正在生成全景图..." << std::endl;
	Stitcher stitcher = Stitcher::createDefault(false);
	Stitcher::Status status = stitcher.stitch(backImages, m_pano);
	if (status != Stitcher::OK)
	{
		cout << "全景图-Can't stitch images, error code=" << int(status) << endl;
		return ;
	}
	cv::cvtColor(m_pano, m_pano, cv::COLOR_BGR2GRAY);
	std::cout << "全景图生成成功!" << "全景图尺寸:" << m_pano.cols << "*" << m_pano.rows<<std::endl;
	cv::imshow("pano", m_pano);
	cv::waitKey();
	cv::destroyAllWindows();

	///提取全景图特征
	keyPointMatch.Set_trainImage(m_pano);
	std::cout << "提取全景图特征成功!" << std::endl;

	///初始化ViBe背景模型
	vibe_bgs.init(m_pano,frame);
	vibe_bgs.processFirstFrame(m_pano);
	std::cout << "初始化ViBe背景模型成功!" << std::endl;
	return ;
}
开发者ID:ztq09290929,项目名称:ptzProject,代码行数:57,代码来源:VideoProcessor.cpp

示例9: main

int main(int argc, char** argv){
    _left = Mat::zeros(480, 640, CV_8UC4);
    _right = Mat::zeros(480, 640, CV_8UC4);
    string outputWindow = "output";
    string leftWindow = "left";
    string rightWindow = "right";    

    ros::init(argc, argv, "image_stitcher_node");
    ros::NodeHandle nh;
    Mat output;
    namedWindow("output");
    
    Stitcher stitcher = Stitcher::createDefault(true);
    
    bool transformSet = false;
 
    image_transport::ImageTransport it(nh);
    image_transport::Subscriber left_sub = it.subscribe("/left_camera/image_raw", 2, leftCallback);
    image_transport::Subscriber right_sub = it.subscribe("/right_camera/image_raw", 2, rightCallback);    
    ros::Rate loop_rate(100);

    while(nh.ok()){
        vector<Mat> images;
        images.push_back(_left);
        images.push_back(_right);
        /*if (!transformSet){
            Stitcher::Status transform_status = stitcher.estimateTransform(images);
            if (transform_status == Stitcher::OK){
                transformSet = true;
                ROS_INFO("Transform Obtained");
            }
        }*/


                
        Stitcher::Status status = stitcher.stitch(images, output);
        images.clear();

        if (status != Stitcher::OK){
            ROS_ERROR("Unable to stitch");
        } else {
            imshow(outputWindow, output);
        }
        //imshow(leftWindow, _left);
        //imshow(rightWindow, _right);
        if (waitKey(10) == 27){
            break;
        }
        loop_rate.sleep();
        ros::spinOnce();
    }
} 
开发者ID:UBC-Snowbots,项目名称:Snowflake,代码行数:52,代码来源:image_stitcher.cpp

示例10: on_actionStitch_triggered

void Stitch::on_actionStitch_triggered()
{
    Stitcher stitcher = Stitcher::createDefault(false);
    Stitcher::Status status = stitcher.stitch(imgs, result);
    if(status == Stitcher::OK)
    {
        Mat rgb;
        cvtColor(result,rgb,CV_BGR2RGB);
        ui->imageLabel->setPixmap(QPixmap::fromImage(QImage(rgb.data,rgb.cols,rgb.rows,rgb.cols*rgb.channels(),QImage::Format_RGB888)));
        ui->imageLabel->resize(ui->imageLabel->pixmap()->size());
        ui->scrollAreaWidgetContents->setFixedSize(ui->imageLabel->size());
    }
}
开发者ID:JanathonL,项目名称:mini-PS,代码行数:13,代码来源:stitch.cpp

示例11: stitch

cv::Mat stitch (vector<Mat>& images)
{
    imgs = images;
    Mat pano;
    Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
    Stitcher::Status status = stitcher.stitch(imgs, pano);
    
    if (status != Stitcher::OK)
        {
        cout << "Can't stitch images, error code = " << int(status) << endl;
            //return 0;
        }
    return pano;
}
开发者ID:Eric-LeiYang,项目名称:OpenCVStitch,代码行数:14,代码来源:stitching.cpp

示例12: stitch

Mat stitch(vector<Mat> &imgs) {

    Mat stitched;
    Stitcher stitcher = Stitcher::createDefault(false);
    Stitcher::Status status = stitcher.stitch(imgs, stitched);

    if (status != Stitcher::OK)
    {
        cout << "Can't stitch images, error code = " << int(status) << endl;
        //return -1;
    }

    imwrite(result_name, stitched);
    return stitched;
}
开发者ID:yanastali,项目名称:object_tracking,代码行数:15,代码来源:stitch.cpp

示例13: expected_dst_size

OCL_PERF_TEST_P(stitch, boat, TEST_DETECTORS)
{
    Size expected_dst_size(10789, 2663);
    checkDeviceMaxMemoryAllocSize(expected_dst_size, CV_16SC3, 4);

#if defined(_WIN32) && !defined(_WIN64)
    if (cv::ocl::useOpenCL())
        throw ::perf::TestBase::PerfSkipTestException();
#endif

    UMat pano;

    vector<Mat> _imgs;
    _imgs.push_back( imread( getDataPath("stitching/boat1.jpg") ) );
    _imgs.push_back( imread( getDataPath("stitching/boat2.jpg") ) );
    _imgs.push_back( imread( getDataPath("stitching/boat3.jpg") ) );
    _imgs.push_back( imread( getDataPath("stitching/boat4.jpg") ) );
    _imgs.push_back( imread( getDataPath("stitching/boat5.jpg") ) );
    _imgs.push_back( imread( getDataPath("stitching/boat6.jpg") ) );
    vector<UMat> imgs = ToUMat(_imgs);

    Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
    Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
            ? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
            : makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);

    declare.iterations(20);

    while(next())
    {
        Stitcher stitcher = Stitcher::createDefault();
        stitcher.setFeaturesFinder(featuresFinder);
        stitcher.setFeaturesMatcher(featuresMatcher);
        stitcher.setWarper(makePtr<SphericalWarper>());
        stitcher.setRegistrationResol(WORK_MEGAPIX);

        startTimer();
        stitcher.stitch(imgs, pano);
        stopTimer();
    }

    EXPECT_NEAR(pano.size().width, expected_dst_size.width, 200);
    EXPECT_NEAR(pano.size().height, expected_dst_size.height, 100);

    SANITY_CHECK_NOTHING();
}
开发者ID:Jazmann,项目名称:opencv,代码行数:46,代码来源:perf_stitch.cpp

示例14: int

cv::Mat stitch1 (vector<Mat>& images)
{
    imgs = images;
    Mat pano;
    Mat test;
    //test = imread("aa.jpg");
    //imshow("a",test);
    Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
    Stitcher::Status status = stitcher.stitch(imgs, pano);
    
    if (status != Stitcher::OK)
        {
        cout << "Can't stitch images, error code = " << int(status) << endl;
            //return 0;
        }
    return pano;
}
开发者ID:Sapphirine,项目名称:HiSnoopy,代码行数:17,代码来源:stitching.cpp

示例15: main

int main(int argc, char* argv[])
{
    int retval = parseCmdArgs(argc, argv);
    if (retval) return -1;

    Mat pano;
    Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
    Stitcher::Status status = stitcher.stitch(imgs, pano);

    if (status != Stitcher::OK)
    {
        cout << "Can't stitch images, error code = " << int(status) << endl;
        return -1;
    }

    imwrite(result_name, pano);
    return 0;
}
开发者ID:BroboticsForever,项目名称:ComputerVision,代码行数:18,代码来源:stitching.cpp


注:本文中的Stitcher::stitch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。