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


C++ Stitcher类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例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: 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

示例7: while

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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: stitch1

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

示例13: 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

示例14: checkMultithreaded

float checkMultithreaded (string const & myResult, string const & learning)
{
    ofstream cmpLog("compare_log.txt", ofstream::trunc);
    if (!cmpLog.is_open())
    {
        cerr << "Cannot create compare_log file.\n";
        return 0;
    }

    map<int, vector<int> > myOdds = readOutput(myResult);
    map<int, vector<int> > trueOdds = readOutput(learning);

    int currentSetN = StartSet;
    int n_wrong = 0;
    float mark = 0;

    Stitcher stitcher;

    while (currentSetN < FinishSet)
    {
        vector<int> v1 = getNextSet(currentSetN, myOdds);
        vector<int> v2 = getNextSet(currentSetN, trueOdds);
        float tmpMark = compareResults(v1, v2);
        if (tmpMark != 1.0)
        {
            cmpLog << currentSetN << "\nmy odds:";
            printIntVector(cmpLog, v1);
            cmpLog << "true odds:";
            printIntVector(cmpLog, v2);

            int tmp;
            printMat_(cmpLog, stitcher.calcSetStitch2(currentSetN, &tmp));
            //Stitcher::printStitchMatrix(cmpLog, stitcher.calcSetStitch2(currentSetN));

            n_wrong += 1;

        }
        mark += tmpMark;
        currentSetN += 1;
    }
    cmpLog << n_wrong << " classified wrong.";
    cmpLog.close();
    return (currentSetN-StartSet>0) ? mark/(currentSetN-StartSet) : mark;
}
开发者ID:katepol,项目名称:PanoramaRecognition,代码行数:44,代码来源:Checker.cpp

示例15: main

int main()
{
/*
    Mat img = imread(IMAGE_PATH_PREFIX + "part5.jpg");
    imgs.push_back(img);
    img=imread(IMAGE_PATH_PREFIX+"part1.jpg");
    imgs.push_back(img);
    img=imread(IMAGE_PATH_PREFIX+"part8.jpg");
    imgs.push_back(img);
    img=imread(IMAGE_PATH_PREFIX+"part3.jpg");
    imgs.push_back(img);
    img=imread(IMAGE_PATH_PREFIX+"part6.jpg");
    imgs.push_back(img);
    img=imread(IMAGE_PATH_PREFIX+"part4.jpg");
    imgs.push_back(img);
    img=imread(IMAGE_PATH_PREFIX+"part7.jpg");
    imgs.push_back(img);
    img=imread(IMAGE_PATH_PREFIX+"part2.jpg");
    imgs.push_back(img);
*/
    Mat img;
    for (auto i = 1; i < 4; ++i) {
      std::string path = "t" + std::to_string(i) + ".jpg";
      std::cout << "add: " + path << std::endl;
      img = imread(path);
      imgs.push_back(img);
    }

    Mat pano;
    //Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
    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;
    }

    imwrite(result_name, pano);
    return 0;
}
开发者ID:zJoyceLee,项目名称:Python,代码行数:42,代码来源:main.cpp


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