【发布时间】:2020-11-10 01:05:34
【问题描述】:
我是 OpenCV 的初学者,正在尝试运行一个开源程序。 http://asrl.utias.utoronto.ca/code/gpusurf/index.html
我目前已安装 Computer Vision Toolbox OpenCV Interface 20.1.0 和 Computer Vision Toolbox 9.2。
我无法运行这个简单的开源特征匹配算法而不会遇到错误。
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
% read images
img1 = cv2.imread('[INSERT PATH #1]');
img2 = cv2.imread('[INSERT PATH #2]');
img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY);
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY);
%sift
sift = cv2.xfeatures2d.SIFT_create();
keypoints_1, descriptors_1 = sift.detectAndCompute(img1,None);
keypoints_2, descriptors_2 = sift.detectAndCompute(img2,None);
len(keypoints_1), len(keypoints_2)
返回以下消息:
Error: File: Keypoints.m Line: 1 Column: 8
The import statement 'import cv2' cannot be found or cannot be imported. Imported names must end with '.*' or be
fully qualified.
但是,当我删除第 1 行时,却收到以下错误。
Error: File: Keypoints.m Line: 2 Column: 8
The import statement 'import matplotlib.pyplot' cannot be found or cannot be imported. Imported names must end
with '.*' or be fully qualified.
最后,跟随错误消息只会导致来自 cv2 库的一系列进一步错误。有什么想法吗?
【问题讨论】:
标签: matlab opencv matplotlib import importerror