Python OpenCV tried to display the image in text.

Image analysis using Python OpenCV

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

nakamoto.jpeg

The above image is converted to the following.

スクリーンショット 2017-09-11 9.16.03.png

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

References

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

Python OpenCV tried to display the image in text.
I tried to process the image in "sketch style" with OpenCV
I tried to display the video playback time (OpenCV: Python version)
I tried to process the image in "pencil style" with OpenCV
I tried "smoothing" the image with Python + OpenCV
I tried "differentiating" the image with Python + OpenCV
I tried "binarizing" the image with Python + OpenCV
I want to display the progress in Python!
Speech to speech in python [text to speech]
I tried to graph the packages installed in Python
Convert the image in .zip to PDF with Python
In the python command python points to python3.8
Introduction to image analysis opencv python
I tried to find the entropy of the image with python
I tried "gamma correction" of the image with Python + OpenCV
I tried to implement the mail sending function in Python
I tried to extract the text in the image file using Tesseract of the OCR engine
I tried to implement PLSA in Python
I tried to implement permutation in Python
[Cloudian # 9] Try to display the metadata of the object in Python (boto3)
I tried to implement PLSA in Python 2
Display Python 3 in the browser with MAMP
[Cloudian # 2] Try to display the object storage bucket in Python (boto3)
How to display multiplication table in python
How to check opencv version in python
I tried to implement ADALINE in Python
I tried to implement PPO in Python
How to display Hello world in python
How to display bytes in the same way in Java and Python
I tried to make an image similarity function with Python + OpenCV
[Python] I tried to summarize the set type (set) in an easy-to-understand manner.
Mouse over Matplotlib to display the corresponding image
How to use the C library in Python
[Python] How to change the date format (display format)
tse --Introduction to Text Stream Editor in Python
How to use Python Image Library in python3 series
What is wheezy in the Docker Python image?
I tried simulating the "birthday paradox" in Python
I tried the least squares method in Python
How to crop an image with Python + OpenCV
To dynamically replace the next method in python
Draw graphs in Julia ... Leave the graphs to Python
[Python] Display the Altair legend in the plot area
The easiest way to use OpenCV with python
The trick to write flatten concisely in python
I tried to implement TOPIC MODEL in Python
How to get the files in the [Python] folder
I tried to implement selection sort in python
I tried using the image filter of OpenCV
[Python + OpenCV] Whiten the transparent part of the image
Introduction to OpenCV (python)-(2)
Image format in Python
[Python] I tried to judge the member image of the idol group using Keras
Former image processing engineer tried to solve Saizeriya's spot the difference with OpenCV
Find the position in the original image from the coordinates after affine transformation (Python + OpenCV)
How to display in the entire window when setting the background image with tkinter
I want to crop the image along the contour instead of the rectangle [python OpenCV]
Display n digits after the decimal point in python
python beginners tried to predict the number of criminals
Tool to make mask image for ETC in Python
How to retrieve the nth largest value in Python