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
my_program < example.jpeg. Actually, I'm getting the data from a webcam with another program and I want to avoid creating temporary files.