我正在尝试使用Python OpenCV绑定(CV2,新绑定)缩小图像:
ret, frame = cap.read()
print frame.shape
# prints (720, 1280, 3)
smallsize = (146,260)
smallframe = cv2.resize(frame, smallsize)
print smallframe.shape
# prints (260, 146, 3)
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,尺寸最终会在缩小的图像上翻转.而不是返回尺寸为(WxH)146x260的图像,而是获得260x146.
是什么赋予了?
我正在阅读python项目的sourcode,并遇到以下行:
from couchexport.export import Format
Run Code Online (Sandbox Code Playgroud)
(来源:https://github.com/wbnigeria/couchexport/blob/master/couchexport/views.py#L1)
我去couchexport/export.py看看是什么Format(Class?Dict?还有什么?).不幸的Format是不在那个文件中. export.py然而不导入Format从couchexport.models那里是一个Format类(来源:https://github.com/wbnigeria/couchexport/blob/master/couchexport/models.py#L11).
当我在IDE中打开原始文件并让它查找声明时,在本问题开头提到的第一行中,它直接导致models.py.
这是怎么回事?如何从一个文件(export.py)导入实际上是从另一个文件(models.py)导入而没有明确说明?