2

I have this code:

#include <opencv2\stitching\stitcher.hpp>

int Stitching()
{
Stitcher m_stitcher = m_stitcher.createDefault(false);

vector<Mat> images; 
Mat img1 = imread("0.jpg"); //read image 0
Mat img2 = imread("1.jpg"); //read image 1
Mat Result;

//add images to the array
images.push_back(img1);
images.push_back(img2);

m_stitcher.stitch(images, Result);
imwrite("panorama.jpg",Result);
return 0;
}

After build I get this error:

Error 4 error C2248: 'cv::Stitcher::Stitcher' : cannot access private member declared in class 'cv::Stitcher' C:\Users\Desktop\Projects\SamplePanorama - PanoramaStitch\SamplePanorama \StitchEngine.cpp 602

What should i add to make the stitch() work correctly?

solvingPuzzles
  • 8,541
  • 16
  • 69
  • 112
Vinshi
  • 313
  • 2
  • 7
  • 27

1 Answers1

0

It would appear that your class Stitcher does not have a public constructor. If this were a class you owned, you would need to give it a public constructor in order to be able to construct an instance of Stitcher. However, it seems that this is a third party library, a quick google search tells you about the presence of this method in Stitcher:

static Stitcher createDefault(bool try_use_gpu = false);

In order to create an instance of Stitcher you would probably have to do something like:

Stitcher m_stitcher = Stitcher::CreateDefault();

Edit: In order to fix your linker errors, you probably need to add the correct lib files to the list of inputs to your linker. This link should help you set that up, http://opencv.willowgarage.com/wiki/InstallGuide

Tejas Sharma
  • 3,420
  • 22
  • 35
  • i did try the createDefault() function. Getting this error:error LNK2019: unresolved external symbol "public: enum cv::Stitcher::Status __thiscall cv::Stitcher::stitch(class cv::_InputArray const &,class cv::_OutputArray const &)" (?stitch@Stitcher@cv@@QAE?AW4Status@12@ABV_InputArray@2@ABV_OutputArray@2@@Z) referenced in function "public: int __thiscall CStitchEngine::PanoramaStitch(void)" (?PanoramaStitch@CStitchEngine@@QAEHXZ) – Vinshi Dec 19 '12 at 20:50
  • and this one too: error LNK2019: unresolved external symbol "public: static class cv::Stitcher __cdecl cv::Stitcher::createDefault(bool)" (?createDefault@Stitcher@cv@@SA?AV12@_N@Z) referenced in function "public: int __thiscall CStitchEngine::PanoramaStitch(void)" (?PanoramaStitch@CStitchEngine@@QAEHXZ) – Vinshi Dec 19 '12 at 20:50
  • @Vinshi you try to access static member (constructor) with wrong operator - `.` instead of `::`. Look at answer again and read carefully. – ArtemStorozhuk Dec 19 '12 at 21:03
  • Also, are you sure you've set everything up correct? I think you need to build the opencv source code and then add the lib files as linker inputs. Have you done that? Alternatively, this would probably be easier http://stackoverflow.com/questions/2985676/setting-up-opencv-and-lib-files – Tejas Sharma Dec 19 '12 at 21:08