示例#1
0
void SVMformat::bowExtractor(Mat img, Mat mask)
{
	Ptr<DescriptorMatcher> matcher(new FlannBasedMatcher);		//KNN
	vector<KeyPoint> cornor; 
	int minHessian = 400; //SURF Hessian Threshold
	Ptr<FeatureDetector> detector(new SurfFeatureDetector());
	Ptr<DescriptorExtractor> extractor(new SurfDescriptorExtractor(minHessian,4,2,false));
	
	BOWImgDescriptorExtractor bowDE(extractor,matcher);
	bowDE.setVocabulary(dictionary);
	Mat bowDescriptor;	
	
	detector->detect(img, cornor, mask);		
	if(cornor.size() < 10)
		return;

	bowDE.compute(img, cornor, bowDescriptor);	
	bowDescriptor = bowDescriptor*100;
	bowDescSet.push_back(bowDescriptor);	//have to convert to CV_8U before training	
}
示例#2
0
文件: regex.cpp 项目: RedSnapper/Obyx
	bool Regex::fullmatch(const string &pattern, const string &scope) {     //match entire string using pcre
		bool retval = false;
		if ( pattern.empty() ) {
			retval = scope.empty() ? true : false;
		} else {
			int* ov;		// size must be a multiple of 3.
			int ovc = 90;  // size of ovector
			ov = new int[ovc];
			size_t result = matcher(pattern, scope, 0, ov, ovc);
			if (result > 0 ) {  //at least one match was found.
				size_t matchstart = ov[0];
				size_t matchend = ov[1];
				if (matchstart == 0 && matchend == scope.length() ) { 
					retval = true;
				}
			}
			delete [] ov;
		}
		return retval;
	}
示例#3
0
 void run() {
     client().ensureIndex( ns(), BSON( "a.b" << 1 ) );
     client().insert( ns(), fromjson( "{ a:[ {}, { b:9 }, { b:1 } ] }" ) );
     
     Client::Transaction transaction(DB_SERIALIZABLE);
     Client::ReadContext context( ns(), mongo::unittest::EMPTY_STRING );
     
     BSONObj query = BSON( "a.b" << 1 );
     CoveredIndexMatcher matcher( query, BSON( "a.b" << 1 ) );
     MatchDetails details;
     details.requestElemMatchKey();
     boost::shared_ptr<Cursor> cursor = getOptimizedCursor( ns(), query );
     // Verify that the cursor is indexed.
     ASSERT_EQUALS( "IndexCursor a.b_1", cursor->toString() );
     ASSERT( matcher.matchesCurrent( cursor.get(), &details ) );
     // The '2' entry of the 'a' array is matched.
     ASSERT( details.hasElemMatchKey() );
     ASSERT_EQUALS( string( "2" ), details.elemMatchKey() );
     transaction.commit();
 }
 void run() {
     client().ensureIndex( ns(), BSON( "a.b" << 1 ) );
     client().insert( ns(), fromjson( "{ a:[ { b:1 } ] }" ) );
     
     Client::ReadContext context( ns() );
     
     BSONObj query = BSON( "a.b" << 1 );
     CoveredIndexMatcher matcher( query, BSON( "a.b" << 1 ) );
     MatchDetails details;
     details.requestElemMatchKey();
     boost::shared_ptr<Cursor> cursor = NamespaceDetailsTransient::getCursor( ns(), query );
     // Verify that the cursor is indexed.
     ASSERT_EQUALS( "BtreeCursor a.b_1", cursor->toString() );
     // Verify that the cursor is not multikey.
     ASSERT( !cursor->isMultiKey() );
     ASSERT( matcher.matchesCurrent( cursor.get(), &details ) );
     // The '0' entry of the 'a' array is matched.
     ASSERT( details.hasElemMatchKey() );
     ASSERT_EQUALS( string( "0" ), details.elemMatchKey() );
 }
示例#5
0
  void matchORB(string image1, string image2)
  {
    Mat img1 = imread(image1,IMREAD_GRAYSCALE);
    Mat img2 = imread(image2,IMREAD_GRAYSCALE);
    namedWindow("ima1", WINDOW_AUTOSIZE);
    namedWindow("ima2", WINDOW_AUTOSIZE);
    imshow("ima1", img1);
    imshow("ima2", img2);
    
    if(img1.empty() || img2.empty())
    {
        printf("Can't load all the images!");
        return;
    }   

  //Initialise the Wrapping Class for Surf()
    ORB detector_extractor;
    //Ptr<FeatureDetector> detector = FeatureDetector::create("SURF");
    vector<KeyPoint> keypoints1, keypoints2;
    detector_extractor.detect(img1, keypoints1);
    detector_extractor.detect(img2, keypoints2);

  // computing descriptors
    //Ptr<DescriptorExtractor> extractor = DescriptorExtractor::create("SURF");
    Mat descriptors1, descriptors2;
    detector_extractor.compute(img1, keypoints1, descriptors1);
    detector_extractor.compute(img2, keypoints2, descriptors2);

  //Initialise BruteForceMatcher: For each descriptor in the first set, this matcher finds the closest descriptor in the second set by trying each on (=brute)
    BFMatcher matcher(NORM_L2);
    vector< DMatch > matches;
    matcher.match(descriptors1, descriptors2, matches);

  // drawing the results
    namedWindow("matches", 1);
    Mat img_matches;
    drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches);
    imshow("matches", img_matches);

    waitKey(0);
  }
U_CFUNC int32_t 
getAt(const UChar* source, int32_t srcLen,
        UChar** dest, int32_t destCapacity,
        int32_t index,
        UParseCommentsOption option,
        UErrorCode* status){

    if(status == NULL || U_FAILURE(*status)){
        return 0;
    }

    UnicodeString     stringArray[MAX_SPLIT_STRINGS];
    RegexPattern      *pattern = RegexPattern::compile(UnicodeString("@"), UREGEX_MULTILINE, *status);
    UnicodeString src (source, srcLen);


    if (U_FAILURE(*status)) {
        return 0;
    }
    int32_t retLen = pattern->split(src, stringArray, MAX_SPLIT_STRINGS, *status);
    
    UnicodeString patternString(patternStrings[option]);
    RegexMatcher matcher(patternString, UREGEX_DOTALL, *status);
    if (U_FAILURE(*status)) {
        return 0;
    } 
    int32_t count = 0;
    for(int32_t i=0; i<retLen; i++){
        matcher.reset(stringArray[i]);
        if(matcher.lookingAt(*status)){
            if(count == index){
                UnicodeString out = matcher.group(1, *status);
                return out.extract(*dest, destCapacity,*status);
            }
            count++;
            
        }
    }
    return 0;

}
示例#7
0
    void wt::PageIterator::loadPage() {
        this->piece.set(this->position);

        if(this->piece.length() <= 1) {
            this->good = false;
            return;
        }

        icu::UnicodeString line = icu::UnicodeString::fromUTF8(this->piece);

        UErrorCode status = U_ZERO_ERROR;
        icu::RegexMatcher matcher(
            icu::UnicodeString("^\\R?(.*?) (?:#|->)"),
            line,
            0,
            status);

        matcher.find();

        this->page.title = matcher.group(1, status);
    }
