我正在尝试使用速度加速模型实现基于卡尔曼滤波器的鼠标跟踪(首先作为测试).
我想试试这个简单的模型,我的状态转移方程是:
X(k) = [x(k), y(k)]' (Position)
V(k) = [vx(k), vy(k)]' (Velocity)
X(k) = X(k-1) + dt*V(k-1) + 0.5*dt*dt*a(k-1)
V(k) = V(k-1) + t*a(k-1)
a(k) = a(k-1)
Run Code Online (Sandbox Code Playgroud)
使用这个我基本上写下了以下代码:
#include <iostream>
#include <vector>
#include <cstdio>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/tracking.hpp>
using namespace cv;
using namespace std;
struct mouse_info_struct { int x,y; };
struct mouse_info_struct mouse_info = {-1,-1}, last_mouse;
void on_mouse(int event, int x, int y, int flags, void* param)
{
//if (event == CV_EVENT_LBUTTONUP)
{
last_mouse = mouse_info;
mouse_info.x = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 gstreamer 将网络摄像头的流保存为一系列图像。到目前为止我已经写了这段代码......
#!/usr/bin/python
import sys, os
import pygtk, gtk, gobject
import pygst
pygst.require("0.10")
import gst
def __init__(self):
#....
# Code to create a gtk Window
#....
self.player = gst.Pipeline("player")
source = gst.element_factory_make("v4l2src", "video-source")
sink = gst.element_factory_make("xvimagesink", "video-output")
caps = gst.Caps("video/x-raw-yuv, width=640, height=480")
filter = gst.element_factory_make("capsfilter", "filter")
filter.set_property("caps", caps)
self.player.add(source, filter, sink)
gst.element_link_many(source, filter, sink)
Run Code Online (Sandbox Code Playgroud)
之后,我尝试通过总线创建一个信号来侦听来自源或接收器的任何消息,以指示已发送或接收新帧,以便可以保存它。
bus = self.player.get_bus()
bus.add_signal_watch()
bus.connect("message::any", self.save_file,"Save file")
Run Code Online (Sandbox Code Playgroud)
其中 save_file 是我的回调,我要在其中保存文件。
def save_file(self, bus, msg):
print "SAVED A NEW FILE"
Run Code Online (Sandbox Code Playgroud)
我有两个问题,
更新(2012 …