2013-07-24 69 views
0

我想在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) 
+0

它在哪裏崩潰?還請將任何與「rgb」重新命名爲「bgr」。 –

+0

請把你的完整代碼,這樣我們也許我們可以修復它 – Khashayar

+0

@Khashayar請用簡單的代碼seemy新問題http://stackoverflow.com/questions/17851743/i-want-to-display-output-image- in-different-windows – user2567857

回答

1

你可能想

for(x = 0; x = 5;x++) 

可能進入到開始修復您的主循環

for(x = 0; x != 5; x++) 

事實上,它是一個無限循環

+0

我使用<=符號編輯了我的for循環,但在顯示第一張圖片後它仍然會崩潰。請參閱問題和代碼上的更新 – user2567857

+0

它會在哪條線上崩潰? –

+0

plase看到我更新的問題我已經顯示它顯示第一個圖像後顯示的錯誤 – user2567857

相關問題