本文整理汇总了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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 ;
}
示例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();
}
}
示例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());
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}