void * AsioHandlerCache::allocate(std::size_t size)
    {
        //return malloc(size);


        VecPtr vecPtr;
        Lock lock(mHandlerMutex);
        if (mHandlerFreeList.empty())
        {
            vecPtr.reset( new std::vector<char>(size) );
        }
        else
        {
            vecPtr = mHandlerFreeList.back();
            mHandlerFreeList.pop_back();
        }

        if (vecPtr->size() != size)
        {
            vecPtr->resize(size);
        }

        mHandlerUsedList.push_back(vecPtr);
        return & (*vecPtr)[0];
    }
Exemplo n.º 2
0
void IMFT<Ptr>::updatePtrsInLastFrame(VecPtr ptrs)
{
    for(ListGraph::NodeIt n(m_g); n != INVALID; ++n){
       if((*m_gNodeMap)[n].nFrame == cnt){
           for(int j=0;j<ptrs.size();j++){
               if((*m_gNodeMap)[n].ptr.id = ptrs.at(j).id)
                   (*m_gNodeMap)[n].ptr = ptrs.at(j);
           }
       }
    }
}
Exemplo n.º 3
0
void IMFT<Ptr>::addToDGraph(VecPtr ptrs)
{
    // save old edges
    m_vecOldEdge.clear();
    for(ListGraph::EdgeIt e(m_g); e != INVALID; ++e){
        m_vecOldEdge.push_back(m_g.id(e));
    }

    // making nodes
    for(int i=0;i<ptrs.size();i++){
        // inNode
        ListGraph::Node xi = m_g.addNode();
        V vi;
        vi.id = m_g.id(xi);
        vi.isIn = 1;
        vi.ptr = ptrs[i];
        vi.nFrame = cnt;
        vi.edgeID = -1;
        vi.isTrack = 0;
        vi.nTrack = 0;
        (*m_gNodeMap)[xi] = vi;

        // outNode
        ListGraph::Node xo = m_g.addNode();
        V vo;
        vo.id = m_g.id(xo);
        vo.isIn = 0;
        vo.ptr = ptrs[i];
        vo.nFrame = cnt;
        vo.edgeID = -1;
        vo.isTrack = 0;
        vo.nTrack = 0;
        (*m_gNodeMap)[xo] = vo;

        // connection to previous nodes
        for(ListGraph::NodeIt n(m_g); n != INVALID; ++n){
            if((*m_gNodeMap)[n].nFrame != vi.nFrame && !(*m_gNodeMap)[n].isIn){
                //                double weight = gain((*m_gNodeMap)[n], vi);
                double weight = gain((*m_gNodeMap)[m_g.nodeFromId(m_g.id(n)-1)], vi);

                //                m_g.nodeFromId(m_g.id((*m_gNodeMap)[n])-1);

                (*m_gEdgeMap)[m_g.addEdge(n,xi)] = weight;

                //                ListGraph::Edge e = m_g.addEdge(n,xi);
                //                (*m_gEdgeMap)[e] = weight;
                //                (*m_gNodeMap)[m_g.u(e)].edgeID = m_g.id(e);
                //                (*m_gNodeMap)[m_g.v(e)].edgeID = m_g.id(e);

            }
        }
    }
}
Exemplo n.º 4
0
void IMFT<Ptr>::setFrame(VecPtr ptrs)
{
    cnt++;
    if(m_isDebug)
        std::cout << "||CNT : " << cnt << " || # of objects : " << ptrs.size() << " || # of tracks : " << m_tracks.size() << " ||" <<std::endl;
    if(cnt > m_nWindow) movingWindow();
    addToDGraph(ptrs);
    tracking();
    if(cnt == m_nWindow) {
        backtracking();
        makeTracks();
    }
    else if(cnt > m_nWindow){
        trackUpdate();
//        setCurrentFrame(cnt);
    }

    setCurrentFrame(cnt);
    confirmDGraph();
}