MotionDetection Class
MotionDetection Class
Description
A class used to retrieve data when motion is detected by comparing the RGB information of each image frame captured from the on-board camera sensor (JXF37).
Syntax
Class MotionDetection
Members
Public Constructors | |
MotionDetection::MotionDetection | Constructs a MotionDetection object and set motion detection resolution. |
Public Methods | |
MotionDetection::configResolution | Configure motion detection grid resolution. |
MotionDetection::configVideo | Configure input video stream parameters. |
MotionDetection::begin | Start motion detection process on input video. |
MotionDetection::end | Stop motion detection process on input video. |
MotionDetection::setTriggerBlockCount | Set the number of blocks to trigger motion detection output. |
MotionDetection::setDetectionMask | Set a specific region in the video stream to enable motion detection. |
MotionDetection::getResult | Get motion detection results. |
MotionDetection::setResultCallback | Set a callback function to receive and display motion detection results. |
MotionDetection::rows | Get currently configured number of rows for motion detection grid. |
MotionDetection::cols | Get currently configured number of columns for motion detection grid. |
MotionDetection::MotionDetection
Description
Constructs a MotionDetection object and configure motion detection resolution.
Syntax
MotionDetection(uint8_t row, uint8_t col);
Parameters
row: Number of rows for motion detection grid resolution. Default value of 16. Maximum value of 32.
col: Number of columns for motion detection grid resolution. Default value of 16. Maximum value of 32.
Returns
NA
Example Code
Example: LoopPostProcessing
(https://github.com/ambiot/ambpro2_arduino/blob/dev/Arduino_package/hardware/libraries/Video/examples/MotionDetection/LoopPostProcessing/LoopPostProcessing.ino)
Notes and Warnings
“MotionDetection.h” must be included to use the class function.
MotionDetection::configResolution
Description
Configure motion detection resolution.
Syntax
void configResolution(uint8_t row, uint8_t col);
Parameters
row: Number of rows for motion detection grid resolution. Default value of 16. Maximum value of 32.
col: Number of columns for motion detection grid resolution. Default value of 16. Maximum value of 32.
Returns
NA
Example Code
NA
Notes and Warnings
“MotionDetection.h” must be included to use the class function.
MotionDetection::configVideo
Description
Configure input video stream parameters.
Syntax
void configVideo(VideoSetting& config);
Parameters
config: VideoSetting class object containing desired video configuration.
Returns
NA
Example Code
Example: LoopPostProcessing
(https://github.com/ambiot/ambpro2_arduino/blob/dev/Arduino_package/hardware/libraries/Video/examples/MotionDetection/LoopPostProcessing/LoopPostProcessing.ino)
Notes and Warnings
“MotionDetection.h” must be included to use the class function. For motion detection, the input video stream uses the RGB format, which is only available on video stream channel 3.
MotionDetection::begin
Description
Start motion detection process on input video.
Syntax
void begin(void);
Parameters
NA
Returns
NA
Example Code
Example: LoopPostProcessing
(https://github.com/ambiot/ambpro2_arduino/blob/dev/Arduino_package/hardware/libraries/Video/examples/MotionDetection/LoopPostProcessing/LoopPostProcessing.ino)
Notes and Warnings
“MotionDetection.h” must be included to use the class function.
MotionDetection::end
Description
Stop motion detection process on input video.
Syntax
void end(void);
Parameters
NA
Returns
NA
Example Code
NA
Notes and Warnings
“MotionDetection.h” must be included to use the class function.
MotionDetection::setTriggerBlockCount
Description
Set the number of blocks to trigger motion detection output.
Syntax
void setTriggerBlockCount(uint16_t count);
Parameters
count: Threshold number of blocks with motion.
Returns
NA
Example Code
NA
Notes and Warnings
“MotionDetection.h” must be included to use the class function.
MotionDetection::setDetectionMask
Description
Set a specific region in the motion detection grid to ignore motion.
Syntax
void setDetectionMask(char * mask);
Parameters
mask: a pointer to a char array containing the regions where motion detection is enabled or disabled. A value of 1 will enable motion detection for the grid region, a value of 0 will disable motion detection for the grid region.
Returns
NA
Example Code
NA
Notes and Warnings
“MotionDetection.h” must be included to use the class function.
MotionDetection::getResult
Description
Get motion detection results.
Syntax
char* getResult(void);
Parameters
NA
Returns
A pointer to a character array containing motion detection results. The array dimensions are identical to the configured motion detection grid resolution. A value of 1 indicates motion detected in the grid region.
Example Code
Example: LoopPostProcessing
(https://github.com/ambiot/ambpro2_arduino/blob/dev/Arduino_package/hardware/libraries/Video/examples/MotionDetection/LoopPostProcessing/LoopPostProcessing.ino)
Notes and Warnings
“MotionDetection.h” must be included to use the class function.
MotionDetection::setResultCallback
Description
Set a callback function to receive and display motion detection results.
Syntax
void setResultCallback(void (*md_callback)(char*));
Parameters
md_callback: A callback function that accepts a pointer to a character array as an argument and returns void. The character array contains the motion detection results. The array dimensions are identical to the configured motion detection grid resolution. A value of 1 indicates motion detected in the grid region.
Returns
NA
Example Code
Example: CallbackPostProcessing
(https://github.com/ambiot/ambpro2_arduino/blob/dev/Arduino_package/hardware/libraries/Video/examples/MotionDetection/CallbackPostProcessing/CallbackPostProcessing.ino)
Notes and Warnings
“MotionDetection.h” must be included to use the class function.
MotionDetection::rows
Description
Get currently configured number of rows for motion detection grid.
Syntax
uint8_t rows(void);
Parameters
NA
Returns
The number of rows in the motion detection grid, expressed as an unsigned integer.
Example Code
NA
Notes and Warnings
“MotionDetection.h” must be included to use the class function.
MotionDetection::cols
Description
Get currently configured number of columns for motion detection grid.
Syntax
uint8_t cols(void);
Parameters
NA
Returns
The number of cols in the motion detection grid, expressed as an unsigned integer.
Example Code
NA
Notes and Warnings
“MotionDetection.h” must be included to use the class function.