A method for counting a number of moving objects that cross at least one predefined curve (116-1, 116-21,116-22, 116-31, 16-32) in a scene, comprising: making detections (401-t1, 401-t2, 401-t3, 401-t4, 401-t5, 401-t6, 401-t7) of positions of one or more moving objects in the scene by using data collected by a sensor device (112-1, 112-2, 112-3), tracking the one or more moving objects in the scene overtime based on the detections (401-t1, 401-t2, 401-t3, 401-t4, 401-t5, 401-t6, 401-t7) to produce one or more corresponding tracks, calculating, for each moving object, a success probability p i that the moving object succeeded to cross the at least one predefined curve (116-1, 116-21,116-22, 116-31, 16-32) in the scene, and a failure probability 1 - p i that the moving object failed to cross the at least one predefined curve (116-1, 116-21,116-22, 116-31, 16-32) in the scene, and calculating an expected value of a number of moving objects that crossed the at least one predefined curve (116-1, 116-21,116-22, 116-31, 16-32), characterized by each track being described by a time dependent probability density function (402-t1, 402-t2, 402-t3, 402-t4, 402-t5, 402-t6, 402-t7), the success probability of a moving object being calculated by using the time dependent probability density function (402-t1, 402-t2, 402-t3, 402-t4, 402-t5, 402-t6, 402-t7) describing the track of the moving object, and calculating a variance of the number of moving objects that crossed the at least one predefined curve (116-1, 116-21,116-22, 116-31, 16-32), wherein the expected value is calculated by summing success probabilities p i calculated with respect to the one or more moving objects, and the variance is calculated by summing products p i (1 - p i) of success and failure probabilities calculated with respect to the one or more moving objects. making detections (401-t1, 401-t2, 401-t3, 401-t4, 401-t5, 401-t6, 401-t7) of positions of one or more moving objects in the scene by using data collected by a sensor device (112-1, 112-2, 112-3), tracking the one or more moving objects in the scene overtime based on the detections (401-t1, 401-t2, 401-t3, 401-t4, 401-t5, 401-t6, 401-t7) to produce one or more corresponding tracks, calculating, for each moving object, a success probability p i that the moving object succeeded to cross the at least one predefined curve (116-1, 116-21,116-22, 116-31, 16-32) in the scene, and a failure probability 1 - p i that the moving object failed to cross the at least one predefined curve (116-1, 116-21,116-22, 116-31, 16-32) in the scene, and calculating an expected value of a number of moving objects that crossed the at least one predefined curve (116-1, 116-21,116-22, 116-31, 16-32), characterized by each track being described by a time dependent probability density function (402-t1, 402-t2, 402-t3, 402-t4, 402-t5, 402-t6, 402-t7), the success probability of a moving object being calculated by using the time dependent probability density function (402-t1, 402-t2, 402-t3, 402-t4, 402-t5, 402-t6, 402-t7) describing the track of the moving object, and calculating a variance of the number of moving objects that crossed the at least one predefined curve (116-1, 116-21,116-22, 116-31, 16-32), wherein the expected value is calculated by summing success probabilities p i calculated with respect to the one or more moving objects, and the variance is calculated by summing products p i (1 - p i) of success and failure probabilities calculated with respect to the one or more moving objects.