Has anyone worked with capturing video streams from IP cameras in MATLAB? For example to grab frames in MATLAB from rtsp://10.10.10.10:554/live.sdp (rtsp stream) or from -cgi/mjpg/video.cgi (mjpeg stream). MATLAB's Image Acquisition Toolbox does not currently support this. I found 2 options:1) using mmread. However http stream reading is not supported under 64-bit MATLAB or 2) to write my own C++ function that grabs frames (I use OpenCV library) and then compile it into MATLAB MEX function.Any suggestions are appreciated.
Unfortunately, you are correct that currently the Image Acquisition Toolbox does not support IP cameras. Regarding workarounds: 1. If mmread works for you, perhaps it is feasible for you to install a 32-bit MATLAB on your 64-bit machine. 2. Writing your own MEX driver should be a possible option. 3. IMREAD is able to obtain frames from IP cameras. It may be possible to utilize this capability and build a function that constructs the video stream. Although frame rate may be an issue.
Below is a link to collection and development kit of matlab mex functions for OpenCV library (thanks to Kota Yamaguchi): This library makes it easy to convert between OpenCV data types and mxArray. Here's an example:
The application can be made asynchronous by using threads, where producer thread grabs frames from the camera and puts it into a circular buffer. Consumer thread, on the other hand, retrieves frames from the buffer and converts them into mxArray (matrix) output. See How to implement a circular buffer of cv::Mat objects (OpenCV)?. Circular buffer will need to be made thread safe, see Thread safe implementation of circular buffer.
c80f0f1006