示例#8
0
文件: node.c 项目: midendian/timps
/*
 * Also annoying to export, for same reason as gnr_node_find().
 */
void gnr_node_offline_many(struct nafmodule *mod, int (*matcher)(struct nafmodule *, struct gnrnode *, const void *), const void *data, int reason)
{
	int idx;

	if (!matcher)
		return;

	for (idx = 0; idx < GNR_NODE_HASH_SIZE; idx++) {
		struct gnrnode *cur, **prev;

		for (prev = &gnr__nodehash[idx]; (cur = *prev); ) {

			if (matcher(mod, cur, data)) {
				*prev = cur->next;
				freenode(cur, reason);
			} else
				prev = &cur->next;
		}
	}

	return;
}
示例#9
0
bool CvFeature::findHomography(const CvFeature &dst, cv::Mat &homography_mat, const double &min_distance_threshold, const double &matches_distance_threshold, const int &matches_count_threshold)
{
	if (dst.descriptors().empty()) return false;

	homography_mat.release();

	std::vector<cv::DMatch> matches;
	std::vector<cv::DMatch> good_matches;
	std::vector<cv::DMatch>::iterator it;

	cv::BFMatcher matcher(cv::NORM_L2);

	matcher.match(this->descriptors(), dst.descriptors(), matches);

	double min_d = DBL_MAX;
	for (it = matches.begin(); it != matches.end(); ++it) {
	    double d = it->distance;
	    if (d < min_d) min_d = d;
	}

	if (min_d > min_distance_threshold) return false;
 
	for (it = matches.begin(); it != matches.end(); ++it) {
		if (it->distance <= min_d * matches_distance_threshold) good_matches.push_back(*it);
	}

	if (good_matches.size() < (unsigned int)matches_count_threshold) return false;

	std::vector<cv::Point2f> src_ps;
	std::vector<cv::Point2f> dst_ps;
	for (it = good_matches.begin(); it != good_matches.end(); ++it) {
		src_ps.push_back(this->keypoints()[it->queryIdx].pt);		
		dst_ps.push_back(dst.keypoints()[it->trainIdx].pt);		
	}

	homography_mat = cv::findHomography(src_ps, dst_ps, cv::RANSAC);

	return true;
}
bool CachedRegexMatcher::addMatcher(const QString& pattern, const QVariant& result)
{
  QRegExp matcher(pattern);
  if (!matcher.isValid())
  {
    QLOG_WARN() << "Could not compile pattern:" << pattern;
    return false;
  }

  // Remove older mapping if it exists.
  if (!m_allowMultiplePatterns)
  {
    auto newEnd = std::remove_if(m_matcherList.begin(),m_matcherList.end(), [pattern](auto mp)
    {
      return mp.first.pattern() == pattern;
    });
    m_matcherList.erase(newEnd, m_matcherList.end());
  }

  m_matcherList.push_back(qMakePair(matcher, result));
  return true;
}
示例#11
0
bool MangoExact::matchBinary (Scanner &scanner, Scanner *xyz_scanner)
{
   CmfLoader loader(_context.cmf_dict, scanner);

   loader.loadMolecule(_target);
   if (xyz_scanner != 0)
      loader.loadXyz(*xyz_scanner);

   _initTarget(_target, true);
   /*
    * Set up timeout for matching
    */
   TimeoutCancellationHandler timeout(_context.timeout);
   AutoCancellationHandler auto_cancel(timeout);

   MoleculeExactMatcher matcher(_query, _target);

   matcher.flags = _flags;
   matcher.rms_threshold = _rms_threshold;

   return matcher.find();
}
Status ReplSetConfig::checkIfWriteConcernCanBeSatisfied(
    const WriteConcernOptions& writeConcern) const {
    if (!writeConcern.wMode.empty() && writeConcern.wMode != WriteConcernOptions::kMajority &&
        writeConcern.wMode != WriteConcernOptions::kInternalMajorityNoSnapshot) {
        StatusWith<ReplSetTagPattern> tagPatternStatus = findCustomWriteMode(writeConcern.wMode);
        if (!tagPatternStatus.isOK()) {
            return tagPatternStatus.getStatus();
        }

        ReplSetTagMatch matcher(tagPatternStatus.getValue());
        for (size_t j = 0; j < _members.size(); ++j) {
            const MemberConfig& memberConfig = _members[j];
            for (MemberConfig::TagIterator it = memberConfig.tagsBegin();
                 it != memberConfig.tagsEnd();
                 ++it) {
                if (matcher.update(*it)) {
                    return Status::OK();
                }
            }
        }
        // Even if all the nodes in the set had a given write it still would not satisfy this
        // write concern mode.
        return Status(ErrorCodes::UnsatisfiableWriteConcern,
                      str::stream() << "Not enough nodes match write concern mode \""
                                    << writeConcern.wMode
                                    << "\"");
    } else {
        int nodesRemaining = writeConcern.wNumNodes;
        for (size_t j = 0; j < _members.size(); ++j) {
            if (!_members[j].isArbiter()) {  // Only count data-bearing nodes
                --nodesRemaining;
                if (nodesRemaining <= 0) {
                    return Status::OK();
                }
            }
        }
        return Status(ErrorCodes::UnsatisfiableWriteConcern, "Not enough data-bearing nodes");
    }
}
示例#13
0
void Differ::computeTextHighlights(QPainterPath *highlighted1,
        QPainterPath *highlighted2, const PdfPage &page1,
        const PdfPage &page2, const int DPI)
{
    const bool ComparingWords = comparisonMode ==
                                CompareWords;
    QRectF rect1;
    QRectF rect2;
    QRectF rect;
    if (margins)
        rect = pointRectForMargins(page1->pageSize());
    const TextBoxList list1 = getTextBoxes(page1, rect);
    const TextBoxList list2 = getTextBoxes(page2, rect);
    TextItems items1 = ComparingWords ? getWords(list1)
                                      : getCharacters(list1);
    TextItems items2 = ComparingWords ? getWords(list2)
                                      : getCharacters(list2);
    const int ToleranceY = 10;
    if (debug >= DebugShowTexts) {
        const bool Yx = debug == DebugShowTextsAndYX;
        items1.debug(1, ToleranceY, ComparingWords, Yx);
        items2.debug(2, ToleranceY, ComparingWords, Yx);
    }

    SequenceMatcher matcher(items1.texts(), items2.texts());
    RangesPair rangesPair = computeRanges(&matcher);
    rangesPair = invertRanges(rangesPair.first, items1.count(),
                              rangesPair.second, items2.count());

    foreach (int index, rangesPair.first)
        addHighlighting(&rect1, highlighted1, items1.at(index).rect, DPI);
    if (!rect1.isNull() && !rangesPair.first.isEmpty())
        highlighted1->addRect(rect1);
    foreach (int index, rangesPair.second)
        addHighlighting(&rect2, highlighted2, items2.at(index).rect, DPI);
    if (!rect2.isNull() && !rangesPair.second.isEmpty())
        highlighted2->addRect(rect2);
}
示例#14
0
/* Since this skips INTERNAL, it is useful only for outside callers. */
nbio_fd_t *nbio_iter(nbio_t *nb, int (*matcher)(nbio_t *nb, void *ud, nbio_fd_t *fdt), void *userdata)
{
	nbio_fd_t *cur;

	if (!nb || !matcher) {
		errno = EINVAL;
		return NULL;
	}

	for (cur = (nbio_fd_t *)nb->fdlist; cur; cur = cur->next) {

		if (cur->flags & NBIO_FDT_FLAG_IGNORE)
			continue;
		if (cur->flags & NBIO_FDT_FLAG_INTERNAL)
			continue;

		if (matcher(nb, userdata, cur))
			return cur;

	}

	return NULL;
}
示例#15
0
文件: query.cpp 项目: igagnidz/tokumx
    bool queryByPKHack(Collection *cl, const BSONObj &pk,
                       const BSONObj &query, BSONObj &result,
                       ResultDetails *resDetails) {
        cc().curop()->debug().idhack = true;

        BSONObj obj;
        bool objMatches = true;
        const bool found = cl->findByPK(pk, obj);
        if (found) {
            // Only use a matcher for queries with more than just an _id
            // component. The _id was already 'matched' by the find.
            const bool singleQueryField = query.nFields() == 1; // TODO: Optimize?
            if (!singleQueryField) {
                Matcher matcher(query);
                objMatches = matcher.matches(obj, &resDetails->matchDetails);
            }
        }

        const bool ok = found && objMatches;
        cl->getPKIndex().noteQuery(ok ? 1 : 0, 0);
        result = ok ? obj : BSONObj();
        return ok;
    }
