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

Line 120: Line 120:
== 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:
Once everything is setup, we can start processing frames as follows:
 
<syntaxhighlight lanng=c++>
#define CHECK_RET_VALUE(ret)      \
  if (ret.IsError()) {            \
    std::cout << ret << std::endl; \
    break;                        \
  }
 
while(true) {
    /*Get input data using one of the provided ways*/
 
    /*Apply algorithms*/
    CHECK_RET_VALUE(motion_detection->apply(input, mask, motion_params))
    CHECK_RET_VALUE(denoise->apply(mask, filtered, denoise_params))
    CHECK_RET_VALUE(blob->apply(filtered, motion_list, blob_params))
   
    /*Check for motion*/
    if (motion_list.size() != 0) {
        /*Do something with motion objects*/
    }
}
</syntaxhighlight>
 
In order to feed the algorithms with the input data the library provides wrapper classes around commonly used data types that are described in the following sections.


=== Create a Frame and fill it with your data ===
=== Create a Frame and fill it with your data ===