Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you're using the outdated c-api headers, which only contain deprecated functionality. instead use:

#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"

or the all-in-one umbrella header:

#include "opencv2/opencv.hpp"

you're using the outdated c-api headers, which only contain deprecated functionality.

instead (since you still use the outdated 2.4 version) use:

#include "opencv2/imgcodecs.hpp"
"opencv2/core/core.hpp"
#include "opencv2/highgui.hpp"
"opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"

or the all-in-one umbrella header:also please avoid any c-api functions:

#include "opencv2/opencv.hpp"
using namespace cv;
int main()
{
    Mat img = imread("C:\\opencv2_4_13\\sources\\samples\\data\\fruits.jpg");
    Mat img1;
    cvtColor(img, img1, COLOR_BGR2GRAY);
    imshow("ex", img1);
    waitKey(0);
    return 0;
}

you're using the outdated c-api headers, which only contain deprecated functionality.

instead (since you still use the outdated 2.4 version) use:

#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"

also please avoid using any c-api functions:

using namespace cv;
int main()
{
    Mat img = imread("C:\\opencv2_4_13\\sources\\samples\\data\\fruits.jpg");
    Mat img1;
    cvtColor(img, img1, COLOR_BGR2GRAY);
    imshow("ex", img1);
    waitKey(0);
    return 0;
}

you're using the outdated c-api headers, which only contain deprecated functionality.

instead (since you still use the outdated 2.4 version) use:

#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"

also please avoid using any c-api functions:

using namespace cv;
int main()
{
    Mat img = imread("C:\\opencv2_4_13\\sources\\samples\\data\\fruits.jpg");
    if (img.empty()) 
    {
          // add a warning msg, if nessecary
          return -1;
    }
    Mat img1;
    cvtColor(img, img1, COLOR_BGR2GRAY);
    imshow("ex", img1);
    waitKey(0);
    return 0;
}