我想在OpenCV中使用C API分別在不同窗口中顯示多個圖像。以下是我的代碼,我已經做了一個for循環,多次顯示相同的圖像,直到循環旋轉。任何人都可以告訴我爲什麼我的代碼在顯示第一個圖像後崩潰了嗎?以下是我對循環代碼:在OpenCV的不同窗口中顯示多個圖像
for(x = 0; x <= 5;x++)
{
IplImage* dst = cvCreateImage(cvSize(src->width, src->height), src->depth, 3);
IplImage* dstRGB[3];
for (int i = 0; i < 3; i++)
{
rgb[i] = cvCreateImage(cvSize(src->width, src->height), src->depth, 1);
dstRGB[i] = cvCreateImage(cvSize(src->width, src->height), src->depth, 1);
}
cvSplit(src, rgb[0], rgb[1], rgb[2], NULL);
for (int i = 0; i < 3; i++)
{
cvFilter2D(rgb[i], dstRGB[i], rgb2);
}
cvReleaseMat(&rgb2);
cvMerge(dstRGB[0], dstRGB[1], dstRGB[2], NULL, dst);
cvNamedWindow("dst", 1);
cvShowImage("dst", dst);
//cvSaveImage("output.png", dst);
cvReleaseImage(&dst);
for (int i = 0; i < 3; i++)
{
cvReleaseImage(&rgb[i]);
cvReleaseImage(&dstRGB[i]);
}
cvWaitKey(0);
} // for loop ends
cvReleaseImage(&src);
cvDestroyWindow(argv[5]);
cvDestroyWindow("dst");
以下是它顯示顯示第一圖像後錯誤
OpenCV Error: Assertion failed (anchor.inside(Rect(0, 0, ksize.width, ksize.height))) in normalizeAnchor, file /home/Documents/opencv-2.4.5/release/modules/imgproc/precomp.hpp, line 90 terminate called after throwing an instance of 'cv::Exception' what(): /home/ocuments/opencv-2.4.5/release/modules/imgproc/precomp.hpp:90: error: (-215) anchor.inside(Rect(0, 0, ksize.width, ksize.height)) in function normalizeAnchor Aborted (core dumped)
它在哪裏崩潰?還請將任何與「rgb」重新命名爲「bgr」。 –
請把你的完整代碼,這樣我們也許我們可以修復它 – Khashayar
@Khashayar請用簡單的代碼seemy新問題http://stackoverflow.com/questions/17851743/i-want-to-display-output-image- in-different-windows – user2567857