There is a consultation about whether you can search the full text of the drawing in the search system consultation. I tried an OpenCV tutorial to verify the realization accuracy.
The following is a memorandum of procedure I took
** Premise ** OS: Windows10 64bit
Python: Python3.7(Anaconda3)
Target From building an OpenCV environment to conducting a simple tutorial (I want to do face recognition for the time being)
https://www.anaconda.com/products/individual
https://opencv.org/releases/
・ Click RELEASES from the tab above. · OpenCV – Click Sources in 4.2.0 -Unzip the zip and take out opencv_python- 4.2.0-cp37-cp37m-win_amd64.whl
conda install numpy
pip install matplotlib
★ Articles referred to so far Articles referred to when building the foundation https://qiita.com/FukuharaYohei/items/5d49938ffd33d198f0c0
Articles referred to for countermeasures against Cascade Classifier errors http://sh0122.hatenadiary.jp/entry/2017/10/30/210411
I'll try it on a trial basis, so I'll try face recognition first. Once you understand the basics, all you have to do is customize the basics.
It is an xml file that has already learned the features required for classification and recognition. This time, "haarcascade_frontalface_default.xml" is used for face recognition. https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xml
The photo used this time is my own photo that was cutely processed with SNOW. Can you recognize this ...?
import cv2
#Classifier
cascadeFile = "C:\imagepy\haarcascade_frontalface_default.xml"
#Classifier settings
cascade = cv2.CascadeClassifier(cascadeFile)
#Input file
imageImput ="C:\imagepy\myface.jpg "
#Read input file
image = cv2.imread(imageImput)
#Make it grayscale
imageGray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
#Output file
imageOutput = "C:\imagepy\out.jpg "
#Recognize face
facerect = cascade.detectMultiScale(imageGray, scaleFactor=1.1, minNeighbors=2, minSize=(30, 30))
#Processing when a face can be detected
if len(facerect) > 0:
#Put a frame on the face
for rect in facerect:
cv2.rectangle(image, tuple(rect[0:2]),tuple(rect[0:2]+rect[2:4]), (255, 255, 255), thickness=2)
#Save the result as an image
cv2.imwrite(imageOutput, image)
It seems that even my own photo processed cutely with SNOW is recognized as a face
We have completed the tutorial, which is our goal. Next time, I would like to recognize the symbols and objects on the drawing and make full-text search possible.
I can't test with the drawings used at work, so I wonder if I should aim for a state where full-text search is possible by recognizing the symbols in the map. .. ..
Recommended Posts