public class opencv_optflow extends opencv_optflow
Constructor and Description |
---|
opencv_optflow() |
Modifier and Type | Method and Description |
---|---|
static double |
calcGlobalOrientation(GpuMat orientation,
GpuMat mask,
GpuMat mhi,
double timestamp,
double duration) |
static double |
calcGlobalOrientation(Mat orientation,
Mat mask,
Mat mhi,
double timestamp,
double duration)
\brief Calculates a global motion orientation in a selected region.
|
static double |
calcGlobalOrientation(UMat orientation,
UMat mask,
UMat mhi,
double timestamp,
double duration) |
static void |
calcMotionGradient(GpuMat mhi,
GpuMat mask,
GpuMat orientation,
double delta1,
double delta2) |
static void |
calcMotionGradient(GpuMat mhi,
GpuMat mask,
GpuMat orientation,
double delta1,
double delta2,
int apertureSize) |
static void |
calcMotionGradient(Mat mhi,
Mat mask,
Mat orientation,
double delta1,
double delta2) |
static void |
calcMotionGradient(Mat mhi,
Mat mask,
Mat orientation,
double delta1,
double delta2,
int apertureSize)
\brief Calculates a gradient orientation of a motion history image.
|
static void |
calcMotionGradient(UMat mhi,
UMat mask,
UMat orientation,
double delta1,
double delta2) |
static void |
calcMotionGradient(UMat mhi,
UMat mask,
UMat orientation,
double delta1,
double delta2,
int apertureSize) |
static void |
calcOpticalFlowSF(GpuMat from,
GpuMat to,
GpuMat flow,
int layers,
int averaging_block_size,
int max_flow) |
static void |
calcOpticalFlowSF(GpuMat from,
GpuMat to,
GpuMat flow,
int layers,
int averaging_block_size,
int max_flow,
double sigma_dist,
double sigma_color,
int postprocess_window,
double sigma_dist_fix,
double sigma_color_fix,
double occ_thr,
int upscale_averaging_radius,
double upscale_sigma_dist,
double upscale_sigma_color,
double speed_up_thr) |
static void |
calcOpticalFlowSF(Mat from,
Mat to,
Mat flow,
int layers,
int averaging_block_size,
int max_flow)
\addtogroup optflow
\{
|
static void |
calcOpticalFlowSF(Mat from,
Mat to,
Mat flow,
int layers,
int averaging_block_size,
int max_flow,
double sigma_dist,
double sigma_color,
int postprocess_window,
double sigma_dist_fix,
double sigma_color_fix,
double occ_thr,
int upscale_averaging_radius,
double upscale_sigma_dist,
double upscale_sigma_color,
double speed_up_thr)
\brief Calculate an optical flow using "SimpleFlow" algorithm.
|
static void |
calcOpticalFlowSF(UMat from,
UMat to,
UMat flow,
int layers,
int averaging_block_size,
int max_flow) |
static void |
calcOpticalFlowSF(UMat from,
UMat to,
UMat flow,
int layers,
int averaging_block_size,
int max_flow,
double sigma_dist,
double sigma_color,
int postprocess_window,
double sigma_dist_fix,
double sigma_color_fix,
double occ_thr,
int upscale_averaging_radius,
double upscale_sigma_dist,
double upscale_sigma_color,
double speed_up_thr) |
static void |
calcOpticalFlowSparseToDense(GpuMat from,
GpuMat to,
GpuMat flow) |
static void |
calcOpticalFlowSparseToDense(GpuMat from,
GpuMat to,
GpuMat flow,
int grid_step,
int k,
float sigma,
boolean use_post_proc,
float fgs_lambda,
float fgs_sigma) |
static void |
calcOpticalFlowSparseToDense(Mat from,
Mat to,
Mat flow) |
static void |
calcOpticalFlowSparseToDense(Mat from,
Mat to,
Mat flow,
int grid_step,
int k,
float sigma,
boolean use_post_proc,
float fgs_lambda,
float fgs_sigma)
\brief Fast dense optical flow based on PyrLK sparse matches interpolation.
|
static void |
calcOpticalFlowSparseToDense(UMat from,
UMat to,
UMat flow) |
static void |
calcOpticalFlowSparseToDense(UMat from,
UMat to,
UMat flow,
int grid_step,
int k,
float sigma,
boolean use_post_proc,
float fgs_lambda,
float fgs_sigma) |
static DenseOpticalFlow |
createOptFlow_DeepFlow()
\brief DeepFlow optical flow algorithm implementation.
|
static DualTVL1OpticalFlow |
createOptFlow_DualTVL1()
\brief Creates instance of cv::DenseOpticalFlow
|
static DenseOpticalFlow |
createOptFlow_Farneback()
Additional interface to the Farneback's algorithm - calcOpticalFlowFarneback()
|
static DenseOpticalFlow |
createOptFlow_SimpleFlow()
Additional interface to the SimpleFlow algorithm - calcOpticalFlowSF()
|
static DenseOpticalFlow |
createOptFlow_SparseToDense()
Additional interface to the SparseToDenseFlow algorithm - calcOpticalFlowSparseToDense()
|
static void |
segmentMotion(GpuMat mhi,
GpuMat segmask,
RectVector boundingRects,
double timestamp,
double segThresh) |
static void |
segmentMotion(Mat mhi,
Mat segmask,
RectVector boundingRects,
double timestamp,
double segThresh)
\brief Splits a motion history image into a few parts corresponding to separate independent motions (for
example, left hand, right hand).
|
static void |
segmentMotion(UMat mhi,
UMat segmask,
RectVector boundingRects,
double timestamp,
double segThresh) |
static void |
updateMotionHistory(GpuMat silhouette,
GpuMat mhi,
double timestamp,
double duration) |
static void |
updateMotionHistory(Mat silhouette,
Mat mhi,
double timestamp,
double duration)
\addtogroup optflow
\{
|
static void |
updateMotionHistory(UMat silhouette,
UMat mhi,
double timestamp,
double duration) |
map
@Namespace(value="cv::optflow") public static void calcOpticalFlowSF(@ByVal Mat from, @ByVal Mat to, @ByVal Mat flow, int layers, int averaging_block_size, int max_flow)
/** \overload
@Namespace(value="cv::optflow") public static void calcOpticalFlowSF(@ByVal UMat from, @ByVal UMat to, @ByVal UMat flow, int layers, int averaging_block_size, int max_flow)
@Namespace(value="cv::optflow") public static void calcOpticalFlowSF(@ByVal GpuMat from, @ByVal GpuMat to, @ByVal GpuMat flow, int layers, int averaging_block_size, int max_flow)
@Namespace(value="cv::optflow") public static void calcOpticalFlowSF(@ByVal Mat from, @ByVal Mat to, @ByVal Mat flow, int layers, int averaging_block_size, int max_flow, double sigma_dist, double sigma_color, int postprocess_window, double sigma_dist_fix, double sigma_color_fix, double occ_thr, int upscale_averaging_radius, double upscale_sigma_dist, double upscale_sigma_color, double speed_up_thr)
from
- First 8-bit 3-channel image.to
- Second 8-bit 3-channel image of the same size as prevflow
- computed flow image that has the same size as prev and type CV_32FC2layers
- Number of layersaveraging_block_size
- Size of block through which we sum up when calculate cost function
for pixelmax_flow
- maximal flow that we search at each levelsigma_dist
- vector smooth spatial sigma parametersigma_color
- vector smooth color sigma parameterpostprocess_window
- window size for postprocess cross bilateral filtersigma_dist_fix
- spatial sigma for postprocess cross bilateralf filtersigma_color_fix
- color sigma for postprocess cross bilateral filterocc_thr
- threshold for detecting occlusionsupscale_averaging_radius
- window size for bilateral upscale operationupscale_sigma_dist
- spatial sigma for bilateral upscale operationupscale_sigma_color
- color sigma for bilateral upscale operationspeed_up_thr
- threshold to detect point with irregular flow - where flow should be
recalculated after upscale
See \cite Tao2012 . And site of project -
\note - An example using the simpleFlow algorithm can be found at samples/simpleflow_demo.cpp
@Namespace(value="cv::optflow") public static void calcOpticalFlowSF(@ByVal UMat from, @ByVal UMat to, @ByVal UMat flow, int layers, int averaging_block_size, int max_flow, double sigma_dist, double sigma_color, int postprocess_window, double sigma_dist_fix, double sigma_color_fix, double occ_thr, int upscale_averaging_radius, double upscale_sigma_dist, double upscale_sigma_color, double speed_up_thr)
@Namespace(value="cv::optflow") public static void calcOpticalFlowSF(@ByVal GpuMat from, @ByVal GpuMat to, @ByVal GpuMat flow, int layers, int averaging_block_size, int max_flow, double sigma_dist, double sigma_color, int postprocess_window, double sigma_dist_fix, double sigma_color_fix, double occ_thr, int upscale_averaging_radius, double upscale_sigma_dist, double upscale_sigma_color, double speed_up_thr)
@Namespace(value="cv::optflow") public static void calcOpticalFlowSparseToDense(@ByVal Mat from, @ByVal Mat to, @ByVal Mat flow, int grid_step, int k, float sigma, @Cast(value="bool") boolean use_post_proc, float fgs_lambda, float fgs_sigma)
from
- first 8-bit 3-channel or 1-channel image.to
- second 8-bit 3-channel or 1-channel image of the same size as fromflow
- computed flow image that has the same size as from and CV_32FC2 typegrid_step
- stride used in sparse match computation. Lower values usually
result in higher quality but slow down the algorithm.k
- number of nearest-neighbor matches considered, when fitting a locally affine
model. Lower values can make the algorithm noticeably faster at the cost of
some quality degradation.sigma
- parameter defining how fast the weights decrease in the locally-weighted affine
fitting. Higher values can help preserve fine details, lower values can help to get rid
of the noise in the output flow.use_post_proc
- defines whether the ximgproc::fastGlobalSmootherFilter() is used
for post-processing after interpolationfgs_lambda
- see the respective parameter of the ximgproc::fastGlobalSmootherFilter()fgs_sigma
- see the respective parameter of the ximgproc::fastGlobalSmootherFilter()@Namespace(value="cv::optflow") public static void calcOpticalFlowSparseToDense(@ByVal Mat from, @ByVal Mat to, @ByVal Mat flow)
@Namespace(value="cv::optflow") public static void calcOpticalFlowSparseToDense(@ByVal UMat from, @ByVal UMat to, @ByVal UMat flow, int grid_step, int k, float sigma, @Cast(value="bool") boolean use_post_proc, float fgs_lambda, float fgs_sigma)
@Namespace(value="cv::optflow") public static void calcOpticalFlowSparseToDense(@ByVal UMat from, @ByVal UMat to, @ByVal UMat flow)
@Namespace(value="cv::optflow") public static void calcOpticalFlowSparseToDense(@ByVal GpuMat from, @ByVal GpuMat to, @ByVal GpuMat flow, int grid_step, int k, float sigma, @Cast(value="bool") boolean use_post_proc, float fgs_lambda, float fgs_sigma)
@Namespace(value="cv::optflow") public static void calcOpticalFlowSparseToDense(@ByVal GpuMat from, @ByVal GpuMat to, @ByVal GpuMat flow)
@Namespace(value="cv::optflow") @opencv_core.Ptr public static DenseOpticalFlow createOptFlow_DeepFlow()
The class implements the DeepFlow optical flow algorithm described in \cite Weinzaepfel2013 . See
also
@Namespace(value="cv::optflow") @opencv_core.Ptr public static DenseOpticalFlow createOptFlow_SimpleFlow()
@Namespace(value="cv::optflow") @opencv_core.Ptr public static DenseOpticalFlow createOptFlow_Farneback()
@Namespace(value="cv::optflow") @opencv_core.Ptr public static DenseOpticalFlow createOptFlow_SparseToDense()
@Namespace(value="cv::optflow") @opencv_core.Ptr public static DualTVL1OpticalFlow createOptFlow_DualTVL1()
@Namespace(value="cv::motempl") public static void updateMotionHistory(@ByVal Mat silhouette, @ByVal Mat mhi, double timestamp, double duration)
/** \brief Updates the motion history image by a moving silhouette.
silhouette
- Silhouette mask that has non-zero pixels where the motion occurs.mhi
- Motion history image that is updated by the function (single-channel, 32-bit
floating-point).timestamp
- Current time in milliseconds or other units.duration
- Maximal duration of the motion track in the same units as timestamp .
The function updates the motion history image as follows:
\[\texttt{mhi} (x,y)= \forkthree{\texttt{timestamp}}{if \(\texttt{silhouette}(x,y) \ne 0\)}{0}{if \(\texttt{silhouette}(x,y) = 0\) and \(\texttt{mhi} < (\texttt{timestamp} - \texttt{duration})\)}{\texttt{mhi}(x,y)}{otherwise}\]
That is, MHI pixels where the motion occurs are set to the current timestamp , while the pixels where the motion happened last time a long time ago are cleared.
The function, together with calcMotionGradient and calcGlobalOrientation , implements a motion templates technique described in \cite Davis97 and \cite Bradski00 .
@Namespace(value="cv::motempl") public static void updateMotionHistory(@ByVal UMat silhouette, @ByVal UMat mhi, double timestamp, double duration)
@Namespace(value="cv::motempl") public static void updateMotionHistory(@ByVal GpuMat silhouette, @ByVal GpuMat mhi, double timestamp, double duration)
@Namespace(value="cv::motempl") public static void calcMotionGradient(@ByVal Mat mhi, @ByVal Mat mask, @ByVal Mat orientation, double delta1, double delta2, int apertureSize)
mhi
- Motion history single-channel floating-point image.mask
- Output mask image that has the type CV_8UC1 and the same size as mhi . Its non-zero
elements mark pixels where the motion gradient data is correct.orientation
- Output motion gradient orientation image that has the same type and the same
size as mhi . Each pixel of the image is a motion orientation, from 0 to 360 degrees.delta1
- Minimal (or maximal) allowed difference between mhi values within a pixel
neighborhood.delta2
- Maximal (or minimal) allowed difference between mhi values within a pixel
neighborhood. That is, the function finds the minimum ( m(x,y)
) and maximum ( M(x,y)
) mhi
values over 3 \times 3
neighborhood of each pixel and marks the motion orientation at (x, y)
as valid only if
\[\min ( \texttt{delta1} , \texttt{delta2} ) \le M(x,y)-m(x,y) \le \max ( \texttt{delta1} , \texttt{delta2} ).\]
apertureSize
- Aperture size of the Sobel operator.
The function calculates a gradient orientation at each pixel (x, y)
as:
\[\texttt{orientation} (x,y)= \arctan{\frac{d\texttt{mhi}/dy}{d\texttt{mhi}/dx}}\]
In fact, fastAtan2 and phase are used so that the computed angle is measured in degrees and covers the full range 0..360. Also, the mask is filled to indicate pixels where the computed angle is valid.
\note - (Python) An example on how to perform a motion template technique can be found at opencv_source_code/samples/python2/motempl.py
@Namespace(value="cv::motempl") public static void calcMotionGradient(@ByVal Mat mhi, @ByVal Mat mask, @ByVal Mat orientation, double delta1, double delta2)
@Namespace(value="cv::motempl") public static void calcMotionGradient(@ByVal UMat mhi, @ByVal UMat mask, @ByVal UMat orientation, double delta1, double delta2, int apertureSize)
@Namespace(value="cv::motempl") public static void calcMotionGradient(@ByVal UMat mhi, @ByVal UMat mask, @ByVal UMat orientation, double delta1, double delta2)
@Namespace(value="cv::motempl") public static void calcMotionGradient(@ByVal GpuMat mhi, @ByVal GpuMat mask, @ByVal GpuMat orientation, double delta1, double delta2, int apertureSize)
@Namespace(value="cv::motempl") public static void calcMotionGradient(@ByVal GpuMat mhi, @ByVal GpuMat mask, @ByVal GpuMat orientation, double delta1, double delta2)
@Namespace(value="cv::motempl") public static double calcGlobalOrientation(@ByVal Mat orientation, @ByVal Mat mask, @ByVal Mat mhi, double timestamp, double duration)
orientation
- Motion gradient orientation image calculated by the function calcMotionGradientmask
- Mask image. It may be a conjunction of a valid gradient mask, also calculated by
calcMotionGradient , and the mask of a region whose direction needs to be calculated.mhi
- Motion history image calculated by updateMotionHistory .timestamp
- Timestamp passed to updateMotionHistory .duration
- Maximum duration of a motion track in milliseconds, passed to updateMotionHistory
The function calculates an average motion direction in the selected region and returns the angle between 0 degrees and 360 degrees. The average direction is computed from the weighted orientation histogram, where a recent motion has a larger weight and the motion occurred in the past has a smaller weight, as recorded in mhi .
@Namespace(value="cv::motempl") public static double calcGlobalOrientation(@ByVal UMat orientation, @ByVal UMat mask, @ByVal UMat mhi, double timestamp, double duration)
@Namespace(value="cv::motempl") public static double calcGlobalOrientation(@ByVal GpuMat orientation, @ByVal GpuMat mask, @ByVal GpuMat mhi, double timestamp, double duration)
@Namespace(value="cv::motempl") public static void segmentMotion(@ByVal Mat mhi, @ByVal Mat segmask, @ByRef RectVector boundingRects, double timestamp, double segThresh)
mhi
- Motion history image.segmask
- Image where the found mask should be stored, single-channel, 32-bit floating-point.boundingRects
- Vector containing ROIs of motion connected components.timestamp
- Current time in milliseconds or other units.segThresh
- Segmentation threshold that is recommended to be equal to the interval between
motion history "steps" or greater.
The function finds all of the motion segments and marks them in segmask with individual values (1,2,...). It also computes a vector with ROIs of motion connected components. After that the motion direction for every component can be calculated with calcGlobalOrientation using the extracted mask of the particular component.
@Namespace(value="cv::motempl") public static void segmentMotion(@ByVal UMat mhi, @ByVal UMat segmask, @ByRef RectVector boundingRects, double timestamp, double segThresh)
@Namespace(value="cv::motempl") public static void segmentMotion(@ByVal GpuMat mhi, @ByVal GpuMat segmask, @ByRef RectVector boundingRects, double timestamp, double segThresh)
Copyright © 2020. All rights reserved.