问题描述
我正在使用C ++进行图像处理项目.要显示图像,我想使用默认的ubuntu图像查看器(eog).我的Image16类中有一些函数,可以读取和写入PPM文件.我知道这些工作是因为我可以将它们写入硬盘,然后使用eog打开它们.但是,我不想将映像写入硬盘,因为我有一个SSD,每个映像大约100 Mb.我想直接将图像数据传递到eog.但是,这产生了一个错误,我不确定为什么.
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);
我设法使其与imagemagick显示器和feh一起使用,但是我真的不喜欢那些程序.如果可能的话,我想使用eog.
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.
推荐答案
如果您真的坚持使用eog,则可以将其包装.例如,粗略的bash函数
If you really insist on eog, you can wrap it. For example, a crude bash function
$ eog- () { cat >/tmp/img && [ -s /tmp/img ] && eog "$@" /tmp/img; }
$ pngtopnm test.png | eog-
这篇关于将ppm图像管道传输到eog图像查看器不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!