gpubgsegm module fixes
This commit is contained in:
parent
c0b3424a23
commit
f531dd839c
@ -4,6 +4,6 @@ endif()
|
||||
|
||||
set(the_description "GPU-accelerated Background Segmentation")
|
||||
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations)
|
||||
|
||||
ocv_define_module(gpubgsegm opencv_video opencv_legacy opencv_gpufilters opencv_gpuimgproc)
|
||||
ocv_define_module(gpubgsegm opencv_video opencv_imgproc opencv_legacy opencv_gpuarithm opencv_gpufilters opencv_gpuimgproc)
|
||||
|
@ -1,296 +1,10 @@
|
||||
Video Analysis
|
||||
==============
|
||||
Background Segmentation
|
||||
=======================
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
|
||||
|
||||
gpu::BroxOpticalFlow
|
||||
--------------------
|
||||
.. ocv:class:: gpu::BroxOpticalFlow
|
||||
|
||||
Class computing the optical flow for two images using Brox et al Optical Flow algorithm ([Brox2004]_). ::
|
||||
|
||||
class BroxOpticalFlow
|
||||
{
|
||||
public:
|
||||
BroxOpticalFlow(float alpha_, float gamma_, float scale_factor_, int inner_iterations_, int outer_iterations_, int solver_iterations_);
|
||||
|
||||
//! Compute optical flow
|
||||
//! frame0 - source frame (supports only CV_32FC1 type)
|
||||
//! frame1 - frame to track (with the same size and type as frame0)
|
||||
//! u - flow horizontal component (along x axis)
|
||||
//! v - flow vertical component (along y axis)
|
||||
void operator ()(const GpuMat& frame0, const GpuMat& frame1, GpuMat& u, GpuMat& v, Stream& stream = Stream::Null());
|
||||
|
||||
//! flow smoothness
|
||||
float alpha;
|
||||
|
||||
//! gradient constancy importance
|
||||
float gamma;
|
||||
|
||||
//! pyramid scale factor
|
||||
float scale_factor;
|
||||
|
||||
//! number of lagged non-linearity iterations (inner loop)
|
||||
int inner_iterations;
|
||||
|
||||
//! number of warping iterations (number of pyramid levels)
|
||||
int outer_iterations;
|
||||
|
||||
//! number of linear system solver iterations
|
||||
int solver_iterations;
|
||||
|
||||
GpuMat buf;
|
||||
};
|
||||
|
||||
|
||||
|
||||
gpu::GoodFeaturesToTrackDetector_GPU
|
||||
------------------------------------
|
||||
.. ocv:class:: gpu::GoodFeaturesToTrackDetector_GPU
|
||||
|
||||
Class used for strong corners detection on an image. ::
|
||||
|
||||
class GoodFeaturesToTrackDetector_GPU
|
||||
{
|
||||
public:
|
||||
explicit GoodFeaturesToTrackDetector_GPU(int maxCorners_ = 1000, double qualityLevel_ = 0.01, double minDistance_ = 0.0,
|
||||
int blockSize_ = 3, bool useHarrisDetector_ = false, double harrisK_ = 0.04);
|
||||
|
||||
void operator ()(const GpuMat& image, GpuMat& corners, const GpuMat& mask = GpuMat());
|
||||
|
||||
int maxCorners;
|
||||
double qualityLevel;
|
||||
double minDistance;
|
||||
|
||||
int blockSize;
|
||||
bool useHarrisDetector;
|
||||
double harrisK;
|
||||
|
||||
void releaseMemory();
|
||||
};
|
||||
|
||||
The class finds the most prominent corners in the image.
|
||||
|
||||
.. seealso:: :ocv:func:`goodFeaturesToTrack`
|
||||
|
||||
|
||||
|
||||
gpu::GoodFeaturesToTrackDetector_GPU::GoodFeaturesToTrackDetector_GPU
|
||||
---------------------------------------------------------------------
|
||||
Constructor.
|
||||
|
||||
.. ocv:function:: gpu::GoodFeaturesToTrackDetector_GPU::GoodFeaturesToTrackDetector_GPU(int maxCorners = 1000, double qualityLevel = 0.01, double minDistance = 0.0, int blockSize = 3, bool useHarrisDetector = false, double harrisK = 0.04)
|
||||
|
||||
:param maxCorners: Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned.
|
||||
|
||||
:param qualityLevel: Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see :ocv:func:`gpu::cornerMinEigenVal` ) or the Harris function response (see :ocv:func:`gpu::cornerHarris` ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the ``qualityLevel=0.01`` , then all the corners with the quality measure less than 15 are rejected.
|
||||
|
||||
:param minDistance: Minimum possible Euclidean distance between the returned corners.
|
||||
|
||||
:param blockSize: Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See :ocv:func:`cornerEigenValsAndVecs` .
|
||||
|
||||
:param useHarrisDetector: Parameter indicating whether to use a Harris detector (see :ocv:func:`gpu::cornerHarris`) or :ocv:func:`gpu::cornerMinEigenVal`.
|
||||
|
||||
:param harrisK: Free parameter of the Harris detector.
|
||||
|
||||
|
||||
|
||||
gpu::GoodFeaturesToTrackDetector_GPU::operator ()
|
||||
-------------------------------------------------
|
||||
Finds the most prominent corners in the image.
|
||||
|
||||
.. ocv:function:: void gpu::GoodFeaturesToTrackDetector_GPU::operator ()(const GpuMat& image, GpuMat& corners, const GpuMat& mask = GpuMat())
|
||||
|
||||
:param image: Input 8-bit, single-channel image.
|
||||
|
||||
:param corners: Output vector of detected corners (it will be one row matrix with CV_32FC2 type).
|
||||
|
||||
:param mask: Optional region of interest. If the image is not empty (it needs to have the type ``CV_8UC1`` and the same size as ``image`` ), it specifies the region in which the corners are detected.
|
||||
|
||||
.. seealso:: :ocv:func:`goodFeaturesToTrack`
|
||||
|
||||
|
||||
|
||||
gpu::GoodFeaturesToTrackDetector_GPU::releaseMemory
|
||||
---------------------------------------------------
|
||||
Releases inner buffers memory.
|
||||
|
||||
.. ocv:function:: void gpu::GoodFeaturesToTrackDetector_GPU::releaseMemory()
|
||||
|
||||
|
||||
|
||||
gpu::FarnebackOpticalFlow
|
||||
-------------------------
|
||||
.. ocv:class:: gpu::FarnebackOpticalFlow
|
||||
|
||||
Class computing a dense optical flow using the Gunnar Farneback’s algorithm. ::
|
||||
|
||||
class CV_EXPORTS FarnebackOpticalFlow
|
||||
{
|
||||
public:
|
||||
FarnebackOpticalFlow()
|
||||
{
|
||||
numLevels = 5;
|
||||
pyrScale = 0.5;
|
||||
fastPyramids = false;
|
||||
winSize = 13;
|
||||
numIters = 10;
|
||||
polyN = 5;
|
||||
polySigma = 1.1;
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
int numLevels;
|
||||
double pyrScale;
|
||||
bool fastPyramids;
|
||||
int winSize;
|
||||
int numIters;
|
||||
int polyN;
|
||||
double polySigma;
|
||||
int flags;
|
||||
|
||||
void operator ()(const GpuMat &frame0, const GpuMat &frame1, GpuMat &flowx, GpuMat &flowy, Stream &s = Stream::Null());
|
||||
|
||||
void releaseMemory();
|
||||
|
||||
private:
|
||||
/* hidden */
|
||||
};
|
||||
|
||||
|
||||
|
||||
gpu::FarnebackOpticalFlow::operator ()
|
||||
--------------------------------------
|
||||
Computes a dense optical flow using the Gunnar Farneback’s algorithm.
|
||||
|
||||
.. ocv:function:: void gpu::FarnebackOpticalFlow::operator ()(const GpuMat &frame0, const GpuMat &frame1, GpuMat &flowx, GpuMat &flowy, Stream &s = Stream::Null())
|
||||
|
||||
:param frame0: First 8-bit gray-scale input image
|
||||
:param frame1: Second 8-bit gray-scale input image
|
||||
:param flowx: Flow horizontal component
|
||||
:param flowy: Flow vertical component
|
||||
:param s: Stream
|
||||
|
||||
.. seealso:: :ocv:func:`calcOpticalFlowFarneback`
|
||||
|
||||
|
||||
|
||||
gpu::FarnebackOpticalFlow::releaseMemory
|
||||
----------------------------------------
|
||||
Releases unused auxiliary memory buffers.
|
||||
|
||||
.. ocv:function:: void gpu::FarnebackOpticalFlow::releaseMemory()
|
||||
|
||||
|
||||
|
||||
gpu::PyrLKOpticalFlow
|
||||
---------------------
|
||||
.. ocv:class:: gpu::PyrLKOpticalFlow
|
||||
|
||||
Class used for calculating an optical flow. ::
|
||||
|
||||
class PyrLKOpticalFlow
|
||||
{
|
||||
public:
|
||||
PyrLKOpticalFlow();
|
||||
|
||||
void sparse(const GpuMat& prevImg, const GpuMat& nextImg, const GpuMat& prevPts, GpuMat& nextPts,
|
||||
GpuMat& status, GpuMat* err = 0);
|
||||
|
||||
void dense(const GpuMat& prevImg, const GpuMat& nextImg, GpuMat& u, GpuMat& v, GpuMat* err = 0);
|
||||
|
||||
Size winSize;
|
||||
int maxLevel;
|
||||
int iters;
|
||||
bool useInitialFlow;
|
||||
|
||||
void releaseMemory();
|
||||
};
|
||||
|
||||
The class can calculate an optical flow for a sparse feature set or dense optical flow using the iterative Lucas-Kanade method with pyramids.
|
||||
|
||||
.. seealso:: :ocv:func:`calcOpticalFlowPyrLK`
|
||||
|
||||
|
||||
|
||||
gpu::PyrLKOpticalFlow::sparse
|
||||
-----------------------------
|
||||
Calculate an optical flow for a sparse feature set.
|
||||
|
||||
.. ocv:function:: void gpu::PyrLKOpticalFlow::sparse(const GpuMat& prevImg, const GpuMat& nextImg, const GpuMat& prevPts, GpuMat& nextPts, GpuMat& status, GpuMat* err = 0)
|
||||
|
||||
:param prevImg: First 8-bit input image (supports both grayscale and color images).
|
||||
|
||||
:param nextImg: Second input image of the same size and the same type as ``prevImg`` .
|
||||
|
||||
:param prevPts: Vector of 2D points for which the flow needs to be found. It must be one row matrix with CV_32FC2 type.
|
||||
|
||||
:param nextPts: Output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image. When ``useInitialFlow`` is true, the vector must have the same size as in the input.
|
||||
|
||||
:param status: Output status vector (CV_8UC1 type). Each element of the vector is set to 1 if the flow for the corresponding features has been found. Otherwise, it is set to 0.
|
||||
|
||||
:param err: Output vector (CV_32FC1 type) that contains the difference between patches around the original and moved points or min eigen value if ``getMinEigenVals`` is checked. It can be NULL, if not needed.
|
||||
|
||||
.. seealso:: :ocv:func:`calcOpticalFlowPyrLK`
|
||||
|
||||
|
||||
|
||||
gpu::PyrLKOpticalFlow::dense
|
||||
-----------------------------
|
||||
Calculate dense optical flow.
|
||||
|
||||
.. ocv:function:: void gpu::PyrLKOpticalFlow::dense(const GpuMat& prevImg, const GpuMat& nextImg, GpuMat& u, GpuMat& v, GpuMat* err = 0)
|
||||
|
||||
:param prevImg: First 8-bit grayscale input image.
|
||||
|
||||
:param nextImg: Second input image of the same size and the same type as ``prevImg`` .
|
||||
|
||||
:param u: Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
|
||||
|
||||
:param v: Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
|
||||
|
||||
:param err: Output vector (CV_32FC1 type) that contains the difference between patches around the original and moved points or min eigen value if ``getMinEigenVals`` is checked. It can be NULL, if not needed.
|
||||
|
||||
|
||||
|
||||
gpu::PyrLKOpticalFlow::releaseMemory
|
||||
------------------------------------
|
||||
Releases inner buffers memory.
|
||||
|
||||
.. ocv:function:: void gpu::PyrLKOpticalFlow::releaseMemory()
|
||||
|
||||
|
||||
|
||||
gpu::interpolateFrames
|
||||
----------------------
|
||||
Interpolates frames (images) using provided optical flow (displacement field).
|
||||
|
||||
.. ocv:function:: void gpu::interpolateFrames(const GpuMat& frame0, const GpuMat& frame1, const GpuMat& fu, const GpuMat& fv, const GpuMat& bu, const GpuMat& bv, float pos, GpuMat& newFrame, GpuMat& buf, Stream& stream = Stream::Null())
|
||||
|
||||
:param frame0: First frame (32-bit floating point images, single channel).
|
||||
|
||||
:param frame1: Second frame. Must have the same type and size as ``frame0`` .
|
||||
|
||||
:param fu: Forward horizontal displacement.
|
||||
|
||||
:param fv: Forward vertical displacement.
|
||||
|
||||
:param bu: Backward horizontal displacement.
|
||||
|
||||
:param bv: Backward vertical displacement.
|
||||
|
||||
:param pos: New frame position.
|
||||
|
||||
:param newFrame: Output image.
|
||||
|
||||
:param buf: Temporary buffer, will have width x 6*height size, CV_32FC1 type and contain 6 GpuMat: occlusion masks for first frame, occlusion masks for second, interpolated forward horizontal flow, interpolated forward vertical flow, interpolated backward horizontal flow, interpolated backward vertical flow.
|
||||
|
||||
:param stream: Stream for the asynchronous version.
|
||||
|
||||
|
||||
|
||||
gpu::FGDStatModel
|
||||
-----------------
|
||||
.. ocv:class:: gpu::FGDStatModel
|
||||
@ -687,7 +401,6 @@ Releases all inner buffer's memory.
|
||||
|
||||
|
||||
|
||||
.. [Brox2004] T. Brox, A. Bruhn, N. Papenberg, J. Weickert. *High accuracy optical flow estimation based on a theory for warping*. ECCV 2004.
|
||||
.. [FGD2003] Liyuan Li, Weimin Huang, Irene Y.H. Gu, and Qi Tian. *Foreground Object Detection from Videos Containing Complex Background*. ACM MM2003 9p, 2003.
|
||||
.. [MOG2001] P. KadewTraKuPong and R. Bowden. *An improved adaptive background mixture model for real-time tracking with shadow detection*. Proc. 2nd European Workshop on Advanced Video-Based Surveillance Systems, 2001
|
||||
.. [MOG2004] Z. Zivkovic. *Improved adaptive Gausian mixture model for background subtraction*. International Conference Pattern Recognition, UK, August, 2004
|
||||
|
@ -1,6 +1,6 @@
|
||||
********************************************
|
||||
gpu. GPU-accelerated Background Segmentation
|
||||
********************************************
|
||||
**************************************************
|
||||
gpubgsegm. GPU-accelerated Background Segmentation
|
||||
**************************************************
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
@ -43,6 +43,10 @@
|
||||
#ifndef __OPENCV_GPUBGSEGM_HPP__
|
||||
#define __OPENCV_GPUBGSEGM_HPP__
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error gpubgsegm.hpp header must be compiled as C++
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
|
@ -41,6 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "opencv2/legacy.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
@ -73,7 +74,7 @@ namespace cv
|
||||
|
||||
DEF_PARAM_TEST_1(Video, string);
|
||||
|
||||
PERF_TEST_P(Video, Video_FGDStatModel,
|
||||
PERF_TEST_P(Video, FGDStatModel,
|
||||
Values(string("gpu/video/768x576.avi")))
|
||||
{
|
||||
declare.time(60);
|
||||
@ -146,7 +147,7 @@ PERF_TEST_P(Video, Video_FGDStatModel,
|
||||
|
||||
DEF_PARAM_TEST(Video_Cn_LearningRate, string, MatCn, double);
|
||||
|
||||
PERF_TEST_P(Video_Cn_LearningRate, Video_MOG,
|
||||
PERF_TEST_P(Video_Cn_LearningRate, MOG,
|
||||
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
|
||||
GPU_CHANNELS_1_3_4,
|
||||
Values(0.0, 0.01)))
|
||||
@ -245,7 +246,7 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG,
|
||||
|
||||
DEF_PARAM_TEST(Video_Cn, string, int);
|
||||
|
||||
PERF_TEST_P(Video_Cn, Video_MOG2,
|
||||
PERF_TEST_P(Video_Cn, MOG2,
|
||||
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
|
||||
GPU_CHANNELS_1_3_4))
|
||||
{
|
||||
@ -344,7 +345,7 @@ PERF_TEST_P(Video_Cn, Video_MOG2,
|
||||
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
|
||||
PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage,
|
||||
PERF_TEST_P(Video_Cn, MOG2GetBackgroundImage,
|
||||
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
|
||||
GPU_CHANNELS_1_3_4))
|
||||
{
|
||||
@ -428,7 +429,7 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage,
|
||||
|
||||
DEF_PARAM_TEST(Video_Cn_MaxFeatures, string, MatCn, int);
|
||||
|
||||
PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG,
|
||||
PERF_TEST_P(Video_Cn_MaxFeatures, GMG,
|
||||
Combine(Values(string("gpu/video/768x576.avi")),
|
||||
GPU_CHANNELS_1_3_4,
|
||||
Values(20, 40, 60)))
|
@ -44,4 +44,4 @@
|
||||
|
||||
using namespace perf;
|
||||
|
||||
CV_PERF_TEST_MAIN(gpuarithm, printCudaInfo())
|
||||
CV_PERF_TEST_MAIN(gpubgsegm, printCudaInfo())
|
||||
|
@ -55,9 +55,7 @@
|
||||
#include "opencv2/ts/gpu_perf.hpp"
|
||||
|
||||
#include "opencv2/gpubgsegm.hpp"
|
||||
|
||||
#include "opencv2/video.hpp"
|
||||
#include "opencv2/legacy.hpp"
|
||||
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "opencv2/core/cuda/utility.hpp"
|
||||
#include "opencv2/core/cuda/reduce.hpp"
|
||||
#include "opencv2/core/cuda/functional.hpp"
|
||||
#include "fgd_bgfg_common.hpp"
|
||||
#include "fgd.hpp"
|
||||
|
||||
using namespace cv::gpu;
|
||||
using namespace cv::gpu::cudev;
|
@ -59,7 +59,7 @@ int cv::gpu::FGDStatModel::update(const cv::gpu::GpuMat&) { throw_no_cuda(); ret
|
||||
|
||||
#else
|
||||
|
||||
#include "fgd_bgfg_common.hpp"
|
||||
#include "cuda/fgd.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
|
||||
namespace
|
@ -46,23 +46,10 @@
|
||||
#include <limits>
|
||||
|
||||
#include "opencv2/gpubgsegm.hpp"
|
||||
|
||||
#include "opencv2/gpuarithm.hpp"
|
||||
#include "opencv2/gpufilters.hpp"
|
||||
#include "opencv2/gpuimgproc.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/video.hpp"
|
||||
|
||||
#include "opencv2/core/gpu_private.hpp"
|
||||
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCV_GPULEGACY
|
||||
# include "opencv2/gpulegacy/private.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
# include "cuda/fgd_bgfg_common.hpp"
|
||||
#endif
|
||||
|
||||
#endif /* __OPENCV_PRECOMP_H__ */
|
||||
|
@ -143,7 +143,7 @@ GPU_TEST_P(FGDStatModel, Update)
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Video, FGDStatModel, testing::Combine(
|
||||
INSTANTIATE_TEST_CASE_P(GPU_BgSegm, FGDStatModel, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
testing::Values(std::string("768x576.avi")),
|
||||
testing::Values(Channels(3), Channels(4))));
|
||||
@ -219,7 +219,7 @@ GPU_TEST_P(MOG, Update)
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Video, MOG, testing::Combine(
|
||||
INSTANTIATE_TEST_CASE_P(GPU_BgSegm, MOG, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
testing::Values(std::string("768x576.avi")),
|
||||
testing::Values(UseGray(true), UseGray(false)),
|
||||
@ -339,7 +339,7 @@ GPU_TEST_P(MOG2, getBackgroundImage)
|
||||
ASSERT_MAT_NEAR(background_gold, background, 0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Video, MOG2, testing::Combine(
|
||||
INSTANTIATE_TEST_CASE_P(GPU_BgSegm, MOG2, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
testing::Values(std::string("768x576.avi")),
|
||||
testing::Values(UseGray(true), UseGray(false)),
|
||||
@ -395,7 +395,7 @@ GPU_TEST_P(GMG, Accuracy)
|
||||
ASSERT_MAT_NEAR(fullfg, d_fgmask, 0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Video, GMG, testing::Combine(
|
||||
INSTANTIATE_TEST_CASE_P(GPU_BgSegm, GMG, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(MatType(CV_8U), MatType(CV_16U), MatType(CV_32F)),
|
@ -57,8 +57,6 @@
|
||||
#include "opencv2/ts/gpu_test.hpp"
|
||||
|
||||
#include "opencv2/gpubgsegm.hpp"
|
||||
|
||||
#include "opencv2/video.hpp"
|
||||
#include "opencv2/legacy.hpp"
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user