MOSSE跟踪算法源码解析

本文简单解析了MOSSE跟踪算法的源码,包括divDFTs、preProcess、correlate、randWarp、initImpl和updateImpl等关键函数。divDFTs实现复数Mat相除;preProcess进行图像预处理,如对数转换、归一化和余弦窗函数应用;correlate执行卷积并更新目标位置;randWarp实现图像随机仿射变换;initImpl初始化算法参数;updateImpl则根据新中心点更新参数。
摘要由CSDN通过智能技术生成

MOSSE算法源码简单解析

 

源码

如下:

// This file ispart of the OpenCV project. 
// It is subject to the license terms in the LICENSEfile found in the top-level directory 
// of this distribution and athttp://opencv.org/license.html. 
 
// 
//[1] David S. Bolme et al. "Visual Object Trackingusing Adaptive Correlation Filters" 
//   http://www.cs.colostate.edu/~draper/papers/bolme_cvpr10.pdf 
// 
 
// 
// credits: 
// Kun-Hsin Chen: for initial c++ code 
// Cracki: for the idea of only converting the usedpatch to gray 
// 
 
#include "opencv2/tracking.hpp" 
 
namespace cv { 
namespace tracking { 
 
struct DummyModel :TrackerModel 
{ 
     virtual void modelUpdateImpl(){} 
     virtual void modelEstimationImpl( const std::vector<Mat>& ){} 
}; 
 
 
const double eps=0.00001;      // fornormalization 
const double rate=0.2;         //learning rate 
const double psrThreshold=5.7; //no detection, if PSR is smaller than this 
 
 
struct MosseImpl :TrackerMOSSE 
{ 
protected: 
 
    Point2d center;//center of the bounding box 
    Size size;      //size ofthe bounding box 
    Mat hanWin; 
    Mat G;          //goal 
    Mat H, A,B;    //state
 
    //  Element-wisedivision of complex numbers in src1 and src2 
    Mat divDFTs( const Mat &src1, const Mat &src2 ) const 
    { 
        Mat c1[2],c2[2],a1,a2,s1,s2,denom,re,im; 
 
        // split into re and im per src 
       cv::split(src1, c1); 
       cv::split(src2, c2); 
 
        // (Re2*Re2 + Im2*Im2) = denom 
        //   denom is same forboth channels 
       cv::multiply(c2[0], c2[0], s1); 
       cv::multiply(c2[1], c2[1], s2); 
        cv::add(s1,s2, denom); 
 
        // (Re1*Re2 + Im1*Im1)/(Re2*Re2 + Im2*Im2) = Re 
       cv::multiply(c1[0], c2[0], a1); 
       cv::multiply(c1[1], c2[1], a2); 
       cv::divide(a1+
  • 1
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值