zeigen Sie mehrere Bilder in einzelne Fenster OPENCV

Ich fand diesen code im internet, und es scheint, es funktioniert gut mit anderen. Aber ich bekomme immer so etwas wie dieses:
Nicht behandelte Ausnahme bei 0x012c1073 in examplexx.exe: 0xC0000005: Zugriffsverletzung beim Lesen der Position 0x00000028.

Haben jemand Ahnung, was könnte ein problem sein?

#include <opencv2/imgproc/imgproc.hpp>  
#include <opencv2/core/core.hpp>        
#include <opencv2/highgui/highgui.hpp>
#include <iostream>


using namespace cv;
using namespace std;

int main()
{
//Image Reading
IplImage* img1 = cvLoadImage( "ball.jpg" );
IplImage* img2 = cvLoadImage( "ball.jpg" );
IplImage* img3 = cvLoadImage( "ball.jpg" );
IplImage* img4 = cvLoadImage( "ball.jpg" );

int dstWidth=img1->width+img1->width;
int dstHeight=img1->height+img1->height;

IplImage* dst=cvCreateImage(cvSize(dstWidth,dstHeight),IPL_DEPTH_8U,3); 

//Copy first image to dst
cvSetImageROI(dst, cvRect(0, 0,img1->width,img1->height) );
cvCopy(img1,dst,NULL);
cvResetImageROI(dst);

//Copy second image to dst
cvSetImageROI(dst, cvRect(img2->width, 0,img2->width,img2->height) );
cvCopy(img2,dst,NULL);
cvResetImageROI(dst);

//Copy third image to dst
cvSetImageROI(dst, cvRect(0, img3->height,img3->width,img3->height) );
cvCopy(img3,dst,NULL);
cvResetImageROI(dst);

//Copy fourth image to dst
cvSetImageROI(dst, cvRect(img4->width, img4->height,img4->width,img4->height));
cvCopy(img4,dst,NULL);
cvResetImageROI(dst);

//show all in a single window
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", dst );
cvWaitKey(0);

}
  • "Ich fand diesen code im internet," - sorry, aber das ist viel zu alt, um nutzbar zu sein. bitte verwenden opencv c++ - api, nicht die veralteten c
InformationsquelleAutor Broom Broom | 2015-02-15
Schreibe einen Kommentar