How to use imshow when png is loaded in memory
My program receives PNG buffers from TCP connection. I have an unsigned character pointer to the PNG file. I want to show the PNG image with imshow as they are received (i.e. sort of a video stream of PNG images).
So far I am not able to achieve this since imshow wants a cv::mat and I don't know how to convert from uchar * (png raw file data) to cv::mat.
Thank you.
You have to wrap the raw data into a Mat first. Maybe is better if you compile OpenCV with FFMPEG enabled so you can "directly" handle TCP connection as far as I know. By the way, VideoCapture class also let you get video stream from an IP, maybe you can try to feed that class directly with your TCP socket.
I never faced this situation, to be honest when I have to deal with real time streming I prefere to use ROS.
Edit: @berak gave to you the simplest way to solve it :-)
Also checkout the answer here https://stackoverflow.com/questions/2...