Answers.Body: <p>Since you only have fixed types.</p>
  
  <p>For <code>colour</code>, I think it is fairly straight forward. <br>
  For <code>number</code>, simplest way is to plot a projection histogram and count the points of discontinuity. <br></p>
  
  <p>An example of the <code>projection histogram</code> <br></p>
  
  <p><a href="https://i.sstatic.net/UGMWZ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UGMWZ.png" alt="enter image description here"></a></p>
  
  <p>For <code>fill</code>, You can find the number of islands. Islands of background colour. <br>
  For <code>shape</code>, Like Clement Hui suggested you can use shape detection</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-11T04:32:24.070Z
Answers.Text: However the shape detection uses ML as far as I am concerned. One concern over the shape detection of openCV is that it may not feature the shapes of the cards.. the wave shape maybe too peculiar to be in the shapes of opencv library. Also I am not sure if the shape detection will work on non-filled or striped shapes. Have you tried it out? Will it work?
Answers.UserDisplayName: Clement
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-11T13:14:23.630Z
Answers.Text: Edited my answer. And you can erode the image before performing a shape detection. Then it should work, but haven't tried it personally.
Answers.UserDisplayName: codeblooded
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-10T08:37:05.023Z
Answers.LastActivityDate: 2020-01-11T13:10:34.723Z
Answers.LastEditDate: 2020-01-11T13:10:34.723Z
Answers.UserDisplayName: codeblooded
Body: <p><a href="https://en.wikipedia.org/wiki/Set_(card_game)" rel="noreferrer">Set is a card game</a> and is <a href="https://codegolf.stackexchange.com/questions/195023/play-the-card-game-set">Nicely described here</a>. </p>
  
  <p>Each set-card has 4 properties: </p>
  
  <ol>
  <li>The number(1,2 or 3)</li>
  <li>the color (Red, Green or Purple)</li>
  <li>Fill (Full, Stripes, None)</li>
  <li>Form (Wave, Oval or Diamond)</li>
  </ol>
  
  <p><a href="https://i.sstatic.net/KDBd2.gif" rel="noreferrer"><img src="https://i.sstatic.net/KDBd2.gif" alt="2PWN"></a></p>
  
  <p>converts to 2 Purple Waves No fill (code: 2PWN)</p>
  
  <p><a href="https://i.sstatic.net/mz20s.gif" rel="noreferrer"><img src="https://i.sstatic.net/mz20s.gif" alt="enter image description here"></a> and <a href="https://i.sstatic.net/N6vZe.gif" rel="noreferrer"><img src="https://i.sstatic.net/N6vZe.gif" alt="enter image description here"></a></p>
  
  <p>convert to codes 1RON and 3GDN</p>
  
  <p>For every combination there is one card so in total there are 3^4 = 81 cards. The goal is to identify 3 cards (set) out of collection of 12 displayed randomly chosen set cards where all properties occur 0,1 or 3 times.</p>
  
  <p>As a hobby project I want to create an android app which can -with the camera- capture the 12 (less or more) <code>set cards</code> and indicate the sets present in the collection of 12. I'm looking for ways to leverage image recognition as efficient as possible.</p>
  
  <p>I've been thinking of taking multiple pictures of all the individual cards, label them and feeding them to a trainer (firebase ML KIT AutoML Vision Edge) But I have the feeling that this a bit of brute force and takes a lot of time and effort photographing and labeling. I could also take pictures of multiple set cards and provide the different codes as labels.</p>
  
  <p>What would be the best (most efficient) approach to have a model for labelling all cards?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-09T16:04:36.387Z
Comments.Text: You might want to try Open CV's shape detector though it might not work for you because your shapes are custom. https://www.pyimagesearch.com/2016/02/08/opencv-shape-detection/
Comments.UserDisplayName: Clement
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-09T16:07:55.140Z
Comments.Text: For data labelling approach amount of data and accuracy maybe a problem here.
Comments.UserDisplayName: Clement
Tags: <image-recognition>
Title: Recognizing Set CARDs
UserDisplayName: dr jerry
ThreadText: # Recognizing Set CARDs
  
  (Asked by: username_0 on 2020-01-09)
  
  [Set is a card game](https://en.wikipedia.org/wiki/Set_(card_game)) and is [Nicely described here](https://codegolf.stackexchange.com/questions/195023/play-the-card-game-set).
  
  Each set-card has 4 properties:
  
  1. The number(1,2 or 3)
  2. the color (Red, Green or Purple)
  3. Fill (Full, Stripes, None)
  4. Form (Wave, Oval or Diamond)
  
  [![2PWN](https://i.sstatic.net/KDBd2.gif)](https://i.sstatic.net/KDBd2.gif)
  
  converts to 2 Purple Waves No fill (code: 2PWN)
  
  [![enter image description here](https://i.sstatic.net/mz20s.gif)](https://i.sstatic.net/mz20s.gif) and [![enter image description here](https://i.sstatic.net/N6vZe.gif)](https://i.sstatic.net/N6vZe.gif)
  
  convert to codes 1RON and 3GDN
  
  For every combination there is one card so in total there are 3^4 = 81 cards. The goal is to identify 3 cards (set) out of collection of 12 displayed randomly chosen set cards where all properties occur 0,1 or 3 times.
  
  As a hobby project I want to create an android app which can -with the camera- capture the 12 (less or more) `set cards` and indicate the sets present in the collection of 12. I'm looking for ways to leverage image recognition as efficient as possible.
  
  I've been thinking of taking multiple pictures of all the individual cards, label them and feeding them to a trainer (firebase ML KIT AutoML Vision Edge) But I have the feeling that this a bit of brute force and takes a lot of time and effort photographing and labeling. I could also take pictures of multiple set cards and provide the different codes as labels.
  
  What would be the best (most efficient) approach to have a model for labelling all cards?
  
  **Tags:** image-recognition
  
  > **Comments:**
  > **username_1**: You might want to try Open CV's shape detector though it might not work for you because your shapes are custom. https://www.pyimagesearch.com/2016/02/08/opencv-shape-detection/  
  > **username_1**: For data labelling approach amount of data and accuracy maybe a problem here.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-01-10. Score: 2
  
  Since you only have fixed types.
  
  For `colour`, I think it is fairly straight forward.   
  For `number`, simplest way is to plot a projection histogram and count the points of discontinuity.
  
  An example of the `projection histogram`
  
  [![enter image description here](https://i.sstatic.net/UGMWZ.png)](https://i.sstatic.net/UGMWZ.png)
  
  For `fill`, You can find the number of islands. Islands of background colour.   
  For `shape`, Like username_1 Hui suggested you can use shape detection
  
  > **Comments:**
  > **username_1**: However the shape detection uses ML as far as I am concerned. One concern over the shape detection of openCV is that it may not feature the shapes of the cards.. the wave shape maybe too peculiar to be in the shapes of opencv library. Also I am not sure if the shape detection will work on non-filled or striped shapes. Have you tried it out? Will it work?  
  > **username_2**: Edited my answer. And you can erode the image before performing a shape detection. Then it should work, but haven't tried it personally.  
  
  ---
  
  