Call the OpenCV library in Python, using the Pycharm environment __python

Source: Internet
Author: User
Tags pycharm download



If the image below shows abnormal, please move the original text:

Reprint Address: http://blog.csdn.net/cumtml/article/details/50575408


My little academic only white, unexpectedly also began to write a blog. Because the configuration OpenCV library used a very long time, three days, encountered a lot of problems, a resolution, before the decision to share out, want to use Pythont call OpenCV library less take some detours. Write this article on the other hand is to receive shallow ink-Mao blog influence, shallow ink blogger, really is selfless to share their code, I am a very lazy person, deeply affected, do not lazy people.
First install Python, there are 2. X and 3.X, two versions are a lot different. I use a lot of libraries that support OPENCV in the 2.7,2 series.


Python download Link:

https://www.python.org/downloads/windows/


Pycharm Download Link
(http://www.jetbrains.com/pycharm), create project, select Editor ... You can also select a good editor when you create a project when you just open pycharm.
In Pycharm, File_new project.
Then in project, in, New--pychonfile. In File_setting, set the interpreter and choose Anaconda.








Community and Professional version of the free, professional version of the charge, I found the user name and secret key from the Internet. So even if you want to use the professional version, you can not pay to buy.
Pycharm is an editor that compiles programs in Python syntax and requires an environment that is selective, IDLE, Aptana, notepad++, Pycharm, SPE, and so forth. We use Python to finish the program, the compiler run results, need to solve the device, there are many interpreters, I use Anaconda. This interpreter activates a variety of packets without having to download other numpy and whatnot. It can be said that this interpreter is a labor of many benefits.
Https://www.continuum.io/downloads download link.





The installation process has been next on the line.
In the configuration process, has been bothering me is that, is to ignore the version of the problem, the computer is 64-bit, while compatible with 32-bit, I began to download the 32-bit, run the error, I have been unable to find the problem, in exchange for 64, the problem solved. All with the number of digits, there are errors, you may wish to configure a version of the same number as their own system to try.
The issue of calling the OpenCV library.
First find the Cv2.pyd in your OpenCV path, and the path information is shown in the following figure.
D:\Program files\opencv\build\python\2.7\x64


Copy Cv2.pyd to ..... The exclamation point at this time is because the network configuration has the following path

C:\Python27\Lib\site-packages




I put it in a different path.
C:\Anaconda2\Lib\site-packages





Two paths can be run, so all two paths are left, and programs can still run.
The operating procedure is attached as follows: The program was found on the Internet.

Import cv2  
import numpy as NP
#import pdb 
#pdb. Set_trace () #turn on the PDB prompt  
  
#read image  
img = CV 2.imread ("E:/2.jpg", Cv2. Imread_color)
Gray = Cv2.cvtcolor (img,cv2. Color_bgr2gray) 
cv2.imshow (' Origin ', img); 
  
#SIFT 
detector = cv2. SIFT ()  
keypoints = Detector.detect (gray,none)  
img = cv2.drawkeypoints (gray,keypoints)  
#img = Cv2.drawkeypoints (gray,keypoints,flags = Cv2. draw_matches_flags_draw_rich_keypoints) 
cv2.imshow (' Test ', IMG); 
Cv2.waitkey (0)  



The program reads the picture as well as the feature point detection, because the graph is too big, the interception part is as follows





If the image below shows abnormal, please move the original source.

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.