- Create a custom MATLAB data type that wraps the FILE pointer.
- Allocate and return an instance of the custom data type from the 1st Mex function.
- Accept the custom data type as an input to the 2nd Mex function.
- Unwrap the custom data type in the 1st Mex function to obtain the FILE pointer.
Pass an open pipeline from C++ to Matlab
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi
I have created a Mex function that opens an FFMPEG streaming pipeline. I need this open pipeline to be passed as an input to a second Mex function which processes video frames and writes the output to the open pipeline. My ideal workflow is as follows:
Open the pipeline in the 1st Mex function. Pass this open pipeline back into Matlab. Create a While loop to process video frames and generate bounding boxes. Call a second Mex function within the loop which takes the open pipeline as input together with a frame and writes the output to an RTSP server.
The problem is that I currently can't pass the open pipeline from my first Mex function to a Matlab variable. The data type of the open pipeline is a File and the error I get is:
note: while trying to match the argument list '(matlab::data::Array, FILE *)'.
I use the c++ function _popen to open the pipeline and according to the documentation, _popen() returns a pointer to an open stream that can be used to read or write to the pipe.
Is there a way to somehow pass an open pipeline to a matlab variable?
댓글 수: 0
답변 (1개)
Harsh Sanghai
2023년 3월 23일
Hi,
It is not possible to pass an open pipeline (a FILE pointer) directly to a MATLAB variable using MATLAB's built-in data types. However, you can create a custom MATLAB data type that wraps the FILE pointer and pass that custom data type between the two MEX functions.
You can follow the steps mention below to obtain this:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!