我想将图像写入stdout。但是我找不到如何使cv2.imwrite()
支持它。有没有办法将图像写入stdout?
cv2.imwrite(sys.stdout, x)
TypeError: expected string or Unicode object, file found
cv2.imwrite('/dev/stdout', x)
cv2.error: OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgcodecs/src/loadsave.cpp:662: error: (-2:Unspecified error) could not find a writer for the specified extension in function 'imwrite_'
答案 0 :(得分:0)
类似的事情可以解决问题。
print cv2.imencode('.jpg', img)[1].tostring()