/* ----------------------------------------------------------------------------- * Detection (FAKE) */ void SampleDetector::detect( const Mat& rgb, const Mat& depth, Objects& objects, int FLAGS ) { objects.clear(); // Set a bounding box of a FAKE detection Object detection; detection.m_bb.x = 100 + (rand() % 20); detection.m_bb.y = 100 + (rand() % 20); detection.m_bb.width = 100 + (rand() % 5); detection.m_bb.height = 100 + (rand() % 5); detection.m_pos_2D.x = detection.m_bb.x + (detection.m_bb.width / 2); detection.m_pos_2D.y = detection.m_bb.y + (detection.m_bb.height / 2); detection.m_class = unknown; detection.m_score = 0; detection.m_angle = 0; detection.m_mask = Mat(cvSize(0, 0), CV_8U); detection.m_timestamp = 0; detection.m_speed = cv::Point3f(0,0,0); objects.push_back(detection); }
ObjectLayer::Objects ObjectLayer::get_selection(const CL_Rectf& rect) { Objects selection; for(Objects::iterator i = impl->objects.begin(); i != impl->objects.end(); ++i) { // FIXME: if (rect.is_inside((*i).get_pos())) { selection.push_back(*i); } } return selection; }
TimelineLayer::Objects TimelineLayer::get_objects(float selection_start, float selection_end) const { assert(selection_start <= selection_end); Objects objects; for(const_iterator i = begin(); i != end(); ++i) { if (selection_start <= (*i)->get_pos() && selection_end > (*i)->get_pos() + (*i)->get_width()) { objects.push_back(*i); } } return objects; }
// NOTE: This is really not at all efficient. However, since there's only a // small number of objects, it should matter. We really do need a stable // sort, though, so Common::sort() is out. SEQFile::Objects SEQFile::getOrderedObjects() { int16 minOrder = (int16)0x7FFF; int16 maxOrder = (int16)0x8000; Objects objects; // Find the span of order values for (uint i = 0; i < kObjectCount; i++) { if (!_objects[i].object) continue; minOrder = MIN(minOrder, _objects[i].order); maxOrder = MAX(maxOrder, _objects[i].order); } // Stably sort the objects by order value for (int16 o = minOrder; o <= maxOrder; o++) for (uint i = 0; i < kObjectCount; i++) if (_objects[i].object && (_objects[i].order == o)) objects.push_back(_objects[i]); return objects; }
PtrTracer(const ManagedHeap& heap) { // сформировать список объектов objects.reserve(heap.allocations.size()); for(Allocations::const_iterator i = heap.allocations.begin(); i != heap.allocations.end(); ++i) objects.push_back(Object(i->first, i->second.size, i->second.info)); std::sort(objects.begin(), objects.end(), sorter); // сформировать карту ссылок for(Ptrs::const_iterator i = heap.ptrs.begin(); i != heap.ptrs.end(); ++i) { // найти объект, в котором содержится указатель Objects::const_iterator j = std::upper_bound(objects.begin(), objects.end(), i->first, sorter); if(j > objects.begin()) { --j; if((size_t)((char*)i->first - (char*)j->data) < j->size) // да, указатель содержится в этом объекте // получить объект, на который указывает указатель, и добавить ссылку links.insert(std::make_pair(j, std::lower_bound(objects.begin(), objects.end(), i->second, sorter))); } } }
T* keep(T* t) { objects.push_back(t); return t; }