示例#16
0
 shared_ptr<Cursor> FindingStartCursor::getCursor( const char *ns, const BSONObj &query, const BSONObj &order ) {
     NamespaceDetails *d = nsdetails(ns);
     if ( !d ) {
         return shared_ptr<Cursor>( new BasicCursor( DiskLoc() ) );
     }
     FieldRangeSetPair frsp( ns, query );
     QueryPlan oplogPlan( d, -1, frsp, 0, query, order );
     FindingStartCursor finder( oplogPlan );
     ElapsedTracker yieldCondition( 256, 20 );
     while( !finder.done() ) {
         if ( yieldCondition.intervalHasElapsed() ) {
             if ( finder.prepareToYield() ) {
                 ClientCursor::staticYield( -1, ns, 0 );
                 finder.recoverFromYield();
             }
         }
         finder.next();
     }
     shared_ptr<Cursor> ret = finder.cursor();
     shared_ptr<CoveredIndexMatcher> matcher( new CoveredIndexMatcher( query, BSONObj() ) );
     ret->setMatcher( matcher );
     return ret;
 }
示例#17
0
bool stringListToPackageList(PackageList *packages, const QStringList &packagesIn,
							 QList<const Package *> &packagesOut, const Platform &host,
							 QStringList *alreadyInstalledPackagesOut, QString *notFoundPackage)
{
	PackageMatcher matcher(packages);
	packagesOut.clear();

	// captures expressions like this: <name>[/<version>][#<target>]
	// examples: qtbase/5.0.0#win32-g++
	//           qtjsbackend
	//           qtpim#linux-g++-32
	//           qtquick1/5.1.0
	QRegularExpression exp("([a-z0-9\\-_\\+]*)(/[a-z0-9\\-\\+\\.]*)?(#[a-z0-9\\-\\+]*)?");

	QRegularExpressionMatch match;

	InstalledPackages *installed = ConfigurationHandler::instance()->installedPackages();

	for (const QString &arg : packagesIn) {
		match = exp.match(arg);
		if (!match.hasMatch()) {
			if (notFoundPackage != 0) {
				*notFoundPackage = arg;
			}
			return false;
		}
		const QString id = match.captured(1);
		const QString version = match.captured(2).remove(0, 1);
		const Platform target = Platform::fromString(match.captured(3).remove(0, 1));
		if (alreadyInstalledPackagesOut != 0 && installed->isPackageInstalled(id, version, host, target)) {
			alreadyInstalledPackagesOut->append(arg);
			continue;
		}
		packagesOut.append(matcher.matchPackages(id, version, Platform(), target));
	}
	return true;
}
std::tuple<feature_stitch::keypoints, feature_stitch::keypoints, cv::Mat>
feature_stitch::match_keypoints(feature_stitch::keypoints const &kpts1, feature_stitch::keypoints const &kpts2,
                                cv::Mat const &descriptor1, cv::Mat const &descriptor2,
                                double ratio, double reproj_thresh) const
{
    using match_vec = std::vector<cv::DMatch>;

    //exhaustively compute euclidean distance between all feature vectors from both images
    //find the pairs of descriptors that have the smallest distance
    cv::BFMatcher matcher(cv::NORM_HAMMING);
    std::vector<match_vec> nn_matches;
    //top 2 matches because we need to apply David Lowe's ratio test
    matcher.knnMatch(descriptor1, descriptor2, nn_matches, 2);

    keypoints matches1, matches2;
    for(match_vec const &m : nn_matches){
        float const dist1 = m[0].distance;
        float const dist2 = m[1].distance;
        if(dist1 < ratio * dist2){
            matches1.emplace_back(kpts1[m[0].queryIdx]);
            matches2.emplace_back(kpts2[m[0].trainIdx]);
        }
    }    
    std::cout<<matches1[0].pt<<","<<matches2[0].pt<<std::endl;

    if(matches1.size() > 4){
        std::vector<cv::Point2f> points1, points2;
        for(size_t i = 0; i != matches1.size(); ++i){
            points1.emplace_back(matches1[i].pt);
            points2.emplace_back(matches2[i].pt);
        }
        cv::Mat hmat = cv::findHomography(points1, points2, cv::RANSAC, reproj_thresh);
        return std::make_tuple(std::move(matches1), std::move(matches2), std::move(hmat));
    }

    return {};
}
示例#19
0
文件: curop.cpp 项目: Axv2/mongo
    CurOp* CurOp::getOp(const BSONObj& criteria) {
        // Regarding Matcher: This is not quite the right hammer to use here.
        // Future: use an actual property of CurOp to flag index builds
        // and use that to filter.
        // This will probably need refactoring once we change index builds
        // to be a real command instead of an insert into system.indexes
        Matcher matcher(criteria);

        Client& me = cc();

        scoped_lock client_lock(Client::clientsMutex);
        for (std::set<Client*>::iterator it = Client::clients.begin();
             it != Client::clients.end();
             it++) {

            Client *client = *it;
            verify(client);

            CurOp* curop = client->curop();
            if (client == &me || curop == NULL) {
                continue;
            }

            if ( !curop->active() )
                continue;

            if ( curop->killPendingStrict() )
                continue;

            BSONObj info = curop->description();
            if (matcher.matches(info)) {
                return curop;
            }
        }

        return NULL;
    }
