void singleObjectTracker::predict(trackingObjectFeature &of){
    of.Circularity=this->feature->Circularity;
    of.Convexity=this->feature->Convexity;
    of.Inertia=feature->Inertia;
    of.onBoundary=feature->onBoundary;
    of.pos=KF.GetPrediction();
    Rect_t r=feature->rect;
    Point_t dif=(2*of.pos-(r.br()+r.tl()));
    dif.x*=0.5f;
    dif.y*=0.5f;
    Point_t tl=r.tl()+dif;
    of.rect=Rect_t(tl.x,tl.y,r.width,r.height);
    of.radius=feature->radius;
    of.size=feature->size;
}
void singleObjectTracker::MissUpdate(int frameNum)
{
    KF.GetPrediction();
    prediction = KF.Update(Point_t(0,0),false);
    if(AvoidUpdate){
        AvoidUpdate=false;
        return;
    }

    status=MISSING_STATUS;
    vec_status.push_back(status);
    frames.push_back(frameNum);
    skipped_frames++;
    Rect_t lastRect=rects.back();
    Point_t diff=prediction-feature->pos;
    // may out of image range!
    rects.push_back(Rect_t(lastRect.x+diff.x,lastRect.y+diff.y,lastRect.width,lastRect.height));

    trace.push_back(prediction);
    lifetime++;
//    lastSeePos=of.pos;
    assert(lifetime==1+frameNum-frames[0]);
    assert(lifetime==(catch_frames+skipped_frames));
}
Ejemplo n.º 3
0
#include "Bullet.h"

static Physic_Info BulletInfo = {Rect_t(0, 0, 4, 4), 3.14f/2};

Bullet::Bullet(Vec2 place, float angle, Bullet_Info* info) :
	Entity_Base(place, info)
{
	m_textureID = 3;
	m_velocity = 5000;
	
	Vec2 vel = Vec2(-m_velocity * sin(angle), m_velocity * cos(angle));

	m_body->setLinearVelocity(vel);
	m_body->setAngle(angle + 3.14f);
}
Rect_t singleObjectTracker::GetPredictRect()
{
    Rect_t lastRect=rects.back();
    Point_t diff=prediction-feature->pos;
    return Rect_t(lastRect.x+diff.x,lastRect.y+diff.y,lastRect.width,lastRect.height);
}