Write out mat to stream / print to screen

asked 2014-08-18 16:28:39 -0600

VladTheImpala gravatar image

updated 2014-08-19 14:55:04 -0600

I have a mat, and I can save it to the filesystem with something like:

cv.SaveImage("/tmp/out.png", mat)

But I'm using opencv with a web server, and I want to write out the image data directly to the client. The equivalent would be writing out the image data to stdout. Is there a way to do this?

edit retag flag offensive close merge delete

Comments

1
  • don't use the arcane cv api(it will be gone soon), but cv2.
  • you don't want to send the pixels only, but a real image, like a png , so please look at imencode and print the outcome of that to stdout
berak gravatar imageberak ( 2014-08-18 16:35:05 -0600 )edit

That did it, thanks! I should've specified: I'm not using python, I am using luacv. It provides lua bindings and uses opencv v2.

VladTheImpala gravatar imageVladTheImpala ( 2014-08-19 14:54:43 -0600 )edit

interesting ;)

still, using outdated c-api stuff only. (that's sad.)

do you think, it's actively maintained ? last entries on sourceforge repo seem to be from 2012

berak gravatar imageberak ( 2014-08-19 15:13:01 -0600 )edit

Not actively maintained for sure. But I need to use opencv from nginx, and lua runs in nginx, so I needed lua bindings.

VladTheImpala gravatar imageVladTheImpala ( 2014-08-19 16:58:56 -0600 )edit