示例#20
0
 void run() {
     Matcher matcher( fromjson( "{ a:1, b:2, $and:[ { c:6, d:7 }, { n:12 } ],"
                               "$or:[ { e:8, l:10 } ], $nor:[ { f:9, m:11 } ],"
                               "g:{ $elemMatch:{ h:3 } },"
                               "i:{ $all:[ { $elemMatch:{ j:4 } },"
                               "{ $elemMatch:{ k:5 } } ] } }" ) );
     Visitor testVisitor;
     matcher.visit( testVisitor );
     BSONObj expectedTraversal = fromjson
             ( "{"
              "Matcher:[ 'a', 'b' ],"
              "ElementMatcher:{ a:1 },"
              "ElementMatcher:{ b:2 },"
              "ElementMatcher:{ g:{ h:3 } },"
              "ElementMatcher:{ i:{ $all:[ { $elemMatch:{ j:4 } },"
                     "{ $elemMatch:{ k:5 } } ] } },"
              "Matcher:[ 'h' ],"
              "ElementMatcher:{ h:3 },"
              "Matcher:[ 'j' ],"
              "ElementMatcher:{ j:4 },"
              "Matcher:[ 'k' ],"
              "ElementMatcher:{ k:5 },"
              "Matcher:[ 'c', 'd' ],"
              "ElementMatcher:{ c:6 },"
              "ElementMatcher:{ d:7 },"
              "Matcher:[ 'n' ],"
              "ElementMatcher:{ n:12 },"
              "Matcher:[ 'e', 'l' ],"
              "ElementMatcher:{ e:8 },"
              "ElementMatcher:{ l:10 },"
              "Matcher:[ 'f', 'm' ],"
              "ElementMatcher:{ f:9 },"
              "ElementMatcher:{ m:11 }"
              "}" );
     ASSERT_EQUALS( expectedTraversal, testVisitor.traversal() );
 }
	SInt32 GetEquippedItemId(Actor * thisActor, UInt32 slot)
	{
		enum
		{
			kSlotID_Left = 0,
			kSlotID_Right
		};

		if (!thisActor)
			return NULL;

		TESForm * equippedForm = thisActor->GetEquippedObject(slot == kSlotID_Left);
		if (!equippedForm)
			return 0;

		ExtraContainerChanges* containerChanges = static_cast<ExtraContainerChanges*>(thisActor->extraData.GetByType(kExtraData_ContainerChanges));
		if (!containerChanges)
			return 0;

		MatchByForm matcher(equippedForm);
		EquipData equipData = containerChanges->FindEquipped(matcher, slot == kSlotID_Right, slot == kSlotID_Left);

		return CalcItemId(equipData.pForm, equipData.pExtraData);
	}
示例#22
0
U_CFUNC int32_t
getCount(const UChar* source, int32_t srcLen, 
         UParseCommentsOption option, UErrorCode *status){
    
    if(status == NULL || U_FAILURE(*status)){
        return 0;
    }

    UnicodeString     stringArray[MAX_SPLIT_STRINGS];
    RegexPattern      *pattern = RegexPattern::compile(UnicodeString("@"), UREGEX_MULTILINE, *status);
    UnicodeString src (source, srcLen);


    if (U_FAILURE(*status)) {
        return 0;
    }
    int32_t retLen = pattern->split(src, stringArray, MAX_SPLIT_STRINGS, *status);
    
    UnicodeString patternString(patternStrings[option]);
    RegexMatcher matcher(patternString, UREGEX_DOTALL, *status);
    if (U_FAILURE(*status)) {
        return 0;
    } 
    int32_t count = 0;
    for(int32_t i=0; i<retLen; i++){
        matcher.reset(stringArray[i]);
        if(matcher.lookingAt(*status)){
            count++;
        }
    }
    if(option == UPC_TRANSLATE && count > 1){
        fprintf(stderr, "Multiple @translate tags cannot be supported.\n");
        exit(U_UNSUPPORTED_ERROR);
    }
    return count;
}
示例#23
0
    boost::shared_ptr<DynamicGlyphMatcherT> operator()(boost::shared_ptr<const TFontImage> font, const std::map<std::string, std::string>& options) const
    {
        size_t nfeatures = 10;
        if (options.count("nf")) {
            try {
                nfeatures = boost::lexical_cast<size_t>(options.find("nf")->second);
            } catch (boost::bad_lexical_cast&) { }
        }

        boost::shared_ptr<EigendecompositionT> decomposition(new EigendecompositionT(font));
        if (options.count("cache") && !options.find("cache")->second.empty()) {
            decomposition->loadFromCache(options.find("cache")->second);
        } else {
            decomposition->analyze();
        }
        if (options.count("makecache") && !options.find("makecache")->second.empty()) {
            decomposition->saveToCache(options.find("makecache")->second);
        }

        boost::shared_ptr<PrincipalComponentsT> components(new PrincipalComponentsT(decomposition, nfeatures));
        boost::shared_ptr<PcaGlyphMatcherT> matcher(new PcaGlyphMatcherT(components));
        boost::shared_ptr<DynamicGlyphMatcherT> dynamic_matcher(new DynamicGlyphMatcherT(matcher));
        return dynamic_matcher;
    }
