當前位置: 首頁>>代碼示例>>Python>>正文


Python cv2.KalmanFilter方法代碼示例

本文整理匯總了Python中cv2.KalmanFilter方法的典型用法代碼示例。如果您正苦於以下問題:Python cv2.KalmanFilter方法的具體用法?Python cv2.KalmanFilter怎麽用?Python cv2.KalmanFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cv2的用法示例。


在下文中一共展示了cv2.KalmanFilter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: myKalman

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import KalmanFilter [as 別名]
def myKalman(tid):
    if tid not in workers:
        kalman = cv2.KalmanFilter(4, 2) # 4:狀態數,包括(x,y,dx,dy)坐標及速度(每次移動的距離);2:觀測量,能看到的是坐標值
        kalman.measurementMatrix = np.array([[1, 0, 0, 0], [0, 1, 0, 0]], np.float32) # 係統測量矩陣
        kalman.transitionMatrix = np.array([[1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]], np.float32) # 狀態轉移矩陣
        kalman.processNoiseCov = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]], np.float32)*0.03 # 係統過程噪聲協方差
        KalmanNmae[tid] = kalman 
開發者ID:lyk19940625,項目名稱:WorkControl,代碼行數:9,代碼來源:utils.py

示例2: create_kalman

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import KalmanFilter [as 別名]
def create_kalman(self):
    """Creates kalman filter."""

    kalman = cv2.KalmanFilter(4, 2)
    kalman.measurementMatrix = np.array([[1, 0, 0, 0], [0, 1, 0, 0]],
                                        np.float32)

    kalman.transitionMatrix = np.array(
        [[1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]], np.float32)

    kalman.processNoiseCov = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],
                                       [0, 0, 0, 1]], np.float32) * 0.03
    self.kalman = kalman
    self.measurement = np.array((2, 1), np.float32)
    self.prediction = np.zeros((2, 1), np.float32) 
開發者ID:google,項目名稱:automl-video-ondevice,代碼行數:17,代碼來源:camshift_object_tracker.py

示例3: __init__

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import KalmanFilter [as 別名]
def __init__(self,
                 state_num=4,
                 measure_num=2,
                 cov_process=0.0001,
                 cov_measure=0.1):
        """Initialization"""
        # Currently we only support scalar and point, so check user input first.
        assert state_num == 4 or state_num == 2, "Only scalar and point supported, Check state_num please."

        # Store the parameters.
        self.state_num = state_num
        self.measure_num = measure_num

        # The filter itself.
        self.filter = cv2.KalmanFilter(state_num, measure_num, 0)

        # Store the state.
        self.state = np.zeros((state_num, 1), dtype=np.float32)

        # Store the measurement result.
        self.measurement = np.array((measure_num, 1), np.float32)

        # Store the prediction.
        self.prediction = np.zeros((state_num, 1), np.float32)

        # Kalman parameters setup for scalar.
        if self.measure_num == 1:
            self.filter.transitionMatrix = np.array([[1, 1],
                                                     [0, 1]], np.float32)

            self.filter.measurementMatrix = np.array([[1, 1]], np.float32)

            self.filter.processNoiseCov = np.array([[1, 0],
                                                    [0, 1]], np.float32) * cov_process

            self.filter.measurementNoiseCov = np.array(
                [[1]], np.float32) * cov_measure

        # Kalman parameters setup for point.
        if self.measure_num == 2:
            self.filter.transitionMatrix = np.array([[1, 0, 1, 0],
                                                     [0, 1, 0, 1],
                                                     [0, 0, 1, 0],
                                                     [0, 0, 0, 1]], np.float32)

            self.filter.measurementMatrix = np.array([[1, 0, 0, 0],
                                                      [0, 1, 0, 0]], np.float32)

            self.filter.processNoiseCov = np.array([[1, 0, 0, 0],
                                                    [0, 1, 0, 0],
                                                    [0, 0, 1, 0],
                                                    [0, 0, 0, 1]], np.float32) * cov_process

            self.filter.measurementNoiseCov = np.array([[1, 0],
                                                        [0, 1]], np.float32) * cov_measure 
開發者ID:kwea123,項目名稱:VTuber_Unity,代碼行數:57,代碼來源:stabilizer.py


注:本文中的cv2.KalmanFilter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。