mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-18 00:01:17 +08:00
Fixed OpenCL check behavior
This commit is contained in:
@@ -100,6 +100,7 @@ protected:
|
||||
const float occlusionsThreshold;
|
||||
const float dampingFactor;
|
||||
const float claheClip;
|
||||
bool useOpenCL;
|
||||
|
||||
public:
|
||||
OpticalFlowPCAFlow( Ptr<const PCAPrior> _prior = Ptr<const PCAPrior>(), const Size _basisSize = Size( 18, 14 ),
|
||||
|
@@ -283,7 +283,12 @@ int main( int argc, char** argv )
|
||||
|
||||
double startTick, time;
|
||||
startTick = (double) getTickCount(); // measure time
|
||||
algorithm->calc(i1, i2, flow);
|
||||
|
||||
if (useGpu)
|
||||
algorithm->calc(i1, i2, flow.getUMat(ACCESS_RW));
|
||||
else
|
||||
algorithm->calc(i1, i2, flow);
|
||||
|
||||
time = ((double) getTickCount() - startTick) / getTickFrequency();
|
||||
printf("\nTime [s]: %.3f\n", time);
|
||||
if(display_images)
|
||||
|
@@ -321,7 +321,7 @@ void OpticalFlowPCAFlow::getSystem( OutputArray AOut, OutputArray b1Out, OutputA
|
||||
AOut.create( features.size(), basisSize.area(), CV_32F );
|
||||
b1Out.create( features.size(), 1, CV_32F );
|
||||
b2Out.create( features.size(), 1, CV_32F );
|
||||
if ( ocl::useOpenCL() )
|
||||
if ( useOpenCL )
|
||||
{
|
||||
UMat A = AOut.getUMat();
|
||||
Mat b1 = b1Out.getMat();
|
||||
@@ -369,7 +369,7 @@ void OpticalFlowPCAFlow::getSystem( OutputArray A1Out, OutputArray A2Out, Output
|
||||
b1Out.create( features.size() + prior->getPadding(), 1, CV_32F );
|
||||
b2Out.create( features.size() + prior->getPadding(), 1, CV_32F );
|
||||
|
||||
if ( ocl::useOpenCL() )
|
||||
if ( useOpenCL )
|
||||
{
|
||||
UMat A = A1Out.getUMat();
|
||||
Mat b1 = b1Out.getMat();
|
||||
@@ -444,6 +444,7 @@ void OpticalFlowPCAFlow::calc( InputArray I0, InputArray I1, InputOutputArray fl
|
||||
CV_Assert( to.channels() == 1 );
|
||||
|
||||
const Mat fromOrig = from.getMat( ACCESS_READ ).clone();
|
||||
useOpenCL = flowOut.isUMat() && ocl::useOpenCL();
|
||||
|
||||
applyCLAHE( from, claheClip );
|
||||
applyCLAHE( to, claheClip );
|
||||
@@ -481,7 +482,7 @@ OpticalFlowPCAFlow::OpticalFlowPCAFlow( Ptr<const PCAPrior> _prior, const Size _
|
||||
float _dampingFactor, float _claheClip )
|
||||
: prior( _prior ), basisSize( _basisSize ), sparseRate( _sparseRate ),
|
||||
retainedCornersFraction( _retainedCornersFraction ), occlusionsThreshold( _occlusionsThreshold ),
|
||||
dampingFactor( _dampingFactor ), claheClip( _claheClip )
|
||||
dampingFactor( _dampingFactor ), claheClip( _claheClip ), useOpenCL( false )
|
||||
{
|
||||
CV_Assert( sparseRate > 0 && sparseRate <= 0.1 );
|
||||
CV_Assert( retainedCornersFraction >= 0 && retainedCornersFraction <= 1.0 );
|
||||
|
Reference in New Issue
Block a user