Ask Your Question

Revision history [back]

Basic script to input / output img doesn't work

I compiled the script at the bottom, and ran it with

./a.out baboon.pgm

It ran without any errors, but nothing was output, whereas I expected a file named L2.pgm to be output. What am I doing wrong?

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

using namespace cv;

int main(int argc, char ** argv){
        if (argc != 1){
                return -1;
        }
        Mat image;
        image = imread(argv[1]);
        imwrite("/home/makes/practice/L2.pgm", image );
}