int main(int argc, char** argv) { try { if (argc == 2) { const std::vector<std::string>& files = Rar::get_filenames(argv[1]); for(std::vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i) { std::cout << "File: '" << *i << "'" << std::endl; } } else if (argc == 3) { BlobPtr blob = Rar::get_file(argv[1], argv[2]); blob->write_to_file("/tmp/out.file"); std::cout << "Writting /tmp/out.file" << std::endl; } else { std::cout << "Usage: " << argv[0] << " RARFILE" << std::endl; std::cout << " " << argv[0] << " RARFILE FILETOEXTRACT" << std::endl; } } catch(std::exception& err) { std::cout << "Error: " << err.what() << std::endl; } return 0; }
TouchEvent::TouchEvent(int id, Type eventType, BlobPtr pBlob, const IntPoint& pos, Source source, const glm::vec2& speed) : CursorEvent(id, eventType, pos, source), m_pBlob(pBlob), m_bHasHandOrientation(false) { setSpeed(speed); if (pBlob) { m_Orientation = pBlob->getOrientation(); m_Area = pBlob->getArea(); m_Center = pBlob->getCenter(); m_Eccentricity = pBlob->getEccentricity(); const glm::vec2& axis0 = m_pBlob->getScaledBasis(0); const glm::vec2& axis1 = m_pBlob->getScaledBasis(1); if (glm::length(axis0) > glm::length(axis1)) { m_MajorAxis = axis0; m_MinorAxis = axis1; } else { m_MajorAxis = axis1; m_MinorAxis = axis0; } } else { m_Orientation = 0; m_Area = 20; m_Center = glm::vec2(0, 0); m_Eccentricity = 0; m_MajorAxis = glm::vec2(5, 0); m_MinorAxis = glm::vec2(0, 5); } }
/*! Adjusts the stochastic model state on the basis of the given measurement of the model state. m is usually equal to get_last_feature(). @see Perform_Kalman_Filtering() */ void Trace::Correct_Kalman_Filter(BlobPtr m) { CvMat* z = cvCreateMat(1,1,CV_32FC1); //Centroid cvmSet(z,0,0,m->centroid().x); cvKalmanCorrect(m_filtFeature.centroid.x, z); cvmSet(z,0,0,m->centroid().y); cvKalmanCorrect(m_filtFeature.centroid.y, z); //Size cvmSet(z,0,0,m->size()); cvKalmanCorrect(m_filtFeature.size, z); //Width cvmSet(z,0,0,m->width()); cvKalmanCorrect(m_filtFeature.width, z); //Height cvmSet(z,0,0,m->height()); cvKalmanCorrect(m_filtFeature.height, z); //Color histogram for (int i=0; i<Blob::HISTO_SIZE; i++) { cvmSet(z,0,0,m->m_color_histogram[i]); cvKalmanCorrect(m_filtFeature.color_histogram[i], z); } cvReleaseMat(&z); }
bool TrackerThread::isRelevant(BlobPtr pBlob, int minArea, int maxArea, float minEccentricity, float maxEccentricity) { bool res; res = isInbetween(pBlob->getArea(), float(minArea), float(maxArea)) && isInbetween(pBlob->getEccentricity(), minEccentricity, maxEccentricity); return res; }
void Trace::add_path_node(BlobPtr feature) { if (!m_nodes.empty()) m_displacement += (m_nodes.back()->centroid() - feature->centroid()).Norm(); /*BlobPtr measured_point(new Blob(*feature)); m_nodes.push_back(measured_point);*/ m_nodes.push_back(feature); #ifdef SMOOTH_TRACES_ONLINE if (get_length() == KALMAN_START_LENGTH) Initialize_Kalman_Filter(); #else if (m_x_range.min > feature->centroid().x) m_x_range.min = feature->centroid().x; if (m_x_range.max < feature->centroid().x) m_x_range.max = feature->centroid().x; if (m_y_range.min > feature->centroid().y) m_y_range.min = feature->centroid().y; if (m_y_range.max < feature->centroid().y) m_y_range.max = feature->centroid().y; #endif }
bool Trace::is_blob_close(BlobPtr blob) { XYCoord A, B; bool boxes_overlap(XYCoord A, XYCoord B, XYCoord a, XYCoord b); get_matching_region(A, B); //cout << "Matching region for trace " << m_id << //" = [" << A.x << "," << A.y << "] [" << B.x << "," << B.y << "]" << endl; return boxes_overlap(A, B, blob->ul(), blob->br()); }
bool f_contains_g(BlobPtr f, BlobPtr g) { return (f && g && (f->ul().x < g->ul().x) && (f->br().x > g->br().x) && (f->ul().y < g->ul().y) && (f->br().y > g->br().y)); }
void TrackerThread::correlateHands(BlobVectorPtr pTrackBlobs, BlobVectorPtr pTouchBlobs) { if (!pTrackBlobs || !pTouchBlobs) { return; } for (BlobVector::iterator it1 = pTouchBlobs->begin(); it1 != pTouchBlobs->end(); ++it1) { BlobPtr pTouchBlob = *it1; IntPoint touchCenter = (IntPoint)(pTouchBlob->getCenter()); for (BlobVector::iterator it2 = pTrackBlobs->begin(); it2 != pTrackBlobs->end(); ++it2) { BlobPtr pTrackBlob = *it2; if (pTrackBlob->contains(touchCenter)) { pTouchBlob->addRelated(pTrackBlob); pTrackBlob->addRelated(pTouchBlob); break; } } } }
void Trace::SaveChangesToDatabase(vpl::BlobTrackerDBManager& dbm, int target_id) { ASSERT(dbm.hasDB()); if (m_dbID < 0) { m_dbID = dbm.createTrace(m_id, start_time(), get_first_frame(), target_id); if (m_dbID < 0) { ShowError("Cannot save target to database"); return; } } for (; m_numFeaturesSaved < m_nodes.size(); m_numFeaturesSaved++) { BlobPtr f = m_nodes[m_numFeaturesSaved]; dbm.createTraceNode((int)f->centroid().x, (int)f->centroid().y, f->height(), f->width(), f->timestamp(), m_numFeaturesSaved, m_dbID); } }
bool blob_features_are_equal(BlobPtr f, BlobPtr g) { return (f && g &&(f->ul() == g->ul()) &&(f->br() == g->br())); }