Fixed an issue with weight assignment causing the resulting GMM weights to be unsorted in the CUDA and OCL versions of BackgroundSubtractorMOG2
This commit is contained in:
@@ -489,7 +489,7 @@ namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
//need only weight if fit is found
|
||||
float weight = alpha1 * gmm_weight(mode * frame.rows + y, x) + prune;
|
||||
|
||||
int swap_count = 0;
|
||||
//fit not found yet
|
||||
if (!fitsPDF)
|
||||
{
|
||||
@@ -540,6 +540,7 @@ namespace cv { namespace gpu { namespace device
|
||||
if (weight < gmm_weight((i - 1) * frame.rows + y, x))
|
||||
break;
|
||||
|
||||
swap_count++;
|
||||
//swap one up
|
||||
swap(gmm_weight, x, y, i - 1, frame.rows);
|
||||
swap(gmm_variance, x, y, i - 1, frame.rows);
|
||||
@@ -557,7 +558,7 @@ namespace cv { namespace gpu { namespace device
|
||||
nmodes--;
|
||||
}
|
||||
|
||||
gmm_weight(mode * frame.rows + y, x) = weight; //update weight by the calculated value
|
||||
gmm_weight((mode - swap_count) * frame.rows + y, x) = weight; //update weight by the calculated value
|
||||
totalWeight += weight;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user