本文整理汇总了C++中Pattern::isText方法的典型用法代码示例。如果您正苦于以下问题:C++ Pattern::isText方法的具体用法?C++ Pattern::isText怎么用?C++ Pattern::isText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pattern
的用法示例。
在下文中一共展示了Pattern::isText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f
vector<FindResult>
getFindResults(Mat screenImage, Pattern ptn, bool all, double similarity) {
vector<FindResult> results;
if (ptn.isText()){
TextFinder f(screenImage);
f.find(ptn.getText(), similarity);
if (all){
while (f.hasNext()){
results.push_back(f.next());
}
}
else{
if (f.hasNext())
results.push_back(f.next());
}
}else{
TemplateFinder f(screenImage);
//string str(ptn.getImageURL());
//char filename[] = "c:\\cygwin\\home\\tomyeh\\libsikuli\\examples\\images\\startpage.png";
//string name("examples\\images\\startpage.png");
ScreenImage ptn_img = ptn.getScreenImage();
Mat image = ptn_img.getMat();
//imread(ptn.getImageURL());
//ptn.getImageURL());
/*namedWindow("Test");
imshow("Test",image);
waitKey();*/
if (all){
f.find_all(image, similarity);
while (f.hasNext()){
results.push_back(f.next());
}
}
else{
f.find(image, similarity);
if (f.hasNext())
results.push_back(f.next());
}
}
return results;
}
示例2: match
vector<Match>
Region::doFind(Pattern target) {
dout << "[Region::doFind] Searching in (" << xo+x << "," << yo+y << ")-(" << xo+x+w << "," << yo+y+h << ")" << endl;
ScreenImage simg = capture();
FindInput* fi;
if (target.isText())
fi = new FindInput(simg.getMat(), TARGET_TYPE_TEXT, target.getText());
else
fi = new FindInput(simg.getMat(), TARGET_TYPE_IMAGE, target.getImageURL());
FindInput& input = *fi;
input.setFindAll(target.bAll());
input.setLimit(target.getLimit());
input.setSimilarity(target.getSimilarity());
if (!target.bAll() && target.where() != ANYWHERE){
input.setFindAll(true);
}
vector<FindResult> results = Vision::find(input);
delete fi;
if (target.getOrdering() == TOPDOWN){
sort(results.begin(), results.end(), sort_by_y_asc);
}else if (target.getOrdering() == BOTTOMUP){
sort(results.begin(), results.end(), sort_by_y_dsc);
}else if (target.getOrdering() == LEFTRIGHT){
sort(results.begin(), results.end(), sort_by_x_asc);
}else if (target.getOrdering() == RIGHTLEFT){
sort(results.begin(), results.end(), sort_by_x_dsc);
}
if (!target.bAll() && target.where() != ANYWHERE){
if (!results.empty()){
// Filter Results
FindResult r = results[0];
for (int i=1; i<results.size(); ++i){
FindResult& ri = results[i];
if ((target.where() == TOPMOST && ri.y < r.y) ||
(target.where() == BOTTOMMOST && ri.y > r.y) ||
(target.where() == LEFTMOST && ri.x < r.x) ||
(target.where() == RIGHTMOST && ri.x > r.x))
r = ri;
}
results.clear();
results.push_back(r);
}
}
vector<Match> matches;
int n = min((int)results.size(), (int)target.getLimit());
for (int i=0; i< n; ++i){
FindResult& r = results[i];
Match match(inner(r.x,r.y,r.w,r.h),r.score);
matches.push_back(match);
}
if (!matches.empty()){
SikuliUI::sikuliUI->handleMatchFound(*this, target, matches);
setLastMatch(matches[0]);
setLastMatches(matches);
}
// TODO: setTargetOffset
//match.setTargetOffset(ptn.getTargetOffset());
return matches;
}