int r = range.start;
chunksSizeAndLabels_[r] = range.end;
- LabelT label = LabelT((r * imgLabels_.cols + 1) / 2 + 1);
+ LabelT label = LabelT((r + 1) / 2) * LabelT((imgLabels_.cols + 1) / 2) + 1;
const LabelT firstLabel = label;
const int w = img_.cols;
//merge labels of different chunks
mergeLabels8Connectivity(imgLabels, P, chunksSizeAndLabels);
+
+ for (int i = 0; i < h; i = chunksSizeAndLabels[i]){
+ flattenL(P, int((i + 1) / 2) * int((w + 1) / 2) + 1, chunksSizeAndLabels[i + 1], nLabels);
+ }
}
else{
//First scan, each thread works with chunk of img.rows/nThreads rows
//merge labels of different chunks
mergeLabels4Connectivity(imgLabels, P, chunksSizeAndLabels);
- }
-
- for (int i = 0; i < h; i = chunksSizeAndLabels[i]){
- flattenL(P, (i * w + 1) / 2 + 1, chunksSizeAndLabels[i + 1], nLabels);
+
+ for (int i = 0; i < h; i = chunksSizeAndLabels[i]){
+ flattenL(P, int(i * w + 1) / 2 + 1, chunksSizeAndLabels[i + 1], nLabels);
+ }
}
//Array for statistics dataof threads
chunksSizeAndLabels_[r] = range.end + (range.end % 2);
- LabelT label = LabelT((r + 1) * (imgLabels_.cols + 1) / 4);
+ LabelT label = LabelT((r + 1) / 2) * LabelT((imgLabels_.cols + 1) / 2) + 1;
const LabelT firstLabel = label;
const int h = img_.rows, w = img_.cols;
//0 0 0 0 0...
//1 0 1 0 1...
//............
- const size_t Plength = ((size_t(h) + 1) * (size_t(w) + 1)) / 4 + 1;
+ const size_t Plength = size_t(((h + 1) / 2) * size_t((w + 1) / 2)) + 1;
//Array used to store info and labeled pixel by each thread.
//Different threads affect different memory location of chunksSizeAndLabels
LabelT nLabels = 1;
for (int i = 0; i < h; i = chunksSizeAndLabels[i]){
- flattenL(P, (i + 1) * (w + 1) / 4, chunksSizeAndLabels[i + 1], nLabels);
+ flattenL(P, LabelT((i + 1) / 2) * LabelT((w + 1) / 2) + 1, chunksSizeAndLabels[i + 1], nLabels);
}
//Array for statistics data
//0 0 0 0 0...
//1 0 1 0 1...
//............
- const size_t Plength = ((size_t(h) + 1) * (size_t(w) + 1)) / 4 + 1;
+ const size_t Plength = size_t(((h + 1) / 2) * size_t((w + 1) / 2)) + 1;
LabelT *P = (LabelT *)fastMalloc(sizeof(LabelT) *Plength);
P[0] = 0;
A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
- is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra,
+ is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara,
*Detecting Moving Shadows...*, IEEE PAMI,2003.
*/
CV_WRAP virtual double getShadowThreshold() const = 0;
A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
- is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra,
+ is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara,
*Detecting Moving Shadows...*, IEEE PAMI,2003.
*/
CV_WRAP virtual double getShadowThreshold() const = 0;
// Tau - shadow threshold. The shadow is detected if the pixel is darker
//version of the background. Tau is a threshold on how much darker the shadow can be.
//Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
- //See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
+ //See: Prati,Mikic,Trivedi,Cucchiara,"Detecting Moving Shadows...",IEEE PAMI,2003.
//model data
int nLongCounter;//circular counter
// Tau - shadow threshold. The shadow is detected if the pixel is darker
//version of the background. Tau is a threshold on how much darker the shadow can be.
//Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
- //See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
+ //See: Prati,Mikic,Trivedi,Cucchiara,"Detecting Moving Shadows...",IEEE PAMI,2003.
String name_;
// Tau - shadow threshold. The shadow is detected if the pixel is darker
//version of the background. Tau is a threshold on how much darker the shadow can be.
//Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
- //See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
+ //See: Prati,Mikic,Trivedi,Cucchiara,"Detecting Moving Shadows...",IEEE PAMI,2003.
};
struct GMM
// shadow detection performed per pixel
// should work for rgb data, could be usefull for gray scale and depth data as well
-// See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
+// See: Prati,Mikic,Trivedi,Cucchiara,"Detecting Moving Shadows...",IEEE PAMI,2003.
CV_INLINE bool
detectShadowGMM(const float* data, int nchannels, int nmodes,
const GMM* gmm, const float* mean,