python - Pydoc 忽略 opencv 函数,只考虑使用 def 关键字定义的 python 函数
问题描述
我想为我的 OpenCV 项目开发 API 文档。
但是当我pydoc - w
在我的模块上运行命令时,它只为那些用 def 关键字声明的函数创建了文档。
Pydoc 忽略 OpenCV 函数,例如cv2.videocaputure()
. 它们不包含在文档中。
def initState(A, B, C, D, E, P1, P2, P3, P4, P5):
"""if all blocks are there and good recognized, if not shows message.
:param: The number of objects
:type: int
:putText()
:return: intial state top or initial state reconized with all objects,
show text on window Sorry , objects not recognized(Text)
"""
if (A == 1 and B == 1 and C == 1 and D == 1 and E == 1 and P1 == 1 and P2 == 1 and P3 == 1 and P4 == 1 and P5 == 1):
cv2.putText(frame, "initial state top",
(100, 100), font, 1, (0, 0, 255))
else:
cv2.putText(frame, "Sorry, not recognized",
(100, 100), font, 1, (0, 0, 255))
# knowing if final state is completed, must be recognized in the moment, if not recognized nothing will be shown
def finalState(A, B, C, D, E, P1, P2, P3, P4, P5):
"""knowing if final state is completed, must be recognized in the moment, if not recognized nothing will be shown.
:param: The number of objects
:type: int
:putText()
:return: Final state reconized with all objects(Text),
"""
if (A == 1 and B == 1 and C == 1 and D == 1 and E == 1 and P1 == 1 and P2 == 1 and P3 == 1 and P4 == 1 and P5 == 1):
cv2.putText(frame, "final state top", (100, 100), font, 1, (0, 0, 255))
return 1
# capturing video, if want to change file or do it with a web cam just change the value
cap = cv2.VideoCapture('exp11111.mp4')
"""
This will simply create the object
for the camera and using this object we can control the
video capturing and other functions related to the web cam.
:param: can be either the device index or the name of a video file
"""
# starting while loop to recognize every frame.
while True:
ret, frame = cap.read()
if(
ret == False):
break
"""
Capture frame-by-frame
:return: bool (True,False)
"""
解决方案
我无法重现。
我拿走了你的代码并伪造了cv.py
class VideoCapture:
def __init__(self, *args, **kwargs):
pass
def read(self):
pass
def putText(*args, **kwargs):
pass
然后跑:
python -m pydoc -w your_code
我进入cap = <cv2.VideoCapture object>
了输出。
如果您还想为 cv2 生成文档,您将需要:
python -m pydoc -w cv2
如果不分叉它或切换到许多更好的替代方案之一,例如 pdoc3、pydoctor 或 pycco,就很难让 pydoc 做你想做的事。
推荐阅读
- python - Tkinter 视频流在按钮命令后冻结
- javascript - 合并两个相似的 JSON 对象,但一个在 NodeJS 中有更多键
- c# - 在 64 位环境中从 Excel VBA 引用 C# proc(内置 32 位环境)
- javascript - 通过 Ember.js 中的控制器将附加数据加载到模型中
- r - 在 Rstudio/AWS linux 服务器上安装 readr 包
- java - 使用嵌套的 For 循环将两个带有数字值的字符串数组“相加”在一起
- python - 在 pandas groupby 之后只过滤少数组元素
- reactjs - 如何使用 styled-components 传递道具
- lua - 分隔/计算字符串中的行
- ios - 如何在运行 iOS 11 或更低版本的 iOS 模拟器中显示自定义字体?