示例#24
0
static SCM
scscm_recording_pre_unwind_handler (void *datap, SCM key, SCM args)
{
  struct with_catch_data *data = datap;
  excp_matcher_func *matcher = data->excp_matcher;

  if (matcher != NULL && matcher (key))
    return SCM_UNSPECIFIED;

  /* There's no need to record the whole stack if we're not going to print it.
     However, convention is to still print the stack frame in which the
     exception occurred, even if we're not going to print a full backtrace.
     For now, keep it simple.  */

  data->stack = scm_make_stack (SCM_BOOL_T, scm_list_1 (scm_from_int (2)));

  /* IWBN if we could return the <gdb:exception> here and skip the unwind
     handler, but it doesn't work that way.  If we want to return a
     <gdb:exception> object from the catch it needs to come from the unwind
     handler.  So what we do is save the stack for later use by the unwind
     handler.  */

  return SCM_UNSPECIFIED;
}
示例#25
0
文件: regex.cpp 项目: RedSnapper/Obyx
	bool Regex::field(const string &pattern,const string &basis,unsigned int fieldnum,string &scope) {
		bool retval=false;
		if ( ! basis.empty() ) {
			int* ov = nullptr; int ovc = 90;		// size must be a multiple of 3. //ovc size of ovector
			ov = new int[ovc];
			memset((int *) ov, 0, sizeof(ov));
			size_t matches = matcher(pattern, basis, 0, ov, ovc);
			if (matches > 0) {
				//				size_t matchstart = ov[0], matchend = ov[1];
				int st = ov[2 * fieldnum];
				if (st >= 0) {
					string newxbit;
					const char *bb = basis.c_str() + st;
					int be = ov[2 * fieldnum + 1];
					if (be > 0 ) { 
						scope.append(bb, be - st);
						retval = true;
					}
				}
			}
			delete [] ov;
		}
		return retval;
	}
