简体   繁体   English

opencv python detectMultiScale API

[英]opencv python detectMultiScale api

I was following this particular tutorial on object detection. 我正在遵循有关对象检测的特定教程 He uses this version of detectMultiSacle function in his code, which allows him to adjust threshold for detection or something like that with rejectLevels and levelWeights: 他在代码中使用了此版本的detectMultiSacle函数,该功能允许他调整阈值以进行检测或类似的操作(使用rejectLevels和levelWeights):

Python: 蟒蛇:

cv2.CascadeClassifier.detectMultiScale(image,
rejectLevels, levelWeights[,
scaleFactor[, minNeighbors[, flags[,
minSize[, maxSize[,
outputRejectLevels]]]]]]) → objects

This is my code: 这是我的代码:

detectMultiScale(image=gray,
rejectLevels=rejectlevels,
levelWeights=levelweights)

But it gives the following error, which makes me confused: 但是它给出了以下错误,这使我感到困惑:

 TypeError: 'rejectLevels' is an invalid keyword argument for this function

I was trying to use detectMultiScale(image, rejectLevels, levelWeights, scaleFactor) originally, but it gives me error that says the fourth argument can't be float, which made suspect I wasn't using the function I thought I was using. 我最初尝试使用detectMultiScale(image, rejectLevels, levelWeights, scaleFactor) ,但这给了我一个错误,即第四个参数不能为float,这使我怀疑我没有使用我以为正在使用的函数。

I use pip to install opencv-python which is version 3.3.0.9. 我使用pip安装版本3.3.0.9的opencv-python。 I couldn't find any python documents other than this webpage . 除此网页外,我找不到任何python文档。

Appreciate some help. 感谢一些帮助。 Like where can I find documents for latest python api, or some experience with this particular function. 就像我在哪里可以找到最新python api的文档,或对该特定功能有一些经验。

It's pretty hard to find python documentation for OpenCV 3.3 but the OpenCV3.0 docs show that detectMultiScale uses ouputRejectLevels . 很难找到适用于OpenCV 3.3的python文档,但OpenCV3.0 文档显示detectMultiScale使用ouputRejectLevels Try using that argument. 尝试使用该参数。

Here's their breakdown: 这是他们的细分:

Python: cv2.CascadeClassifier.detectMultiScale(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]) → objects Python:cv2.CascadeClassifier.detectMultiScale(image [,scaleFactor [,minNeighbors [,flags ,, minSize [,maxSize]]]]]))→对象

Python: cv2.CascadeClassifier.detectMultiScale2(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]) → objects, numDetections Python:cv2.CascadeClassifier.detectMultiScale2(image [,scaleFactor [,minNeighbors [,flags [,minSize [,maxSize]]]]])→对象,numDetections

Python: cv2.CascadeClassifier.detectMultiScale3(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize[, outputRejectLevels]]]]]]) → objects, rejectLevels, levelWeights Python:cv2.CascadeClassifier.detectMultiScale3(image [,scaleFactor [,minNeighbors [,flags [,minSize [,maxSize [,outputRejectLevels]]]]]]))→对象,rejectLevels,levelWeights

While the online documentation for the recent versions of OpenCV does not list information about the Python bindings, it is quite simple to find it -- it's embedded right in the Python module. 虽然有关OpenCV的最新版本的在线文档未列出有关Python绑定的信息,但找到它非常简单-它直接嵌入在Python模块中。 At the least you will get the signatures of the methods in question. 至少您将获得有关方法的签名。

Use the build-in help() function to access it. 使用内置的help()函数进行访问。

For example (not that this is OpenCV 3.1, so double check it locally): 例如(不是这是OpenCV 3.1,因此请在本地仔细检查):

>>> import cv2
>>> c = cv2.CascadeClassifier()
>>> help(c.detectMultiScale)
Help on built-in function detectMultiScale:

detectMultiScale(...)
    detectMultiScale(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]) -> objects

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM