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

模塊'對(duì)象沒有屬性'drawMatches'opencv pyth

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

問題描述

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

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

模塊'對(duì)象沒有屬性'drawMatches'

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

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()

錯(cuò)誤:

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 接口,你會(huì)發(fā)現(xiàn)類似這樣的內(nèi)容:

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

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

編輯

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

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)于模塊'對(duì)象沒有屬性'drawMatches'opencv python的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個(gè)矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個(gè)矩形邊界框中應(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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 亚洲啊v在线| 欧美一区二区三区高清视频 | 欧美一区二区 | 欧美激情一区二区三区 | 国产精品久久久久久久久久久久午夜片 | 亚洲欧洲日本国产 | 久草网址 | 日韩美女在线看免费观看 | 亚洲欧美日韩精品久久亚洲区 | 操久久 | 国产精品区一区二 | 午夜电影网 | 国产高清视频 | 亚洲精品乱码久久久久久久久 | 久久国产精品99久久久久久丝袜 | 精品免费国产视频 | 久久精品视频12 | www.国产精 | 久久99精品国产 | 午夜精品一区二区三区在线观看 | 亚洲成色777777在线观看影院 | 成人黄色电影在线观看 | 一级毛片免费视频 | 久久久精品综合 | 91精品久久久久久久 | 久色 | 国产成人精品网站 | 久久久久国产精品午夜一区 | 国产欧美一区二区三区免费 | 欧美日韩精品久久久免费观看 | 国产黄色小视频在线观看 | 九九九久久国产免费 | 日韩精品在线一区 | 99久久久久久久 | 日韩精品在线观看免费 | 伊人二区| 国产成人精品久久二区二区91 | 国产日韩欧美一区 | 国产成人99久久亚洲综合精品 | 亚洲国产精品一区二区第一页 | 欧美精品在线一区二区三区 |