本文整理汇总了C++中Bitmap::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::IsValid方法的具体用法?C++ Bitmap::IsValid怎么用?C++ Bitmap::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitmap
的用法示例。
在下文中一共展示了Bitmap::IsValid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
using namespace lhack;
if (argc < 4) {
std::cerr << "Syntax: lhack rootdir comma-sep-filters similarity-coeff" << std::endl;
return 2;
}
const char *fbdev = "/dev/fb/0";
#if defined(LHACK_DEVEL_HOST)
if (argc < 5) {
std::cerr << "You must provide a grayscale image as the final arg. to be used instead of fbdev\n";
return 3;
}
fbdev = argv[4];
std::cout << "FB device: " << fbdev << std::endl;
#endif
#if defined(LHACK_K3)
FrameGrabber<K3Dimensions> fgrab(fbdev);
#else
FrameGrabber<KDXDimensions> fgrab(fbdev);
#endif
Bitmap image = fgrab.GrabSelected();
if (!image.IsValid())
return 2;
#ifdef LHACK_DEBUG_GRABBER
if (image.IsValid()) {
char dmpname[80];
snprintf(dmpname, 80, "titledump-%dx%d.gray", image.width(), image.height());
std::ofstream bmdump(dmpname);
bmdump.write(image.buffer(), image.height()*image.width());
bmdump.close();
}
#endif
#if defined(LHACK_DEVEL_HOST)
#if defined(LHACK_K3)
Recognizer<K3Dimensions> ocr("/mnt/x86/share", "eng");
#else
Recognizer<KDXDimensions> ocr("/mnt/x86/share", "eng");
#endif
#else
#if defined(LHACK_K3)
Recognizer<K3Dimensions> ocr("/mnt/us/launchpad/share", "eng");
#else
Recognizer<KDXDimensions> ocr("/mnt/us/launchpad/share", "eng");
#endif
#endif
string ocr_result = ocr.Recognize(image);
#if defined(LHACK_DEVEL_HOST)
std::cout << "OCR result: " << ocr_result << std::endl;
#endif
std::vector<std::string> filters;
char* fbegin = argv[2];
char* fend = fbegin;
while (*fend) {
if (*fend == ',') {
filters.push_back(string(fbegin, fend));
fbegin = ++fend;
}
else {
++ fend;
}
}
if (fend > fbegin)
filters.push_back(string(fbegin, fend));
if (filters.empty())
return 2;
string match = Search(argv[1], filters, ocr_result, atof(argv[3]));
if (match.empty())
return 3;
std::cout << match << std::endl;
return 0;
}