How can I read image data from stdin rather than from a file?
With the C++ interface, it seems to be possible: https://stackoverflow.com/a/5458035/908515. The function imdecode
is available in Python as well. But it expects a numpy array
as (first) argument. I have no idea how to convert the stdin data.
This is what I tried:
import cv
import sys
import numpy
stdin = sys.stdin.read()
im = cv.imdecode(numpy.asarray(stdin), 0)
Result: TypeError: <unknown> data type = 18 is not supported