示例#26
0
  void LocalMapping::CreateNewMapPoints() {
    // Retrieve neighbor keyframes in covisibility graph
    //    int nn = 10;
    //    if(mbMonocular)
    int nn = 20;
    const vector<kfptr> vpNeighKFs = mpCurrentKeyFrame->GetBestCovisibilityKeyFrames(nn);

    ORBmatcher matcher(0.6, false);

    cv::Mat Rcw1 = mpCurrentKeyFrame->GetRotation();
    cv::Mat Rwc1 = Rcw1.t();
    cv::Mat tcw1 = mpCurrentKeyFrame->GetTranslation();
    cv::Mat Tcw1(3, 4, CV_32F);
    Rcw1.copyTo(Tcw1.colRange(0, 3));
    tcw1.copyTo(Tcw1.col(3));
    cv::Mat Ow1 = mpCurrentKeyFrame->GetCameraCenter();

    const float &fx1 = mpCurrentKeyFrame->fx;
    const float &fy1 = mpCurrentKeyFrame->fy;
    const float &cx1 = mpCurrentKeyFrame->cx;
    const float &cy1 = mpCurrentKeyFrame->cy;
    const float &invfx1 = mpCurrentKeyFrame->invfx;
    const float &invfy1 = mpCurrentKeyFrame->invfy;

    const float ratioFactor = 1.5f * mpCurrentKeyFrame->mfScaleFactor;

    int nnew = 0;

    // Search matches with epipolar restriction and triangulate
    for(size_t i = 0; i < vpNeighKFs.size(); i++) {
      if(i > 0 && CheckNewKeyFrames()) {
        return;
      }

      kfptr pKF2 = vpNeighKFs[i];

      // Check first that baseline is not too short
      cv::Mat Ow2 = pKF2->GetCameraCenter();
      cv::Mat vBaseline = Ow2 - Ow1;
      const float baseline = cv::norm(vBaseline);

      //        if(!mbMonocular)
      //        {
      //            if(baseline<pKF2->mb)
      //            continue;
      //        }
      //        else
      //        {
      const float medianDepthKF2 = pKF2->ComputeSceneMedianDepth(2);
      const float ratioBaselineDepth = baseline / medianDepthKF2;

      if(ratioBaselineDepth < 0.01) {
        continue;
      }

      //        }

      // Compute Fundamental Matrix
      cv::Mat F12 = ComputeF12(mpCurrentKeyFrame, pKF2);

      // Search matches that fullfil epipolar constraint
      vector<pair<size_t, size_t> > vMatchedIndices;
      matcher.SearchForTriangulation(mpCurrentKeyFrame, pKF2, F12, vMatchedIndices);

      cv::Mat Rcw2 = pKF2->GetRotation();
      cv::Mat Rwc2 = Rcw2.t();
      cv::Mat tcw2 = pKF2->GetTranslation();
      cv::Mat Tcw2(3, 4, CV_32F);
      Rcw2.copyTo(Tcw2.colRange(0, 3));
      tcw2.copyTo(Tcw2.col(3));

      const float &fx2 = pKF2->fx;
      const float &fy2 = pKF2->fy;
      const float &cx2 = pKF2->cx;
      const float &cy2 = pKF2->cy;
      const float &invfx2 = pKF2->invfx;
      const float &invfy2 = pKF2->invfy;

      // Triangulate each match
      const int nmatches = vMatchedIndices.size();

      for(int ikp = 0; ikp < nmatches; ikp++) {
        const int &idx1 = vMatchedIndices[ikp].first;
        const int &idx2 = vMatchedIndices[ikp].second;

        const cv::KeyPoint &kp1 = mpCurrentKeyFrame->mvKeysUn[idx1];
        //            const float kp1_ur=mpCurrentKeyFrame->mvuRight[idx1];
        //            bool bStereo1 = kp1_ur>=0;

        const cv::KeyPoint &kp2 = pKF2->mvKeysUn[idx2];
        //            const float kp2_ur = pKF2->mvuRight[idx2];
        //            bool bStereo2 = kp2_ur>=0;

        // Check parallax between rays
        cv::Mat xn1 = (cv::Mat_<float>(3, 1) << (kp1.pt.x - cx1) * invfx1, (kp1.pt.y - cy1) * invfy1, 1.0);
        cv::Mat xn2 = (cv::Mat_<float>(3, 1) << (kp2.pt.x - cx2) * invfx2, (kp2.pt.y - cy2) * invfy2, 1.0);

        cv::Mat ray1 = Rwc1 * xn1;
        cv::Mat ray2 = Rwc2 * xn2;
        const float cosParallaxRays = ray1.dot(ray2) / (cv::norm(ray1) * cv::norm(ray2));

        float cosParallaxStereo = cosParallaxRays + 1;
        //            float cosParallaxStereo1 = cosParallaxStereo;
        //            float cosParallaxStereo2 = cosParallaxStereo;

        //            if(bStereo1)
        //                cosParallaxStereo1 = cos(2*atan2(mpCurrentKeyFrame->mb/2,mpCurrentKeyFrame->mvDepth[idx1]));
        //            else if(bStereo2)
        //                cosParallaxStereo2 = cos(2*atan2(pKF2->mb/2,pKF2->mvDepth[idx2]));

        //            cosParallaxStereo = min(cosParallaxStereo1,cosParallaxStereo2);

        cv::Mat x3D;

        if(cosParallaxRays < cosParallaxStereo && cosParallaxRays > 0 && (cosParallaxRays < 0.9998)) { //(bStereo1 || bStereo2 || cosParallaxRays<0.9998))
          // Linear Triangulation Method
          cv::Mat A(4, 4, CV_32F);
          A.row(0) = xn1.at<float>(0) * Tcw1.row(2) - Tcw1.row(0);
          A.row(1) = xn1.at<float>(1) * Tcw1.row(2) - Tcw1.row(1);
          A.row(2) = xn2.at<float>(0) * Tcw2.row(2) - Tcw2.row(0);
          A.row(3) = xn2.at<float>(1) * Tcw2.row(2) - Tcw2.row(1);

          cv::Mat w, u, vt;
          cv::SVD::compute(A, w, u, vt, cv::SVD::MODIFY_A | cv::SVD::FULL_UV);

          x3D = vt.row(3).t();

          if(x3D.at<float>(3) == 0) {
            continue;
          }

          // Euclidean coordinates
          x3D = x3D.rowRange(0, 3) / x3D.at<float>(3);

        }

        //            else if(bStereo1 && cosParallaxStereo1<cosParallaxStereo2)
        //            {
        //                x3D = mpCurrentKeyFrame->UnprojectStereo(idx1);
        //            }
        //            else if(bStereo2 && cosParallaxStereo2<cosParallaxStereo1)
        //            {
        //                x3D = pKF2->UnprojectStereo(idx2);
        //            }
        else {
          continue;  //No stereo and very low parallax
        }

        cv::Mat x3Dt = x3D.t();

        //Check triangulation in front of cameras
        float z1 = Rcw1.row(2).dot(x3Dt) + tcw1.at<float>(2);

        if(z1 <= 0) {
          continue;
        }

        float z2 = Rcw2.row(2).dot(x3Dt) + tcw2.at<float>(2);

        if(z2 <= 0) {
          continue;
        }

        //Check reprojection error in first keyframe
        const float &sigmaSquare1 = mpCurrentKeyFrame->mvLevelSigma2[kp1.octave];
        const float x1 = Rcw1.row(0).dot(x3Dt) + tcw1.at<float>(0);
        const float y1 = Rcw1.row(1).dot(x3Dt) + tcw1.at<float>(1);
        const float invz1 = 1.0 / z1;

        //            if(!bStereo1)
        //            {
        float u1 = fx1 * x1 * invz1 + cx1;
        float v1 = fy1 * y1 * invz1 + cy1;
        float errX1 = u1 - kp1.pt.x;
        float errY1 = v1 - kp1.pt.y;

        if((errX1 * errX1 + errY1 * errY1) > 5.991 * sigmaSquare1) {
          continue;
        }

        //            }
        //            else
        //            {
        //                float u1 = fx1*x1*invz1+cx1;
        //                float u1_r = u1 - mpCurrentKeyFrame->mbf*invz1;
        //                float v1 = fy1*y1*invz1+cy1;
        //                float errX1 = u1 - kp1.pt.x;
        //                float errY1 = v1 - kp1.pt.y;
        //                float errX1_r = u1_r - kp1_ur;
        //                if((errX1*errX1+errY1*errY1+errX1_r*errX1_r)>7.8*sigmaSquare1)
        //                    continue;
        //            }

        //Check reprojection error in second keyframe
        const float sigmaSquare2 = pKF2->mvLevelSigma2[kp2.octave];
        const float x2 = Rcw2.row(0).dot(x3Dt) + tcw2.at<float>(0);
        const float y2 = Rcw2.row(1).dot(x3Dt) + tcw2.at<float>(1);
        const float invz2 = 1.0 / z2;
        //            if(!bStereo2)
        //            {
        float u2 = fx2 * x2 * invz2 + cx2;
        float v2 = fy2 * y2 * invz2 + cy2;
        float errX2 = u2 - kp2.pt.x;
        float errY2 = v2 - kp2.pt.y;

        if((errX2 * errX2 + errY2 * errY2) > 5.991 * sigmaSquare2) {
          continue;
        }

        //            }
        //            else
        //            {
        //                float u2 = fx2*x2*invz2+cx2;
        //                float u2_r = u2 - mpCurrentKeyFrame->mbf*invz2;
        //                float v2 = fy2*y2*invz2+cy2;
        //                float errX2 = u2 - kp2.pt.x;
        //                float errY2 = v2 - kp2.pt.y;
        //                float errX2_r = u2_r - kp2_ur;
        //                if((errX2*errX2+errY2*errY2+errX2_r*errX2_r)>7.8*sigmaSquare2)
        //                    continue;
        //            }

        //Check scale consistency
        cv::Mat normal1 = x3D - Ow1;
        float dist1 = cv::norm(normal1);

        cv::Mat normal2 = x3D - Ow2;
        float dist2 = cv::norm(normal2);

        if(dist1 == 0 || dist2 == 0) {
          continue;
        }

        const float ratioDist = dist2 / dist1;
        const float ratioOctave = mpCurrentKeyFrame->mvScaleFactors[kp1.octave] / pKF2->mvScaleFactors[kp2.octave];

        /*if(fabs(ratioDist-ratioOctave)>ratioFactor)
            continue;*/
        if(ratioDist * ratioFactor < ratioOctave || ratioDist > ratioOctave * ratioFactor) {
          continue;
        }

        // Triangulation is succesfull
        mpptr pMP{new MapPoint(x3D, mpCurrentKeyFrame, mpMap, mClientId, mpComm, mpCC->mSysState, -1)};

        pMP->AddObservation(mpCurrentKeyFrame, idx1);
        pMP->AddObservation(pKF2, idx2);

        mpCurrentKeyFrame->AddMapPoint(pMP, idx1);
        pKF2->AddMapPoint(pMP, idx2);

        pMP->ComputeDistinctiveDescriptors();

        pMP->UpdateNormalAndDepth();

        mpMap->AddMapPoint(pMP);
        mlpRecentAddedMapPoints.push_back(pMP);

        nnew++;
      }
    }
  }
