vermaneerajin / leptonica

Automatically exported from code.google.com/p/leptonica
0 stars 0 forks source link

Feature requests: implement read from memory for windows #77

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I need to read image file from stdin. I created test case stdin2pix.cpp. It 
works ok on linux ('cat test.png | ./stdin2pix'), but I got error messages when 
I run in on windows (mingw32 or VC++ 2008):

Error in pixReadMemPng: png read from memory not implemented on this platform.

Interesting is that it works for tif, but not for there formats: pnm, png, 
jpeg, bmp, gif...

I think multiplatform library should provide same features on all platforms.

Original issue reported on code.google.com by zde...@gmail.com on 8 Mar 2013 at 5:34

Attachments:

GoogleCodeExporter commented 8 years ago
The problem on windows and osx is that they do not include a function similar 
to fmemopen() in the gnu runtime library, which allows you to read from memory 
AS IF you were reading from a file stream.

If you look at environ.h, you'll see a discussion of this, where HAVE_FMEMOPEN 
is manually set.  (If you build using configure, this will be set to 0 in 
config_auto.h)

It's not entirely satisfactory, but you can work around this by writing your 
image data to file and reading from there.

Original comment by dan.bloo...@gmail.com on 8 Mar 2013 at 9:24

GoogleCodeExporter commented 8 years ago
Unfortunately user try to avoid save to disk. He want to run something like 
this (with tesseract):

wget http://mi_server/image.jpg -q0- | tessaract --stdin --stdout | grep 
$(important)

I would prefer if workaround is done by leptonica, so leptonica user should not 
care about platform differences.

BTW: there is fmemopen for Mac OS and iOS(Apache 2.0 License)
https://github.com/jverkoey/fmemopen

open_memstream (Apache 2.0 License):
http://mirror.yongbok.net/pub/linux/android/repository/system/core/libcutils/ope
n_memstream.c

I also find implementations of fmemopen for win32 (licenced under GPL2):

http://fossies.org/unix/misc/suricata-1.4.1.tar.gz:a/suricata-1.4.1/src/util-fme
mopen.c
http://ejudge.ru/trac/browser/trunk/ejudge/win32/fmemopen.c

so I hope there could be better solution for windows and Mac than saving data 
to file.

Original comment by zde...@gmail.com on 10 Mar 2013 at 3:36