Constructor
new VideoMotion()
Members
_arrays :number
A buffer for holding one component of a pixel's full value twice. One for the current value. And one for the last value.
Type:
- number
_curr :number
A clamped uint8 view of _arrays. One component of each index of the curr member is copied into this array.
Type:
- number
_prev :number
A clamped uint8 view of _arrays. One component of each index of the prev member is copied into this array.
Type:
- number
curr :Uint32Array
A copy of the current frame's pixel values. A index of the array is represented in RGBA. The lowest byte is red. The next is green. The next is blue. And the last is the alpha value of that pixel.
Type:
- Uint32Array
frameNumber :number
The number of frames that have been added from a source.
Type:
- number
lastAnalyzedFrame :number
The frameNumber last analyzed.
Type:
- number
motionAmount :number
The amount of motion detected in the current frame.
Type:
- number
motionDirection :number
The direction the motion detected in the frame is general moving in.
Type:
- number
prev :Uint32Array
A copy of the last frame's pixel values.
Type:
- Uint32Array
Methods
addFrame(source)
Add a frame to be next analyzed. The passed array represent a pixel with each index in the RGBA format.
Parameters:
Name | Type | Description |
---|---|---|
source |
Uint32Array | a source frame of pixels to copy |
analyzeFrame()
Analyze the current frame against the previous frame determining the amount of motion and direction of the motion.
getLocalMotion(drawable, state)
Build motion amount and direction values based on stored current and previous frame that overlaps a given drawable.
Parameters:
Name | Type | Description |
---|---|---|
drawable |
Drawable | touchable and bounded drawable to build motion for |
state |
MotionState | state to store built values to |
reset()
Reset internal state so future frame analysis does not consider values from before this method was called.