示例#27
0
int ConnectMain( int argc, char * argv[] )
{
    (void)argc;
    (void)argv;

    Allocator & allocator = GetDefaultAllocator();

    uint64_t clientId = 0;
    RandomBytes( (uint8_t*) &clientId, 8 );

    printf( "\nclient id is %.16" PRIx64 "\n", clientId );

    Matcher matcher( allocator );

    if ( !matcher.Initialize() )
    {
        printf( "error: failed to initialize matcher\n" );
        return 1;
    }

    matcher.RequestMatch( ProtocolId, clientId );

    if ( matcher.GetStatus() == MATCHER_FAILED )
    {
        printf( "\nerror: request match failed. is the matcher running?\n\n" );
        return 1;
    }

    printf( "requesting match from https://localhost:8080\n" );

    MatchResponse matchResponse;

    matcher.GetMatchResponse( matchResponse );

    if ( matchResponse.numServerAddresses == 0 )
    {
        printf( "error: could not find a match\n" );
        return 1;
    }

    printf( "received match response\n" );

    ClientServerPacketFactory packetFactory;

    GameNetworkTransport clientTransport( packetFactory );

    if ( clientTransport.GetError() != SOCKET_ERROR_NONE )
    {
        printf( "error: failed to initialize client socket\n" );
        return 1;
    }
    
    printf( "client started on port %d\n", clientTransport.GetAddress().GetPort() );

    GameClient client( GetDefaultAllocator(), clientTransport );

    client.Connect( matchResponse.serverAddresses[0],
                    matchResponse.connectTokenData, 
                    matchResponse.connectTokenNonce, 
                    matchResponse.clientToServerKey,
                    matchResponse.serverToClientKey );

    double time = 0.0;

    const double deltaTime = 0.1;

    signal( SIGINT, interrupt_handler );    

    while ( !quit )
    {
        client.SendPackets();

        clientTransport.WritePackets();

        clientTransport.ReadPackets();

        client.ReceivePackets();

        client.CheckForTimeOut();

        if ( client.IsDisconnected() )
            break;

        time += deltaTime;

        client.AdvanceTime( time );

        clientTransport.AdvanceTime( time );

        if ( client.ConnectionFailed() )
            break;

        platform_sleep( deltaTime );
    }

    if ( quit )
        printf( "\nclient stopped\n" );

    printf( "\n" );

    if ( client.IsConnected() )
        client.Disconnect();

    return 0;
}
const KstTimezone *KstTimezones::local()
{
    const KstTimezone *local = 0;

    // First try the simplest solution of checking for well-formed TZ setting.
    char *envZone = ::getenv("TZ");
    if (envZone)
    {
        if (envZone[0] == '\0')
        {
            return m_UTC;
        }
        else
        if (envZone[0] == ':')
        {
            envZone++;
        }
        local = zone(envZone);
    }
    if (local)
        return local;

    // Try to match /etc/localtime against the list of zoneinfo files.
    QFile f;
    f.setName("/etc/localtime");
    if (f.open(IO_ReadOnly))
    {
        // Compute the MD5 sum of /etc/localtime.
        KMD5 context("");
        context.reset();
        context.update(f);
        QIODevice::Offset referenceSize = f.size();
        QString referenceMd5Sum = context.hexDigest();
        f.close();
        if (!m_zoneinfoDir.isEmpty())
        {
            // Compare it with each zoneinfo file.
            for (ZoneMap::Iterator it = m_zones->begin(); it != m_zones->end(); ++it)
            {
                KstTimezone *zone = it.data();
                f.setName(m_zoneinfoDir + '/' + zone->name());
                if (f.open(IO_ReadOnly))
                {
                    QIODevice::Offset candidateSize = f.size();
                    QString candidateMd5Sum;
                    if (candidateSize == referenceSize)
                    {
                        // Only do the heavy lifting for file sizes which match.
                        context.reset();
                        context.update(f);
                        candidateMd5Sum = context.hexDigest();
                    }
                    f.close();
                    if (candidateMd5Sum == referenceMd5Sum)
                    {
                        local = zone;
                        break;
                    }
                }
            }
        }
    }
    if (local)
        return local;

    // BSD support.
    QString fileZone;
    f.setName("/etc/timezone");
    if (!f.open(IO_ReadOnly))
    {
        // Solaris support using /etc/default/init.
        f.setName("/etc/default/init");
        if (f.open(IO_ReadOnly))
        {
            QTextStream ts(&f);
            ts.setEncoding(QTextStream::Latin1);

            // Read the last line starting "TZ=".
            while (!ts.atEnd())
            {
                fileZone = ts.readLine();
                if (fileZone.startsWith("TZ="))
                {
                    fileZone = fileZone.mid(3);

                    local = zone(fileZone);
                }
            }
            f.close();
        }
    }
    else
    {
        QTextStream ts(&f);
        ts.setEncoding(QTextStream::Latin1);

        // Read the first line.
        if (!ts.atEnd())
        {
            fileZone = ts.readLine();

            local = zone(fileZone);
        }
        f.close();
    }
    if (local)
        return local;

    // None of the deterministic stuff above has worked: try a heuristic. We
    // try to find a pair of matching timezone abbreviations...that way, we'll
    // likely return a value in the user's own country.
    if (!m_zoneinfoDir.isEmpty())
    {
        tzset();
        AbbreviationsMatch matcher(tzname[0], tzname[1]);
        int bestOffset = INT_MAX;
        for (ZoneMap::Iterator it = m_zones->begin(); it != m_zones->end(); ++it)
        {
            KstTimezone *zone = it.data();
            int candidateOffset = QABS(zone->offset(Qt::LocalTime));
            if (zone->parse(matcher) && matcher.test() && (candidateOffset < bestOffset))
            {
                bestOffset = candidateOffset;
                local = zone;
            }
        }
    }
    if (local)
        return local;
    return m_UTC;
}
示例#29
0
bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* const argv[])
{
    Settings& settings = cppcheck->settings();
    CmdLineParser parser(&settings);
    const bool success = parser.ParseFromArgs(argc, argv);

    if (success) {
        if (parser.GetShowVersion() && !parser.GetShowErrorMessages()) {
            const char * const extraVersion = cppcheck->extraVersion();
            if (*extraVersion != 0)
                std::cout << "Cppcheck " << cppcheck->version() << " ("
                          << extraVersion << ')' << std::endl;
            else
                std::cout << "Cppcheck " << cppcheck->version() << std::endl;
        }

        if (parser.GetShowErrorMessages()) {
            errorlist = true;
            std::cout << ErrorLogger::ErrorMessage::getXMLHeader(settings._xml_version);
            cppcheck->getErrorMessages();
            std::cout << ErrorLogger::ErrorMessage::getXMLFooter(settings._xml_version) << std::endl;
        }

        if (parser.ExitAfterPrinting()) {
            settings.terminate();
            return true;
        }
    } else {
        return false;
    }

    // Check that all include paths exist
    {
        std::list<std::string>::iterator iter;
        for (iter = settings._includePaths.begin();
             iter != settings._includePaths.end();
            ) {
            const std::string path(Path::toNativeSeparators(*iter));
            if (FileLister::isDirectory(path))
                ++iter;
            else {
                // If the include path is not found, warn user and remove the non-existing path from the list.
                std::cout << "cppcheck: warning: Couldn't find path given by -I '" << path << '\'' << std::endl;
                iter = settings._includePaths.erase(iter);
            }
        }
    }

    // Output a warning for the user if he tries to exclude headers
    bool warn = false;
    const std::vector<std::string>& ignored = parser.GetIgnoredPaths();
    for (std::vector<std::string>::const_iterator i = ignored.cbegin(); i != ignored.cend(); ++i) {
        if (Path::isHeader(*i)) {
            warn = true;
            break;
        }
    }
    if (warn) {
        std::cout << "cppcheck: filename exclusion does not apply to header (.h and .hpp) files." << std::endl;
        std::cout << "cppcheck: Please use --suppress for ignoring results from the header files." << std::endl;
    }

    const std::vector<std::string>& pathnames = parser.GetPathNames();

#if defined(_WIN32)
    // For Windows we want case-insensitive path matching
    const bool caseSensitive = false;
#else
    const bool caseSensitive = true;
#endif
    if (!pathnames.empty()) {
        // Execute recursiveAddFiles() to each given file parameter
        PathMatch matcher(ignored, caseSensitive);
        for (std::vector<std::string>::const_iterator iter = pathnames.begin(); iter != pathnames.end(); ++iter)
            FileLister::recursiveAddFiles(_files, Path::toNativeSeparators(*iter), _settings->library.markupExtensions(), matcher);
    }

    if (_files.empty()) {
        std::cout << "cppcheck: error: could not find or open any of the paths given." << std::endl;
        if (!ignored.empty())
            std::cout << "cppcheck: Maybe all paths were ignored?" << std::endl;
        return false;
    }
    return true;
}
bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* const argv[])
{
    Settings& settings = cppcheck->settings();
    CmdLineParser parser(&settings);
    bool success = parser.ParseFromArgs(argc, argv);

    if (success) {
        if (parser.GetShowVersion() && !parser.GetShowErrorMessages()) {
            const char * extraVersion = cppcheck->extraVersion();
            if (*extraVersion != 0)
                std::cout << "Cppcheck " << cppcheck->version() << " ("
                          << extraVersion << ')' << std::endl;
            else
                std::cout << "Cppcheck " << cppcheck->version() << std::endl;
        }

        if (parser.GetShowErrorMessages()) {
            errorlist = true;
            std::cout << ErrorLogger::ErrorMessage::getXMLHeader(settings._xml_version);
            cppcheck->getErrorMessages();
            std::cout << ErrorLogger::ErrorMessage::getXMLFooter(settings._xml_version) << std::endl;
        }

        if (parser.ExitAfterPrinting())
            std::exit(EXIT_SUCCESS);
    } else {
        std::exit(EXIT_FAILURE);
    }

    // Check that all include paths exist
    {
        std::list<std::string>::iterator iter;
        for (iter = settings._includePaths.begin();
             iter != settings._includePaths.end();
            ) {
            const std::string path(Path::toNativeSeparators(*iter));
            if (FileLister::isDirectory(path))
                ++iter;
            else {
                // If the include path is not found, warn user (unless --quiet
                // was used) and remove the non-existing path from the list.
                if (!settings._errorsOnly)
                    std::cout << "cppcheck: warning: Couldn't find path given by -I '" << path << '\'' << std::endl;
                iter = settings._includePaths.erase(iter);
            }
        }
    }

    const std::vector<std::string>& pathnames = parser.GetPathNames();

    if (!pathnames.empty()) {
        // Execute recursiveAddFiles() to each given file parameter
        std::vector<std::string>::const_iterator iter;
        for (iter = pathnames.begin(); iter != pathnames.end(); ++iter)
            FileLister::recursiveAddFiles(_files, Path::toNativeSeparators(*iter), _settings->library.markupExtensions());
    }

    if (!_files.empty()) {
        // Remove header files from the list of ignored files.
        // Also output a warning for the user.
        // TODO: Remove all unknown files? (use FileLister::acceptFile())
        bool warn = false;
        std::vector<std::string> ignored = parser.GetIgnoredPaths();
        for (std::vector<std::string>::iterator i = ignored.begin(); i != ignored.end();) {
            const std::string extension = Path::getFilenameExtension(*i);
            if (extension == ".h" || extension == ".hpp") {
                i = ignored.erase(i);
                warn = true;
            } else
                ++i;
        }
        if (warn) {
            std::cout << "cppcheck: filename exclusion does not apply to header (.h and .hpp) files." << std::endl;
            std::cout << "cppcheck: Please use --suppress for ignoring results from the header files." << std::endl;
        }

#if defined(_WIN32)
        // For Windows we want case-insensitive path matching
        const bool caseSensitive = false;
#else
        const bool caseSensitive = true;
#endif
        PathMatch matcher(parser.GetIgnoredPaths(), caseSensitive);
        for (std::map<std::string, std::size_t>::iterator i = _files.begin(); i != _files.end();) {
            if (matcher.Match(i->first))
                _files.erase(i++);
            else
                ++i;
        }
    } else {
        std::cout << "cppcheck: error: could not find or open any of the paths given." << std::endl;
        return false;
    }

    if (!_files.empty()) {
        return true;
    } else {
        std::cout << "cppcheck: error: no files to check - all paths ignored." << std::endl;
        return false;
    }
}