Ask Your Question

Revision history [back]

Okay, this code snippet works perfectly on my system - just tested it

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

using namespace cv;
using namespace std;

int main()
{
    Mat image, image_out;
    image=imread("/home/steven/Documents/test.jpg");
    cvtColor(image, image_out, CV_BGR2Lab);
    imshow("sohi",image_out); waitKey(0);
    return 0;
}

So I am guessing you are either in one of the following problems

  • You are linking against the wrong libraries or to no libraries at all in linker options
  • Your image is not in the directory you are building, try to use absolete paths and not relative ones like I did
  • You forgot to place a waitKey() after the imshow and by that, there is no resulting frame. This is quite normal since the waitKey() holds the window and gives it the chance to call its internal redraw function. An imshow always needs to be accompagnied by this. Giving it the value 0 will wait until a key is hit, else the time is in milliseconds.