David Schwartz 427 Posted August 4 I'd like to build something that can be trained to recognize a deck of playing cards or flash cards, both upright and upside-down. Why? Because it's far easier and cheaper to be able to use a set of existing cards to do this as opposed to printing up a set with barcodes on them that the computer can read. Copyright issues aside, it's really expensive to print a set of playing cards. You need to print them by the 1000s if not 10,000s and then you have to sell them. It's not a quick process. Or print unique barcodes / QR codes / NFC tags and stick them on all of the cards. This is the "age of AI" so why not just be able to use a deck of cards and train the software to recognize each one? Once trained and incorporated into an app, you could hold up a card in front of the video camera and it would recognize it and as one of the cards it was trained on, say as an index into the list of cards, and be able to process it via the index from that point forward. I'm looking at a relatively limited set of cards, up to 100 or so, with images of varying complexity, and recognize each one with a high degree of accuracy. This is just pattern recognition, not any kind of generative aspect. What's the best way to go about something like this in Delphi? Share this post Link to post
Brian Evans 108 Posted August 5 Python has more bindings and tutorials for stuff like this and can be used from Delphi once you get it working in Python. Retraining an image classification model on the set of cards would be a good start. Some starting points: Image Recognition and Classification in Python with TensorFlow and Keras (stackabuse.com) TensorFlow Lite | ML for Mobile and Edge Devices 1 Share this post Link to post
JonRobertson 72 Posted August 9 (edited) 22 hours ago, David Schwartz said: Anything like that in just Delphi? You may want to look at ImageEn. Although this is a commercial library, it has been developed for decades, currently maintained, and extremely well supported. It offers several ways to recognize objects in images. One is an integration with Google Vision, TIEGoogleVision. The others require the IEVision add-on: TIEVisionImage.matchTemplate TIEVisionObjectsFinder TIEVisionNNet.detectObjects TIEVisionBlobDetector TIEVisionFaceRecognizer TIEVisionBarCodeScanner I have no affiliation with ImageEn, aside from being a happy customer & user of ImageEn components. (I have no experience with the IEVision components referenced above.) Edited August 9 by JonRobertson 1 Share this post Link to post
David Schwartz 427 Posted August 10 11 hours ago, JonRobertson said: You may want to look at ImageEn. Although this is a commercial library, it has been developed for decades, currently maintained, and extremely well supported. It offers several ways to recognize objects in images. One is an integration with Google Vision, TIEGoogleVision. The others require the IEVision add-on: I have no problem with licensing libraries, unlike a lot of programmers today. I draw the line at royalties on a per-use basis, however. A quick glance at this library tells me it's designed to be trained from a bunch of samples in order to classify and/or recognize unseen examples based on common features extracted from the samples. I only have a single example of each card. If you hold up the Ace of Spades, there's only one of them and it should not be confused by whether it's red or black, or a Club, Diamond, or Heart. I want to train it on all of the cards in the deck so it recognizes any given card from that deck that's held up to the camera. Noise might be present in terms of variances in color tint and hue, brightness, contrast, and orientation, but the same details are unchanged and not fuzzy nor ambiguous. Share this post Link to post
DelphiUdIT 182 Posted August 10 (edited) To do what you need I would use computer vision, in particular the "pattern matching" technique. You can try to use the OpenCV environment which is developed in C++ but on the net there are several wrappers for Delphi (here is one: https://github.com/gidesa/ocvWrapper46). I can't help you with OpenCV though, I used it the last time more than twenty years ago. Now I use Halcon (www.mvtec.com) and doing this is not very complex. The problem is that Halcon is very expensive for the developer and there is a royalty for each distribution depending on the features used (up to 2k Euro). One of the last project, I used it to recognize up to sixty LEGO pieces in a selection line (total time near to 200 ms.). P.S.: Halcon doesn't support Delphi, but I can give you (should still be in some post in this forum) a Delphi wrapper around C Halcon DLL. Edited August 10 by DelphiUdIT 1 Share this post Link to post