Reading image in c++ using opencv

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Reading image in c++ using opencv

Davi
This post has NOT been accepted by the mailing list yet.
I'm trying to read image using opencv libraries with C++ and getting this error.

init done
opengl support available
QXcbShmImage: shmget() failed (22) for size 40449024 (2736x3696)

The doesn't wait, Can you please help me to solve the problem.

Here is the code-

//header files
#include "opencv2/highgui/highgui.hpp"
#include<iostream>

using namespace cv;
using namespace std;

int main(int argc, const char** argv)
{
        Mat img = imread("a.JPG", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "a.JPG" and store it in 'img'

        if(img.empty()) //check whether the image is loaded or not
        {
                cout<<"Error:Image cannot be loaded..!!"<<endl;
                //system("pause");   //wait for a key press
                return -1;
        }

        namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);  //create a window with name "MyWindow"

        imshow("MyWindow", img);   //display the image which is stored in the 'img' in the "MyWindow" window

        waitKey(3000);   //wait infinite time for a keypress
        destroyWindow("MyWindow");  //destroy the window with the name, "MyWindow"

        return 0;
}


Reply | Threaded
Open this post in threaded view
|

Re: Reading image in c++ using opencv

keghn
 The program worked fine.
 The only way i could make it fail, was have upper/lower case letter mismatch a.JPG is no the same as a.jpg.
 I used OpenCV 3.0, on Mint 17.1, Linux, 64 bit OS
 
DIL
Reply | Threaded
Open this post in threaded view
|

Re: Reading image in c++ using opencv

DIL
This post has NOT been accepted by the mailing list yet.
In reply to this post by Davi
Try resize the image, same change resolved this error at my end

Size sz(720, 540);
resize(img, img, sz);