Configure opencv2.4.4 in Python

Source: Internet
Author: User

C ++ is a common language,ProgramIt's too slow. MATLAB is very suitable for scientific computation, but for a coders, they want to get on the Internet, so they decided to use the python paste language as a tool for the future, after two days of learning, I felt that it was really convenient. It was very convenient, including scientific computing, desktop programs, Internet programs (front-end, back-end), and visualization, I suddenly felt that "life is limited, so we need to use Python" is right, very happy!

It is best for beginners to install Python (x, y), because this installation package contains most of the commonly used packages, save yourself to find a variety of toolkit, and then install. In my version of Python (x, y) 2.7.3.1 (latest), no matter where your custom installation directory is selected, the C folder is generated in drive C: \ python27 ", which contains no opencv package, so you need to install it yourself. My opencv version is 2.4.4. After downloading it, decompress it, copy all the files in the "opencv \ build \ Python \ 2.7" Directory (only one cv2.pyd file exists) to the "C: \ python27 \ Lib \ Site-packages" directory, the configuration is complete, so simple, because the version after opencv2.2 is perfectly connected to Python.

Directly:

Import CV # This is an earlier version, similar to C

Import cv2 # This is a new version, similar to C ++. It is as convenient as the mat operation to directly correspond to the python Array

In addition, it seems that opencv2.4.4 does not correspond to the python manual. You can refer to the example in the opencv \ samples \ python2 directory.

Access Function example:

Im1_cv2.imread('lena.jpg ', cv2.cv. cv_load_image_color) type (IM) # Shows numpy arrayim. shape # numpy array object shape gives image sizecv2.imshow ('colorur', Im) im_gray = cv2.cvtcolor (IM, cv2.color _ bgr2gray) cv2.imshow ('Gray ', im_gray) # Show image on screencv2.imwrite('i1g.jpg ', im_gray) # Write to fileim_gray [...] = 0 # Use numpy broadcastingcv2.imshow ('turned Black', im_gray) cv2.waitkey ()

Example of accessing image content:

 
IMG [, 0] # Same as array

A small example Website: http://opencvpython.blogspot.com/

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.