OpenCV (Open Source Computer Vision Library) is an open source computer vision library developed and released by Intel [1]. After the development was transferred to Willow Garage in 2009, Itseez is currently performing maintenance as of 2015 [2]. In addition, it was announced that Intel will acquire Itseez on May 26, 2016.
In other words, it was developed by intel, went around, and now it seems that intel has acquired it again.
Such a library.
It has not only image processing but also opportunity learning,
It's nice.
So I wondered if I could develop something using this.
I converted the photo into text and spit it out in HTML.
First of all, you can not do it unless you can use openCV in the development environment, so let's make it available.
Homebrew is convenient, so I will use it.
Use tap.
tap Summary:
A command called "tap" has been added to Homebrew. By using this command, you can import a repository that has published a formula other than the official one into homebrew, and you can handle it with the $ brew command.
This makes it easy to add formulas such as vim, Apache, and php that homebrew didn't have before. Also, if you have a formula uploaded to your github account, you can also import it.
Quoted below http://tukaikta.blog135.fc2.com/blog-entry-204.html
That is convenient.
brew tap homebrew/science
Install openCV.
brew install.
brew install opencv
Check if it can be used with python.
->> python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> import numpy
>>>
It seems to be a nice library for manipulating numpy multidimensional arrays, and it seems to be just right for storing the information spit out by openCV.
I will use it for the time being.
import
sudo pip install numpy
If you can do this far
First, try loading the image with openCV.
img = cv2.imread('./nakamoto.jpeg', cv2.IMREAD_COLOR)
cv2.imread (image path, type of image to output)
Image data can be output by the above function. If you just want to display it.
img = cv2.imread('./fuckImage.png', cv2.IMREAD_COLOR)
cv2.imshow('imgae',img )
cv2.waitKey(0)
This alone will launch the one that displays the image.
cv2.imread () In other words, the image itself read from the function on the left is output.
That is an image.
We will use this data.
You can get the RGB value of the specified location of this acquired image.
wid_num = 0
hei_num = 0
b = img[wid_num,hei_num,0]
g = img[wid_num,hei_num,1]
r = img[wid_num,hei_num,2]
Due to the above You can get the color of 0X0 coordinates.
Apply these and convert the following
The above image is converted to the following.
All of the above images have not been drawn, so if you want to see the whole, you can see it from the following.
http://shichimitoucarashi.com/ImageToStr/
The entire source code is below, so we are waiting for your pull request.
https://github.com/keisukeYamagishi/ImageToStr/tree/created_html
https://ja.wikipedia.org/wiki/OpenCV http://opencv.org/ http://cs231n.github.io/python-numpy-tutorial/ http://alcuin.space/ http://docs.opencv.org/3.3.0/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56
Recommended Posts