GPU Accelerated Motion Detector/Examples/Library Usage: Difference between revisions

Line 119: Line 119:


== Process Frames ==
== Process Frames ==
Once parameters, algorithms and frames are defined we can start processing. In order to do it we need to get and provide the frames that will be consumed by the library. To do this we have several options:
=== Create a Frame and fill it with your data ===
<syntaxhighlight lanng=c++>
std::shared_ptr<rr::Frame> input = factory->getFrame(rr::Resolution(WIDTH, HEIGHT), rr::Format::FORMAT_RGBA);
/*Get data pointer. It is an array with a pointer for each plane of the video format*/
std::vector<void*> data = input->getData();
/*Fill data*/
</syntaxhighlight>
===use one of the provided wrappers around different data types===
For easier usage, we provide wrappers around common data types. The available are:
* '''GstFrame''': Wrapper around a GstVideoFrame.
<syntaxhighlight lanng=c++>
GstVideoFrame videoframe;
std::shared_ptr<rr::Frame> input = std::make_shared<rr::GSTFrame>(&videoframe);
</syntaxhighlight>
* '''GSTCudaDataFrame''': Wrapper around a GstCudaData from [https://developer.ridgerun.com/wiki/index.php/GstCUDA GstCuda]
<syntaxhighlight lanng=c++>
GstCudaData data;
std::shared_ptr<rr::Frame> input = std::make_shared<rr::GSTCudaDataFrame>(&data);
</syntaxhighlight>
*'''CVFrame''': Wrapper around OpenCV Mat object
<syntaxhighlight lanng=c++>
cv::Mat matrix;
std::shared_ptr<rr::Frame> input = std::make_shared<rr::CVFrame>(matrix);
</syntaxhighlight>
*'''GpuMatFrame''': Wrapper around OpenCV GpuMat object
<syntaxhighlight lanng=c++>
cv::cuda::CpuMat matrix;
std::shared_ptr<rr::Frame> input = std::make_shared<rr::GpuMatFrame>(matrix);
</syntaxhighlight>


<noinclude>
<noinclude>
{{GPU Accelerated Motion Detector/Foot|Examples|Examples/GStreamer_Pipelines}}
{{GPU Accelerated Motion Detector/Foot|Examples|Examples/GStreamer_Pipelines}}
</noinclude>
</noinclude>