2016-09-07 1 views
0

OpenCV를 처음 사용하고 Qt Creator에서 사용하고 있습니다. 이미지를 표시하고 싶습니다. 내 코드 :Qt의 OpenCV에 이미지가 표시되지 않습니다.

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

#include <iostream> 
#include <string> 

using namespace cv; 
using namespace std; 

int main() 
{ 
    Mat image=imread("C:/Users/richa/Desktop/IMG-20150324-WA0001.jpg",CV_LOAD_IMAGE_COLOR); // Read the file 


    if(image.empty())      // Check for invalid input 
    { 
     cout << "Could not open or find the image" << std::endl ; 
     return -1; 
    } 

    namedWindow("Image",WINDOW_AUTOSIZE); // Create a window for display. 
    imshow("Image", image);    // Show our image inside it. 

    waitKey(); // Wait for a keystroke in the window 
    return 0; 
} 

출력은 이미지가없는 콘솔 창입니다. 또한 프로그램은 -1073741511 코드로 종료됩니다. 이미지가 새 창에로드되지 않는 이유는 무엇입니까? 스크린 샷 : enter image description here

+0

문제는 당신이 외부 단자에서 프로그램을 실행하고 있는지 수 있습니다. 'Check Projects -> Run Settings -> Run in terminal'에서 QtCreator를 비활성화하도록 구성하십시오. – ikaro

답변

0

시도 :

int main() 
{ 
    Mat image=imread("C:/Users/richa/Desktop/IMG-20150324-WA0001.jpg",CV_LOAD_IMAGE_COLOR); // Read the file 


    if(image.empty())      // Check for invalid input 
    { 
     cout << "Could not open or find the image" << std::endl ; 
     return -1; 
    } 

    namedWindow("Image",WINDOW_AUTOSIZE); // Create a window for display. 

    for(;;)//infinite loop 
    { 
    imshow("Image", image);    // Show our image inside it. 

    char c=waitKey(10); // Wait for a keystroke in the window for 10ms, then move on 
    if(c=='b' || c=='B')//if b is pressed 
    break; 
    } 
    return 0; 
} 
관련 문제