using opencv instead of imagemagick in zbar qr cod

2020-06-27 09:01发布

I am writing a qr code decoder using Zbar api. I am using windows pre built libraries . I used the following code to load the image to ZBar

IplImage *src=cvLoadImage("image.png",CV_LOAD_IMAGE_GRAYSCALE);
ImageScanner scanner;
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);  
int width = src->width;
int height = src->height;   
uchar* raw = (uchar *)(src->imageData);
Image image(width, height, "Y800", raw, width * height);
int n = scanner.scan(image);

But it failed to decode the image. Am I using the correct way to read image data using opencv ? . When I tested only one image decoded and failed for all others . But it is working well when I used the zbarimg command line option

0条回答
登录 后发表回答