Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

problem using GraphCut algorithem

I have this code:

Mat image0=imread("C:\\Working Dir\\Tests\\TestBlending\\image0.jpg");
Mat image1=imread("C:\\Working Dir\\Tests\\TestBlending\\image1.jpg");

// our corners are just at (0,0)
cv::Point corner1;
corner1.x = 0;
corner1.y = 0;

cv::Point corner2;
corner2.x = 0;
corner2.y = 0;

std::vector<cv::Point> corners;

corners.push_back(corner1);
corners.push_back(corner2);

std::vector<cv::Mat> masks;
Mat imageMask0;
Mat imageMask1;
masks.push_back(imageMask0);
masks.push_back(imageMask1);

std::vector<cv::Mat> sources;

sources.push_back(image0);
sources.push_back(image1);

cv::detail::GraphCutSeamFinder *seam_finder = new cv::detail::GraphCutSeamFinder();
seam_finder->find(sources, corners, masks);

printf("%lu\n", masks.size());
for(int i = 0; i < masks.size(); i++)
{
    std::cout << "MASK = "<< std::endl << " "  << masks.at(i) << std::endl << std::endl;
}

return 0;

When I ran this code, I am getting this error:

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si

ze.p[0] && (unsigned)(i1DataType<_Tp>::channels) < (unsigned)(size.p[1]channel s()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3 ) - 1))*4) & 15) == elemSize1()) in unknown function, file C:\slave\builds\WinIn stallerMegaPack\src\opencv\modules\core\include\opencv2/core/mat.hpp, line 537

I am using OpenCV 2.4.6 (C++ on visual studio 2012)

What is wrong with this code that generate this error?

Is there any sampole code to show how to use GraphCut to find seam line between two image before blending?

problem using GraphCut algorithem

I have this code:

Mat image0=imread("C:\\Working Dir\\Tests\\TestBlending\\image0.jpg");
Mat image1=imread("C:\\Working Dir\\Tests\\TestBlending\\image1.jpg");

// our corners are just at (0,0)
cv::Point corner1;
corner1.x = 0;
corner1.y = 0;

cv::Point corner2;
corner2.x = 0;
corner2.y = 0;

std::vector<cv::Point> corners;

corners.push_back(corner1);
corners.push_back(corner2);

std::vector<cv::Mat> masks;
Mat imageMask0;
Mat imageMask1;
masks.push_back(imageMask0);
masks.push_back(imageMask1);

std::vector<cv::Mat> sources;

sources.push_back(image0);
sources.push_back(image1);

cv::detail::GraphCutSeamFinder *seam_finder = new cv::detail::GraphCutSeamFinder();
seam_finder->find(sources, corners, masks);

printf("%lu\n", masks.size());
for(int i = 0; i < masks.size(); i++)
{
    std::cout << "MASK = "<< std::endl << " "  << masks.at(i) << std::endl << std::endl;
}

return 0;

When I ran this code, I am getting this error:

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si

ze.p[0] && (unsigned)(i1DataType<_Tp>::channels) (unsigned)size.p[0] && (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]channel s()) (unsigned)(size.p[1]*channels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3 ) 3) - 1))*4) & 15) == elemSize1()) in unknown function, file C:\slave\builds\WinIn stallerMegaPack\src\opencv\modules\core\include\opencv2/core/mat.hpp, C:\slave\builds\WinInstallerMegaPack\src\opencv\modules\core\include\opencv2/core/mat.hpp, line 537

537

I am using OpenCV 2.4.6 (C++ on visual studio 2012)

What is wrong with this code that generate this error?

Is there any sampole code to show how to use GraphCut to find seam line between two image before blending?

problem using GraphCut algorithem

I have this code:

int main()
{    
     Mat image0=imread("C:\\Working Dir\\Tests\\TestBlending\\image0.jpg");
 Mat image1=imread("C:\\Working Dir\\Tests\\TestBlending\\image1.jpg");

 // our corners are just at (0,0)
 cv::Point corner1;
 corner1.x = 0;
 corner1.y = 0;

 cv::Point corner2;
 corner2.x = 0;
 corner2.y = 0;

 std::vector<cv::Point> corners;

 corners.push_back(corner1);
 corners.push_back(corner2);

 std::vector<cv::Mat> masks;
 Mat imageMask0;
 Mat imageMask1;
 masks.push_back(imageMask0);
 masks.push_back(imageMask1);

 std::vector<cv::Mat> sources;

 sources.push_back(image0);
 sources.push_back(image1);

 cv::detail::GraphCutSeamFinder *seam_finder = new cv::detail::GraphCutSeamFinder();
 seam_finder->find(sources, corners, masks);

 printf("%lu\n", masks.size());
 for(int i = 0; i < masks.size(); i++)
 {
     std::cout << "MASK = "<< std::endl << " "  << masks.at(i) << std::endl << std::endl;
 }

 return 0;
}

