在官方示例中,Motion-Based Multiple Object Tracking和Using Kalman Filter for Object Tracking都使用了下面兩個算法進行物體的識別
1、vision.ForegroundDetector
原理:The ForegroundDetector System object compares a color or grayscale video frame to a background model to determine whether individual pixels are part of the background or the foreground. It then computes a foreground mask. By using background subtraction, you can detect foreground objects in an image taken from a stationary camera.
將每一幀和一個背景幀進行對比,判斷每個像素點是屬於背景,還是屬於罩子(罩子就是不屬於背景的意思)。通過這種對比,就能識別出后面幀中運動的物體。適用范圍:一個固定的攝像頭所拍攝的視頻。
算法:Gaussian mixture models (GMM).,呵呵,又是高斯。
使用方法見官方文檔、示例。
參數,也是最重要的部分:
AdaptLearningRate,默認true,解釋:
Enables the object to adapt the learning rate during the period specified by the NumTrainingFrames property. When you set this property to true, the object sets the LearningRate property to 1/(current frame number). When you set this property to false, the LearningRate property must be set at each time step.
很簡單,就是設置要不要Learning。
NumTrainingFrames,默認150,解釋:
用於訓練背景模型的幀數,前面講過,通過和這個背景模型對比來識別運動的物體。注意:這些數目的幀是指視頻開頭的部分。
LearningRate,默認0.005,解釋:
Learning rate for parameter updates(說不上來,自己理解吧。)
Specify the learning rate to adapt model parameters. This property controls how quickly the model adapts to changing conditions. Set this property appropriately to ensure algorithm stability.(控制背景模型的更新速度,同時該參數影響算法的穩定性)
When you set AdaptLearningRate to true, the LearningRate property takes effect only after the training period specified by NumTrainingFrames is over.
(這個參數在初始的學習幀數,也就是上一個參數完畢后,才開始生效)
When you set the AdaptLearningRate to false, this property will not be available. This property is tunable.
MinimumBackgroundRatio,默認0.7,解釋:
Threshold to determine background model
Set this property to represent the minimum of the apriori probabilities for pixels to be considered background values. Multimodal backgrounds can not be handled, if this value is too small.
一個像素被認為是屬於背景的最小先驗概率。個人認為這個參數控制識別的敏感性,設置比較大時,識別就比較遲鈍,對細微變化忽略掉。
NumGaussians,默認5,解釋:
Number of Gaussian modes in the mixture model(高斯大神的數量?大神保佑我)
Specify the number of Gaussian modes in the mixture model. Set this property to a positive integer. Typically this value is 3, 4 or 5. Set this value to 3 or greater to be able to model multiple background modes.(貌似是越大越好?然后更利於處理多背景的情況)
InitialVariance,解釋:
Variance when initializing a new Gaussian mode
呵呵
一些相關的方法就不解釋了。
2、vision.BlobAnalysis
原理:computes statistics for connected regions in a binary image. (將連通的區域連起來,作為識別的那個移動物體);
輸入輸出參數:
Use the step syntax below with input binary image, BW, blob analysis object, H, and any optional properties. The step method computes and returns statistics of the input binary image depending on the property values specified. The order of the returned values when there are multiple outputs are in the order they are described below:
輸出:區域的面積、中心點、外面的框框。
[AREA,CENTROID,BBOX] = step(H,BW) returns the area, centroid and the bounding box of the blobs when the AreaOutputPort, CentroidOutputPort and BoundingBoxOutputPort properties are set to true. These are the only properties that are set to true by default. If you set any additional properties to true, the corresponding outputs follow the AREA,CENTROID, and BBOX outputs.
輸入參數有很多個,這里不一一解釋,后面用到再詳細說。
可設置的屬性:
AreaOutputPort,CentroidOutputPort,BoundingBoxOutputPort
默認為true,表示會輸出[AREA,CENTROID,BBOX]
MajorAxisLengthOutputPort,MinorAxisLengthOutputPort,OrientationOutputPort,EccentricityOutputPort,
EquivalentDiameterSquaredOutputPort,ExtentOutputPort,PerimeterOutputPort,LabelMatrixOutputPort
一些計算結果的輸出,默認為false
OutputDataType,默認double,設置輸出數據的格式,包括: double, single, or Fixed point
Connectivity,默認8,設置哪些像素點是連接的,可選4和8。你懂的,一個小正方形周圍有8個小正方形。
MaximumCount,默認50,解釋:
Maximum number of labeled regions in each input image(每幅圖中最大的區域個數,也就是識別到的運動物體個數)
MinimumBlobArea,默認0,解釋:
Minimum blob area in pixels(區域最小面積,占多少個像素?)
MaximumBlobArea,默認為最大的整型數intmax('uint32')
Maximum blob area in pixels(區域占的最大面積,單位像素)
以上兩個屬性可以控制識別到的區域大小,把不想識別到的篩選出去。
ExcludeBorderBlobs,默認false
Exclude blobs that contain at least one border pixel
Set this property to true if you do not want to label blobs that contain at least one border pixel.
排除掉有邊界的區域。
