因为我使用过,cv2.namedWindow('Frame', cv2.WINDOW_NORMAL)所以我可以在运行时调整窗口大小,但我也想打印新的窗口大小。有谁能帮忙吗?
更新:这不是完整的代码,但它是这样的
cap = cv2.VideoCapture(0)
cv2.namedWindow('Frame', cv2.WINDOW_NORMAL)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
cv2.imshow('Frame',frame)
print(frame.shape) #prints image dimension
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
即使我调整了窗口大小,它仍然在打印 (480, 640, 3)
我遵循了本教程:https : //www.pyimagesearch.com/2017/09/11/object-detection-with-deep-learning-and-opencv/ 我改变了这部分,在插入之前将图像源转换为灰度到神经网络
frame = vs.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = imutils.resize(frame, width=400)
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(cv2.resize(frame, (300, 300)),
0.007843, (300, 300), 127.5)
net.setInput(blob)
detections = net.forward()
Run Code Online (Sandbox Code Playgroud)
但是会出现这个错误:
OpenCV(3.4.1) Error: Assertion failed (ngroups > 0 && inpCn % ngroups == 0 && outCn % ngroups == 0) in cv::dnn::ConvolutionLayerImpl::getMemoryShapes, file D:\Build\OpenCV\opencv-3.4.1\modules\dnn\src\layers\convolution_layer.cpp, line 234
Traceback (most recent call last):
File "C:/Users/Toshiba/PycharmProjects/real-time-object-detection/study7ver2.py", line 75, in <module>
detections = net.forward()
cv2.error: OpenCV(3.4.1) D:\Build\OpenCV\opencv-3.4.1\modules\dnn\src\layers\convolution_layer.cpp:234: error: (-215) ngroups > …Run Code Online (Sandbox Code Playgroud)