Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix opencv_contrib issue #2941 #3606

Open
wants to merge 3 commits into
base: 4.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions modules/cudabgsegm/src/mog2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ class MOG2Impl CV_FINAL : public cuda::BackgroundSubtractorMOG2
void setVarInit(double varInit) CV_OVERRIDE { constantsHost_.varInit_ = (float)varInit; }

double getVarMin() const CV_OVERRIDE { return constantsHost_.varMin_; }
void setVarMin(double varMin) CV_OVERRIDE { constantsHost_.varMin_ = ::fminf((float)varMin, constantsHost_.varMax_); }

void setVarMin(double varMin) CV_OVERRIDE { constantsHost_.varMin_ = (float)varMin; }
double getVarMax() const CV_OVERRIDE { return constantsHost_.varMax_; }
void setVarMax(double varMax) CV_OVERRIDE { constantsHost_.varMax_ = ::fmaxf(constantsHost_.varMin_, (float)varMax); }
void setVarMax(double varMax) CV_OVERRIDE { constantsHost_.varMax_ = (float)varMax; }

double getComplexityReductionThreshold() const CV_OVERRIDE { return ct_; }
void setComplexityReductionThreshold(double ct) CV_OVERRIDE { ct_ = (float)ct; }
Expand Down Expand Up @@ -239,6 +238,11 @@ void MOG2Impl::initialize(cv::Size frameSize, int frameType, Stream &stream)
bgmodelUsedModes_.create(frameSize_, CV_8UC1);
bgmodelUsedModes_.setTo(Scalar::all(0));

float real_varMin = ::fminf(constantsHost_.varMin_, constantsHost_.varMax_);
float real_varMax = ::fmaxf(constantsHost_.varMin_, constantsHost_.varMax_);
constantsHost_.varMin_ = real_varMin;
constantsHost_.varMax_ = real_varMax;

cudaSafeCall(cudaMemcpyAsync(constantsDevice_, &constantsHost_, sizeof(Constants), cudaMemcpyHostToDevice, StreamAccessor::getStream(stream)));
}
} // namespace
Expand Down
Loading