1

So I am looking for a solution to read a QR code from delphi with a webcam. I found this example project to capture the webcam's image and save it to a .bmp file : linky

So I have the image that I want to scan. Now I would like to know how to get its contents in string format in Delphi. So to read the QR code I found ZBar which is exactly what I need. I just cant figure out how to use it with delphi.

I want to know if there is a way I can either implement the libraries ZBar supplies or somehow run ZBar and just receive the decoded text ?

ZBar has a command prompt example so I thought that it would be possible to run the command prompt, receive the results and just format the strings to find the code (like this). But that seems rather hacky and I am sure there must be a better way. I also could not get any of the answers to work.

I am using delphi 7 or xe3 if thats a factor.

Thanks for your time and suggestions.

Community
  • 1
  • 1
Kobus Vdwalt
  • 347
  • 1
  • 7
  • 20
  • 1
    "I am using delphi 7 or xe3 if thats a factor." Those are majorly different, especially when it comes to enforced Unicode. – Jerry Dodge Apr 20 '15 at 19:58
  • Should I stick with one ? I just mention it cause it may open up more possibilities. But it doesn't matter at all to me. – Kobus Vdwalt Apr 20 '15 at 20:07
  • Well that's a third-party software, not a library for Delphi. You might be able to use it, but I'm sure there are better options. – Jerry Dodge Apr 20 '15 at 20:10
  • A simple search for "Delphi QR Code" and the first result: http://www.debenu.com/open-source/delphizxingqrcode/ – Jerry Dodge Apr 20 '15 at 20:12
  • That one's for generating, here's one that can scan too: http://blog.marcocantu.com/blog/qr_codes_delphi.html Moral of the story is, use a search engine. – Jerry Dodge Apr 20 '15 at 20:14
  • 1
    I searched extensively (which I tried to convey through linking the resources) and the article you linked the example does not scan it only generates a QR code. – Kobus Vdwalt Apr 20 '15 at 20:28
  • Did you see my second comment? – Jerry Dodge Apr 20 '15 at 20:32
  • 1
    Yeah after I posted mine.. Oops :) Not to sound ungrateful but I visited all of those sites before. The TMS component seems to use the objective C port of ZBar which is meant for IPhone and not for scanning images after they have been taken. – Kobus Vdwalt Apr 20 '15 at 20:33
  • Compile the code into a DLL, then call it – David Heffernan Apr 20 '15 at 22:34
  • 3
    here's an [example](http://blog.freehand.com.ua/2013/03/zbar-reading-bar-codes-in-delphi.html) and it uses XE3... – whosrdaddy Apr 21 '15 at 04:34
  • Whosrdaddy that looks to be exactly what I need. The pascal header conversion seems to be critical to the whole thing. I will test when i get home. – Kobus Vdwalt Apr 21 '15 at 05:50
  • I am calling zbar_image_read('blabla.png') but it then throws an error : zbar_image_read not found in libzbar-0.dll I dont know what to do now. – Kobus Vdwalt Apr 21 '15 at 16:51
  • Should I ask a new question or edit the original one? I just want a simple example of how to use that zbar library. I just cant figure it out. – Kobus Vdwalt Apr 21 '15 at 17:54
  • I suspect that the header is a bit outdated, just try the example in the link I gave you, I does not use zbar_image_read. – whosrdaddy Apr 21 '15 at 18:34
  • I opened that example but its a console application and i need it in a win forms application. I tried to transfer the functions but the main read_image one writes its results to the console instead of returning the barcode string. I just need a function I can call with a path to the image as string which then returns the contents of the qr code as string. – Kobus Vdwalt Apr 21 '15 at 18:57

1 Answers1

0

The famous ZXing library finally has been ported to Delphi, but it is for the modern Delphi versions like Delphi 10.4, because there are new features used like in-place filling of dynamic arrays. I tried to rewrite it for Delphi 6 and didn't manage that.

Here is the link: https://github.com/Spelt/ZXing.Delphi

There is also an example for a webcam.

Paul
  • 25,812
  • 38
  • 124
  • 247