问题
I am working on an image processing project in C++. To display the images I want to use the default ubuntu image viewer (eog). I have functions in my Image16 class which can read and write PPM files. I know these work because I can write them to the hard disk and then open them with eog. However I do not want to be writing the images to my hard disk because I have an SSD and each image is about 100 Mb. I want to directly pipe the image data into eog. This however is generating an error and I am not sure why.
ifstream in("/home/chase/Desktop/moon.ppm");
Image16 img = Image16::read_ppm(in);
in.close();
FILE* f = popen("eog /dev/stdin", "w");
img.write_ppm(f, 255);
pclose(f);
I managed to get it to work with imagemagick display and feh but I really don't like those programs. I want to use eog if possible.
来源:https://stackoverflow.com/questions/29731836/piping-ppm-image-to-eog-image-viewer-not-working