0

I found a below program in c++ on internet,

#include <opencv2/opencv.hpp>
using namespace cv;

int main(void) {

    // Read image in GrayScale mode
    Mat image = imread("emily.jpg", 0);

    // Save grayscale image
    imwrite("emilyGray.jpg", image);

    // To display the image
    imshow("Grayscale Image", image);
    waitKey(0);

    return 0;
}

Then I compiled the above program with the following,

g++ opencv1.cpp -o opencv1.exe -IC:\\opencv\\build\\install\\include -LC:\\opencv\\build\\install\\x64\\mingw\\lib -lopencv_calib3d452 -lopencv_core452 -lopencv_highgui452 -lopencv_imgcodecs452

After running opencv1.exe, theres no change, no image being created.

Note:- I am using mingw for compiling and my opencv is built with mingw and cmake.

2
  • 1
    maybe imread cannot find the file? Commented Jul 1, 2021 at 9:15
  • the file is in same directory as where the program is executing. Commented Jul 1, 2021 at 9:19

1 Answer 1

1

Actually I did not set the path to opencv dlls after I built opencv using mingw32-make.

After setting C:\opencv\build\bin to PATH variable of environment variables I could see the output.

Regards

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.