2

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

Senan
  • 411
  • 2
  • 6
  • 16
  • 1
    Issue solved.. I used cvLoadImageM instead of cvLoadImage. The final code look like this CvMat *cv_matrix = cvLoadImageM(argv[1],CV_LOAD_IMAGE_GRAYSCALE); int width = cv_matrix->width; int height= cv_matrix->height; char *raw = (char*)cv_matrix->data.ptr; – Senan Feb 14 '12 at 10:55
  • 1
    That comment should be an answer. Not a comment. – Sheena Nov 19 '12 at 21:39

0 Answers0