Python cv2.KalmanFilter() Examples
The following are 8
code examples of cv2.KalmanFilter().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cv2
, or try the search function
.
Example #1
Source File: camshift_object_tracker.py From automl-video-ondevice with Apache License 2.0 | 5 votes |
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)
Example #2
Source File: utils.py From WorkControl with Apache License 2.0 | 5 votes |
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
Example #3
Source File: myrun.py From WorkControl with Apache License 2.0 | 5 votes |
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
Example #4
Source File: mytest1.py From WorkControl with Apache License 2.0 | 5 votes |
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
Example #5
Source File: stabilizer.py From VTuber_Unity with MIT License | 4 votes |
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
Example #6
Source File: kalman_filter.py From face_landmark_dnn with MIT License | 4 votes |
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
Example #7
Source File: stabilizer.py From head-pose-estimation with MIT License | 4 votes |
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
Example #8
Source File: stabilizer.py From PINTO_model_zoo with MIT License | 4 votes |
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