Computer vision>>PCV installation and use

reference:

Solve the problem that python cannot find PCV

https://blog.csdn.net/weixin_42606065/article/details/88190283

 

installation

Download the installation package

Address:  https://github.com/jesolem/PCV

git clone to any directory, or download the zip file directly.

Unzip to get the folder:

PCV-master

The files in it are as follows:

Among them, there are files that need to be changed in the PCV.

Trial installation

After decompression, cmd enters the directory where setup.py is located and runs the installation instructions:

Please confirm the existing python installation directory and execute the corresponding instructions, otherwise it will not be detected after the installation.:

If python is installed in the system directory (/usr/local/lib/), please execute:

sudo python setup.py install  #

If python is installed in the user directory (/home/xxx/.local/lib/), please execute:

python setup.py install --user

Some print errors will be reported at this time.

This is a problem caused by differences in python versions.
In the python2 version, it is: print "hello python!"
But in python3 you need to add parentheses, you should use: print ("hello python!")

Modify file

The files contained in the error message are all in the PCV subfolder and need to be modified, as follows: 

./PCV/tools/ncut.py

./PCV/tools/imtools.py

./PCV/tools/ransac.py

./PCV/imagesearch/imagesearch.py

./PCV/classifiers/bayes.py

./PCV/geometry/warp.py

./PCV/localdescriptors/dsift.py

./PCV/localdescriptors/sift.py

Open each file, search for print, and enclose the next print content with ().

There are 4 prints in ransac.py, and 1 print in other files, so the change was quickly completed.   

Reinstall

Run again: 

sudo python setup.py install

Normal, no errors were reported.

verification

carried out:

python

PVC import

Import is normal. The effect is as follows:

 

use

Commonly used sentences:

from PCV.tools import imtools

 

In the process of studying the book "Computer Vision" of People's Post and Telecommunications, and doing partial image descriptors and image-to-image mapping, the examples in the textbook run incorrectly: ModuleNotFoundError: No module named'matplotlib.delaunay', modified for a long time, Now I finally know how to change it. The specific steps are as follows:

first step:

Put

import matplotlib.delaunay as md
  • 1

Change to

from scipy.spatial import Delaunay
  • 1

Step 2: As shown in the figure, enter PCV\geometry\ warp.py and replace the code in triangulate_points(x,y) with

tri = Delaunay(np.c_[x,y]).simplices
  • 1

Insert picture description here
Then run it again, there is no problem.

 

common problem

The PCV module is not installed

1) If you have already installed it, please confirm whether the system has multiple python versions installed, and whether PCV is installed on the python version you are using

2) If it has not been installed, please install

3) After PCV is installed, please close the project and reopen it to recognize PCV normally

ImportError: cannot import name 'camera'

As of the writing of this article (2019.8.6), in the code downloaded from github,'camera' is placed in the PCV/geometry directory.

So please add the statement:

from PCV import camera

To:

from PCV.geometry import camera

Guess you like

Origin blog.csdn.net/c2a2o2/article/details/110657033