opencv - (success, box) = tracker.update(frame) cv2.error: OpenCV(4.5.1669: error: (-209:Sizes of input arguments do not match)
问题描述
请检查一下,我正在使用 python 3.9 和 OpenCV 4.5.1.48
**tracker = OPENCV_OBJECT_TRACKERS"kcf" while True: # 抓取当前帧,如果我们使用的是 VideoStream 或 VideoCapture 对象则处理 ret,frame = vs.read() (H, W) = frame.shape[:2 ] #h=480 w=640 #print(H,W) if imagee is not None: # 抓取物体的新边界框坐标 tracker.init(frame, imagee)
fps = FPS().start()
(success, box) = tracker.update(frame)
keypoints_sift1, descriptors1 = orb.detectAndCompute(frame, None)
try:
matches = bf.match(descriptors,descriptors1)
#frame = cv2.drawMatches(frame,keypoints_sift1,imcorp,keypoints_sift,matches[::], None,flags=2)
# check to see if the tracking was a success
if success:
(x, y, w, h) = [int(v) for v in box]
cv2.rectangle(frame, (x, y), (x + w, y + h),(0, 255, 0), 2)
newx=(x+x+w)/2
newy=(y+y+h)/2
except:
pass
# update the FPS counter
fps.update()
fps.stop()
# initialize the set of information we'll be displaying on
# the frame
info = [
("Tracker", "tld"),
("Success", "Yes" if success else "No"),
("FPS", "{:.2f}".format(fps.fps())),
]
# loop over the info tuples and draw them on our frame
for (i, (k, v)) in enumerate(info):
text = "{}: {}".format(k, v)
cv2.putText(frame, text, (10, H - ((i * 20) + 20)),cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 0, 255), 2)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF**
解决方案
推荐阅读
- python - Python re.findall 组织列表
- pandas - 是否有 pandas 功能可以获取 None 而不是索引错误?
- r - R ggplot2:对数转换数据的自定义 y 轴刻度标签?
- sql - 在 Oracle SQL 中使用查询的 Cast 和 Case 语句
- tensorflow - 张量流安装问题
- python - 使用 project.toml 配置 isort 和 autoflake
- r - 在移动到下一列之前是否有读取特定值的 R 代码?
- reactjs - ReactTags 是否适用于 React 16.12 应用程序?
- amazon-web-services - AWS Cloudfront 无法访问使用 CodeBuild 部署的 S3 文件
- arrays - 将数组拆分为不同大小的 N 块