卡尔曼滤波之Opencv(二)

本文探讨了卡尔曼滤波在目标跟踪中的应用,并详细研究了OpenCV库中卡尔曼滤波器的源代码。通过分析提供的示例代码,加深了对卡尔曼滤波原理的理解。
摘要由CSDN通过智能技术生成

今天研究了一下卡尔曼滤波跟踪,同时也看了一下卡尔曼滤波Opencv的源代码,总是看懂了,具体原理可以看看【1】。下面是opencv自带的一个程序,代码如下:

// kalman.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"


#include "opencv2/video/tracking.hpp"
#include "opencv2/highgui/highgui.hpp"

#include <stdio.h>

using namespace cv;

static inline Point calcPoint(Point2f center, double R, double angle)
{
    return center + Point2f((float)cos(angle), (float)-sin(angle))*(float)R;
}

static void help()
{
    printf( "\nExamle of c calls to OpenCV's Kalman filter.\n"
"   Tracking of rotating point.\n"
"   Rotation speed is constant.\n"
"   Both state and measurements vectors are 1D (a point angle),\n"
"   Measurement is the real point angle + gaussian noise.\n"
"   The real and the estimated points are connected with yellow line segment,\n"
"   the real and the measured points are connected with red line segment.\n"
"   (if Kalman filter works correctly,\n"
"    the yellow segment should be shorter than the red one).\n"
            "\n"
"   Pressing any key (except ESC) will reset the tracking with a different speed.\n"
"   Pressing ESC will stop the program.\n"
            );
}

int main(int, char**)
{
    help();
    Mat img(500, 500, CV_8UC3);
    KalmanFilter KF(2, 1, 0);
	//[x1,x2]=[角度,角速度]
	/*
	运动模型:x1(k+1) = x1(k) + x2(k)*T
	         x2(k+1) = x2(k)
	状态转移方程:
	x^ = AX + w
	测量方程
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值