"Python+opencv learning" first, Gui Features in OPENCV (1) Read and save pictures __python

Source: Internet
Author: User

First of all, thank De Lihui Teacher Translation finishing of the "Opencv-python Chinese course", this document is really good, for OpenCV beginners, help is very large, can let beginners quick start.

Recommend two OPENCV learning sites:

(1) http://docs.opencv.org/2.4/index.html

This site can query the use of OPENCV functions, such as: Cv2.minarearect () function, in the query, be sure not to enter parentheses, so you can not retrieve.

(2) Http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_table_of_contents_gui/py_ Table_of_contents_gui.html

This site is the official use of OpenCV, De Lihui Teacher is the translation of this site.

These two URLs are really great for OPENCV beginners.

Learn Python and OpenCV for more than half a year, but did not write a blog before, in order to exercise their writing skills, recently began to write blog. The task at this stage is to make up the things you learned in the previous period.

"Python+opencv Learning" series of articles is just my study of the process of recording, the main record some important content, convenient to consult later. I am a small white one, I hope the great God criticized the advice.

The specific use of each function in the program is explained in detail in the URL above

1. Start using pictures

(1) Read into the image

Import cv2
img = cv2.imread (' test.jpg ', 0)
cv2.imshow (' Image ', img)
cv2.waitkey (0)
Cv2.destroyallwindows ()

Cv2.imread () The second parameter is the image read format, where 0 is read in grayscale format.

Note: If your image path has errors, it will not complain, but the print img result is none.

(2) Save the image

Import cv2
img = cv2.imread (' test.jpg ', 0)
cv2.imwrite (' person01.png ', IMG)
(3) Summary

Import NumPy as NP
import cv2

img = cv2.imread (' test01.jpg ', 0)
cv2.imshow (' Image ', img)
k = Cv2.waitkey (0)
If k =:
    cv2.destroyallwindows ()
elif k = = Ord (' s '):
    cv2.imwrite (' messigray.png ', img)
    Cv2.destroyallwindows ()
Note: If your system is 64 bits, you will need to
k = Cv2.waitkey (0)
Change into

k = Cv2.waitkey (0) &0xff

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.