[PYTHON] You can read the analog meter with the example MNIST.

You can use MNIST in the textbook example to read the analog meter using artificial intelligence.

First, fix the camera and lighting and install them so that the shooting conditions are constant. If you can guarantee that you can shoot within a certain range, the prediction accuracy by artificial intelligence will improve. Next, take a picture of a specific analog meter in advance and prepare the state of each needle position. How much data to prepare depends on the required resolution, but 20-30 resolution seems to be sufficient. This is because the accuracy (error) of the analog meter itself is about ± 2.5% or ± 1.6%, that is, an error of about 5% or 3% is allowed when using the analog meter. Analog meters are not suitable for measuring 3 or 4 effective digits.

In order to prepare a lot of data in advance, shake the shooting conditions and lighting conditions to shoot as much as possible within the allowable range, or inflate the data with image processing.

The program itself has the same classification as MNIST. With enough data, you can divide it into training and testing, verify overfitting, adjust parameters, and much more.

ana00.png ana00.png

ana01.png ana01.png

Source code Data preparation The image file is stored below. https://bono0.com/

import numpy as np import matplotlib.pyplot as plt import cv2

i=np.ndarray([32,32,3]) data=np.ndarray([10,32,32,3]) data[:]=0

i=plt.imread("ana00.png ") plt.imshow(i) plt.show() i = cv2.resize(i, (32,32)) data[0,:,:,:]=i plt.imshow(i) plt.show()

i=plt.imread("ana01.png ") i = cv2.resize(i, (32,32)) data[1,:,:,:]=i

i=plt.imread("ana02.png ") i = cv2.resize(i, (32,32)) data[2,:,:,:]=i

i=plt.imread("ana03.png ") i = cv2.resize(i, (32,32)) data[3,:,:,:]=i

i=plt.imread("ana04.png ") i = cv2.resize(i, (32,32)) data[4,:,:,:]=i

i=plt.imread("ana05.png ") i = cv2.resize(i, (32,32)) data[5,:,:,:]=i

i=plt.imread("ana06.png ") i = cv2.resize(i, (32,32)) data[6,:,:,:]=i

i=plt.imread("ana07.png ") i = cv2.resize(i, (32,32)) data[7,:,:,:]=i

i=plt.imread("ana08.png ") i = cv2.resize(i, (32,32)) data[8,:,:,:]=i

i=plt.imread("ana09.png ") i = cv2.resize(i, (32,32)) data[9,:,:,:]=i

Learning and prediction import matplotlib.pyplot as plt from sklearn import datasets, svm, metrics from sklearn.model_selection import train_test_split

x = data.reshape((10,-1)) y=np.array([0,1,2,3,4,5,6,7,8,9])

X_train=x X_test=x y_train=y y_test=y

classifier = svm.SVC(gamma=0.001) classifier.fit(X_train, y_train) predicted = classifier.predict(X_test)

print("Classification report for classifier %s:\n%s\n" % (classifier, metrics.classification_report(y_test, predicted)))

Artificial intelligence simply looks at images and classifies them. We do not recognize the concept of analog meters or understand the hands and scales. If you don't require excessive requirements, you can read the analog meter with MNIST in the example.

Recommended Posts

You can read the analog meter with the example MNIST.
You can read the analog meter with the example MNIST.
Until you can read the error log
Read the power of the smart meter with M5StickC (BP35C0-J11-T01)
Can you delete the file?
read the tag assigned to you on ec2 with boto3
What you can do with the Python standard library statistics
Consider what you can do with Python from the Qiita article
Python | What you can do with Python
You can also check the communication of DB and cache with curl
18 beautiful Python terms you want to read aloud. R18 with example sentences
Starting with Django 1.8, you can choose Jinja2 as the template engine #djangoja
[Implementation example] Read the file line by line with Cython (Python) from the last line
What you can do with API vol.1
What you can do with programming skills
Until you can use opencv with python
If you guys in the scope kitchen can do it with a margin ~ ♪
Until you use the Kaggle API with Colab
Can you challenge Kaggle with just your iPad?
You can manage overlapping characters with multiple plt.text.
You can easily create a GUI with Python
Until you can use the Google Speech API
You can now display slides with nbviewer! [Jupyter]
Until you can install blender and run it with python for the time being