久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

模塊'對象沒有屬性'drawMatches'opencv pyth

module#39; object has no attribute #39;drawMatches#39; opencv python(模塊對象沒有屬性drawMatchesopencv python)
本文介紹了模塊'對象沒有屬性'drawMatches'opencv python的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我只是在 OpenCV 中做一個特征檢測的例子.此示例如下所示.它給了我以下錯誤

I am just doing an example of feature detection in OpenCV. This example is shown below. It is giving me the following error

模塊'對象沒有屬性'drawMatches'

我檢查了 OpenCV 文檔,但不確定為什么會出現(xiàn)此錯誤.有誰知道為什么?

I have checked the OpenCV Docs and am not sure why I'm getting this error. Does anyone know why?

import numpy as np
import cv2
import matplotlib.pyplot as plt

img1 = cv2.imread('box.png',0)          # queryImage
img2 = cv2.imread('box_in_scene.png',0) # trainImage

# Initiate SIFT detector
orb = cv2.ORB()

# find the keypoints and descriptors with SIFT
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)

# create BFMatcher object
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)

# Match descriptors.
matches = bf.match(des1,des2)

# Draw first 10 matches.
img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:10], flags=2)

plt.imshow(img3),plt.show()

錯誤:

Traceback (most recent call last):
File "match.py", line 22, in <module>
img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:10], flags=2)
AttributeError: 'module' object has no attribute 'drawMatches'

推薦答案

drawMatches 函數(shù)不是 Python 接口的一部分.
正如您在 docs 中看到的,它僅定義為C++ 目前.

The drawMatches Function is not part of the Python interface.
As you can see in the docs, it is only defined for C++ at the moment.

文檔摘錄:

 C++: void drawMatches(const Mat& img1, const vector<KeyPoint>& keypoints1, const Mat& img2, const vector<KeyPoint>& keypoints2, const vector<DMatch>& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), const vector<char>& matchesMask=vector<char>(), int flags=DrawMatchesFlags::DEFAULT )
 C++: void drawMatches(const Mat& img1, const vector<KeyPoint>& keypoints1, const Mat& img2, const vector<KeyPoint>& keypoints2, const vector<vector<DMatch>>& matches1to2, Mat& outImg, const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), const vector<vector<char>>& matchesMask=vector<vector<char> >(), int flags=DrawMatchesFlags::DEFAULT )

如果函數(shù)有 Python 接口,你會發(fā)現(xiàn)類似這樣的內(nèi)容:

If the function had a Python interface, you would find something like this:

 Python: cv2.drawMatches(img1, keypoints1, [...]) 

編輯

實際上有一個 commit 介紹了這個函數(shù).但是,它(還沒有)在官方文檔中.
確保您使用的是最新的 OpenCV 版本 (2.4.7).為了完整起見,OpenCV 3.0.0 的函數(shù)接口看起來像 這個:

There actually was a commit that introduced this function 5 months ago. However, it is not (yet) in the official documentation.
Make sure you are using the newest OpenCV Version (2.4.7). For sake of completeness the Functions interface for OpenCV 3.0.0 will looks like this:

cv2.drawMatches(img1, keypoints1, img2, keypoints2, matches1to2[, outImg[, matchColor[, singlePointColor[, matchesMask[, flags]]]]]) → outImg

這篇關(guān)于模塊'對象沒有屬性'drawMatches'opencv python的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 91精品久久久久久久久 | 亚洲男人天堂网 | 全部免费毛片在线播放网站 | 成人在线视频一区 | 亚洲视频1区 | 91亚洲精品国偷拍自产在线观看 | 国产精品夜夜夜一区二区三区尤 | 韩日av在线 | 国产清纯白嫩初高生视频在线观看 | 久久精品av | 视频在线观看一区 | 亚洲综合在线播放 | 欧美日韩国产中文 | 国产91在线 | 亚洲 | 亚洲精品福利视频 | 在线观看免费福利 | 国产精品久久性 | 久久性色 | 1204国产成人精品视频 | 国产成人av在线播放 | av一区二区三区四区 | 国产精品av久久久久久久久久 | 久久久成人免费一区二区 | 久久久久久黄 | 午夜国产 | 视频在线日韩 | 九九热在线免费观看 | h在线看 | 国产精品视频综合 | 欧美色欧美亚洲另类七区 | 毛片1| 羞羞的视频免费在线观看 | 91久久北条麻妃一区二区三区 | 一级大黄 | 成人av免费看 | 国产999精品久久久久久 | 久久久久国产一区二区三区 | 黄色大全免费看 | 97caoporn国产免费人人 | 日本精品视频 | 亚洲一区精品在线 |