When I ran this code, I am getting this error:

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] && (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in unknown function, file C:\slave\builds\WinInstallerMegaPack\src\opencv\modules\core\include\opencv2/core/mat.hpp, line 537

stack at the place that it fails is:

    [Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]    
TestApplication.exe!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 152  C++

TestApplication.exe!cv::error(class cv::Exception const &)  Unknown

TestApplication.exe!cv::Mat::at<class cv::Point3_<float> >(int,int) Unknown

TestApplication.exe!cv::detail::GraphCutSeamFinder::Impl::findInPair(unsigned int,unsigned int,class cv::Rect_<int>)    Unknown

TestApplication.exe!cv::detail::PairwiseSeamFinder::run(void)   Unknown

TestApplication.exe!cv::detail::PairwiseSeamFinder::find(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > const &,class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > const &,class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &)  Unknown

TestApplication.exe!cv::detail::GraphCutSeamFinder::Impl::find(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > const &,class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > const &,class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &)    Unknown

TestApplication.exe!cv::detail::GraphCutSeamFinder::find(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > const &,class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > const &,class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &)  Unknown

TestApplication.exe!main(int argc, char * * argv) Line 58   C++

I am using OpenCV 2.4.6 (C++ on visual studio 2012)

What is wrong with this code that generate this error?

Is there any sampole code to show how to use GraphCut to find seam line between two image before blending?

problem using GraphCut algorithem

I have this code:

int main()
{    
     Mat image0=imread("C:\\Working Dir\\Tests\\TestBlending\\image0.jpg");
     Mat image1=imread("C:\\Working Dir\\Tests\\TestBlending\\image1.jpg");

     // our corners are just at (0,0)
     cv::Point corner1;
     corner1.x = 0;
     corner1.y = 0;

     cv::Point corner2;
     corner2.x = 0;
     corner2.y = 0;

     std::vector<cv::Point> corners;

     corners.push_back(corner1);
     corners.push_back(corner2);

     std::vector<cv::Mat> masks;
     Mat imageMask0;
     Mat imageMask1;
     masks.push_back(imageMask0);
     masks.push_back(imageMask1);

     std::vector<cv::Mat> sources;

     sources.push_back(image0);
     sources.push_back(image1);

     cv::detail::GraphCutSeamFinder *seam_finder = new cv::detail::GraphCutSeamFinder();
     seam_finder->find(sources, corners, masks);

     printf("%lu\n", masks.size());
     for(int i = 0; i < masks.size(); i++)
     {
          std::cout << "MASK = "<< std::endl << " "  << masks.at(i) << std::endl << std::endl;
      }

      return 0;
}

When I ran this code, I am getting this error:

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] && (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in unknown function, file C:\slave\builds\WinInstallerMegaPack\src\opencv\modules\core\include\opencv2/core/mat.hpp, line 537

stack at the place that it fails is:

    [Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]    
TestApplication.exe!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 152  C++

TestApplication.exe!cv::error(class cv::Exception const &)  Unknown

TestApplication.exe!cv::Mat::at<class cv::Point3_<float> >(int,int) Unknown

TestApplication.exe!cv::detail::GraphCutSeamFinder::Impl::findInPair(unsigned int,unsigned int,class cv::Rect_<int>)    Unknown

TestApplication.exe!cv::detail::PairwiseSeamFinder::run(void)   Unknown

TestApplication.exe!cv::detail::PairwiseSeamFinder::find(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > const &,class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > const &,class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &)  Unknown

TestApplication.exe!cv::detail::GraphCutSeamFinder::Impl::find(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > const &,class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > const &,class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &)    Unknown

TestApplication.exe!cv::detail::GraphCutSeamFinder::find(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > const &,class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > const &,class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &)  Unknown

TestApplication.exe!main(int argc, char * * argv) Line 58   C++

I am using OpenCV 2.4.6 (C++ on visual studio 2012)

What is wrong with this code that generate this error?

Is there any sampole code to show how to use GraphCut to find seam line between two image before blending?

edit1

I did some digging and found that the problem is in this line:

   subimg1.at<Point3f>(y + gap, x + gap) = img1.at<Point3f>(y1, x1);

This is in seam_finders.cpp line 1241.

The problem is that image 1 is not in a float format and hence img1.at<point3f>(y1, x1); generate error.

I tried to convert image to a float which fixed the problem but also clear all data from my images.

so my code at the moment is:

Mat image0=imread("C:\\Working Dir\\Tests\\TestBlending\\layer0000.jpg");
Mat image1=imread("C:\\Working Dir\\Tests\\TestBlending\\layer0001.jpg");

image0.convertTo(image0,CV_32FC3);
image1.convertTo(image1,CV_32FC3);

I can see that images are loaded correctly but after convertto they are both empty (values are zero).

How can I fix this problem?