【发布时间】:2018-08-25 03:39:18
【问题描述】:
我使用了来自this 链接的代码并成功完成了检测,但问题是它仅来自网络摄像头。我试图修改代码,以便它可以从文件中读取。我修改的部分是:我已经写了这个
print("[INFO] starting video stream...")
vs= cv2.VideoCapture('cars.avi')
time.sleep(2.0)
fps = FPS().start()
# loop over the frames from the video stream
while True:
# grab the frame from the threaded video stream and resize it
# to have a maximum width of 400 pixels
frame = vs.read()
而不是这个(来自上述链接的代码)
print("[INFO] starting video stream...")
vs = VideoStream(src=0).start()
time.sleep(2.0)
fps = FPS().start()
# loop over the frames from the video stream
while True:
# grab the frame from the threaded video stream and resize it
# to have a maximum width of 400 pixels
frame = vs.read()
为了从终端运行程序,我在这两种情况下都使用这个命令:
python real_time_object_detection.py --prototxt
MobileNetSSD_deploy.prototxt.txt --model MobileNetSSD_deploy.caffemodel
从文件读取时遇到的错误是
我得到的错误是:
C:\Users\DEBASMITA\AppData\Local\Programs\Python\Python35\real-time-object-
detection>python videoobjectdetection.py --prototxt
MobileNetSSD_deploy.prototxt.txt --model MobileNetSSD_deploy.caffemodel
[INFO] loading model...
Traceback (most recent call last):
File "videoobjectdetection.py", line 54, in <module>
frame = imutils.resize(frame, width=400)
File "C:\Users\DEBASMITA\AppData\Local\Programs\Python\Python35\lib\site-
packages\imutils\convenience.py", line 69, in resize
(h, w) = image.shape[:2]
AttributeError: 'tuple' object has no attribute 'shape'
我不知道我在哪里做错了。请指导我。
【问题讨论】:
-
查看两个应用程序中 vs 的格式并找出不同之处。
-
你能解释一下吗?我是该领域的新手,并将其作为我的 mtech 项目进行
-
对不起,我的意思是:查看两个应用程序中“框架”的格式并找出差异。您可能无法期望 VideoStream 和 cv2.VideoCapture 提供具有相同属性/格式的图像。
-
好的..检查一下
-
Micka 我的问题解决了。是的,问题出在视频捕捉中。我必须使用 FileVideoStream 而不是 VideoStream 并完成
标签: python opencv deep-learning object-detection video-tracking