Answers.Body: <p>This is a simple <a href="https://en.wikipedia.org/wiki/Digital_image_processing" rel="nofollow noreferrer">digital image processing</a> task. I am proposing a quite efficient solution without any error correction mechanism, so this is not a production quality approach. But as a first proof of concept it should do the trick.</p>
  
  <p>The easiest approach would be splitting the image in two channels - one for the color red and one for the color black. You can neglect the rest outside a certain threshold. If the lighting is good, this should also deal with the background.</p>
  
  <p>Step 1: Crop away everything outside the gauge to simplify your life. The easiest way to do this is just putting the camera close enough that it only captures the gauge. That way you don't have to implement it in your algorithm.</p>
  
  <p>Step 2: The center of your image will be the red dot in the middle of the gauge. You can easily identify it with a filter looking for the largest concentration of red in the red channel of your image. Calculate the center and remember the coordinates.</p>
  
  <p>Step 3: Do the same for the largest concentration of black in the black channel. This will be the thick end part of the black needle. Calculate the center as well and remember the coordinates.</p>
  
  <p>Step 4: Calculate the vector between those two coordinates. The angle of the vector will tell you the angle of the needle (take care of the direction of the vector). Once you have the angle of the needle, you can easily derive the number it is pointing to.</p>
  
  <p>There are obviously much more elegant approaches to solve this problem, but this quick and dirty algorithm should do the trick without a lot of hassle. You need to make sure that the camera is positioned in the right angle, because we haven't implemented any error corrections in our algorithm. You also need to make sure the lighting is sufficient and that there aren't any other significant influences on the image quality. As long as the orientation is stable and the image quality high, this should enable you to read the gauge with good precision.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-05T10:18:33.897Z
Answers.Text: I have made something similar that could run on a Pi. Python and the OpenCV library work very well for this if the camera position, light and gauge are similar in all the images.
Answers.UserDisplayName: mjul
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-02T20:12:08.617Z
Answers.LastActivityDate: 2017-11-02T20:12:08.617Z
Answers.UserDisplayName: Demento
Body: <p>I have a simple gauge displaying analog values ranging from 0 to 4.
  <a href="https://www.fragdenstein.de/wordpress/wp-content/uploads/2014/10/heizung_wasser_auffuellen_beitragsbild.jpg" rel="noreferrer">Here is an image of the gauge</a>. Unfortunately there is no way to get a analog or digital signal for the value.</p>
  
  <p>How do I read the value of the gauge? </p>
  
  <p>My idea is to make an image every 5 minutes and get the value by analyzing it. I am thinking of manually generating reference images with the black needle in different positions and then compare it to the real image. </p>
  
  <p>Since all the processing should be done on a raspberry pi without internet connectivity, a good approach would be a preconfigured docker image for image comparison which helps doing the image comparison locally, maybe supported by a python or php script.</p>
  
  <p>How to proceed?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-02T17:55:00.973Z
Comments.Text: Why the heck a -1 voting? What's wrong with this question?
Comments.UserDisplayName: WeSee
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-02T17:55:49.393Z
Comments.Text: Is this too simple? Please give me a hint, where this has already been solved...
Comments.UserDisplayName: WeSee
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-02T20:15:30.840Z
Comments.Text: Downvotes without explanation (and often without obvious reason) are common here, don't worry about it. It might have been because your question is not a real AI question, but can rather be solved with a simple image processing algorithm. Nevertheless, Computer Vision is considered an important part of AI development right now, so I think it can be argued that the question is still on topic. +1 from my side for the interesting challenge.
Comments.UserDisplayName: Demento
Tags: <image-recognition>
Title: Reading a value of a real gauge
UserDisplayName: WeSee
ThreadText: # Reading a value of a real gauge
  
  (Asked by: username_0 on 2017-11-02)
  
  I have a simple gauge displaying analog values ranging from 0 to 4.
  [Here is an image of the gauge](https://www.fragdenstein.de/wordpress/wp-content/uploads/2014/10/heizung_wasser_auffuellen_beitragsbild.jpg). Unfortunately there is no way to get a analog or digital signal for the value.
  
  How do I read the value of the gauge?
  
  My idea is to make an image every 5 minutes and get the value by analyzing it. I am thinking of manually generating reference images with the black needle in different positions and then compare it to the real image.
  
  Since all the processing should be done on a raspberry pi without internet connectivity, a good approach would be a preconfigured docker image for image comparison which helps doing the image comparison locally, maybe supported by a python or php script.
  
  How to proceed?
  
  **Tags:** image-recognition
  > **Comments:**
  > **username_0**: Why the heck a -1 voting? What's wrong with this question?  
  > **username_0**: Is this too simple? Please give me a hint, where this has already been solved...  
  > **username_1**: Downvotes without explanation (and often without obvious reason) are common here, don't worry about it. It might have been because your question is not a real AI question, but can rather be solved with a simple image processing algorithm. Nevertheless, Computer Vision is considered an important part of AI development right now, so I think it can be argued that the question is still on topic. +1 from my side for the interesting challenge.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-11-02. Score: 1
  
  This is a simple [digital image processing](https://en.wikipedia.org/wiki/Digital_image_processing) task. I am proposing a quite efficient solution without any error correction mechanism, so this is not a production quality approach. But as a first proof of concept it should do the trick.
  
  The easiest approach would be splitting the image in two channels - one for the color red and one for the color black. You can neglect the rest outside a certain threshold. If the lighting is good, this should also deal with the background.
  
  Step 1: Crop away everything outside the gauge to simplify your life. The easiest way to do this is just putting the camera close enough that it only captures the gauge. That way you don't have to implement it in your algorithm.
  
  Step 2: The center of your image will be the red dot in the middle of the gauge. You can easily identify it with a filter looking for the largest concentration of red in the red channel of your image. Calculate the center and remember the coordinates.
  
  Step 3: Do the same for the largest concentration of black in the black channel. This will be the thick end part of the black needle. Calculate the center as well and remember the coordinates.
  
  Step 4: Calculate the vector between those two coordinates. The angle of the vector will tell you the angle of the needle (take care of the direction of the vector). Once you have the angle of the needle, you can easily derive the number it is pointing to.
  
  There are obviously much more elegant approaches to solve this problem, but this quick and dirty algorithm should do the trick without a lot of hassle. You need to make sure that the camera is positioned in the right angle, because we haven't implemented any error corrections in our algorithm. You also need to make sure the lighting is sufficient and that there aren't any other significant influences on the image quality. As long as the orientation is stable and the image quality high, this should enable you to read the gauge with good precision.
  
  > **Comments:**
  > **username_2**: I have made something similar that could run on a Pi. Python and the OpenCV library work very well for this if the camera position, light and gauge are similar in all the images.  
  
  ---
  
  