http://zbar.sourceforge.net/
bool findBarcode(IplImage *src, char *code)
{
cvCvtColor(src, grayImage, CV_BGR2GRAY);
ImageScanner scanner;
scanner.set_config(ZBAR_ISBN13, ZBAR_CFG_ENABLE, 1);
Image image(grayImage->width, grayImage->height,
"GREY", grayImage->imageData,
grayImage->width * grayImage->height);
// scan the image for barcodes
int n = scanner.scan(image);
// extract results
for(Image::SymbolIterator symbol = image.symbol_begin();
symbol != image.symbol_end();
++symbol) {
if(strcmp(symbol->get_type_name().c_str(), "ISBN-13") == 0)
{
strcpy(code, const_cast(symbol->get_data().c_str()));
return true;
}
}
// clean up
image.set_data(NULL, 0);
return false;
}
Google bookから情報を取ってくる
char code[13];
if(findBarcode(capFrame, code))
{
cout << code << endl; System::Net::WebClient wc; System::String^ strCode = gcnew System::String(code); System::String^ bookdata = wc.DownloadString("http://books.google.com/books?bibkeys=ISBN:" + strCode + "&jscmd=viewapi&callback=mycallback")->Replace("\\x26","&");
System::Console::WriteLine(bookdata);
}
0 件のコメント:
コメントを投稿