当前位置: 首页 > wzjs >正文

邯郸市出租房屋信息网百度关键词相关性优化软件

邯郸市出租房屋信息网,百度关键词相关性优化软件,哪有做外单的图片素材网站,自助建站平台免费TrackZone 使用Ultralytics YOLO11 -Ultralytics YOLO 文档 如何通过Ultralytics YOLO11 在Python 中使用 TrackZone? 只需几行代码,您就可以在特定区域设置对象跟踪,从而轻松将其集成到您的项目中。 import cv2from ultralytics import s…

TrackZone 使用Ultralytics YOLO11 -Ultralytics YOLO 文档

如何通过Ultralytics YOLO11 在Python 中使用 TrackZone?

只需几行代码,您就可以在特定区域设置对象跟踪,从而轻松将其集成到您的项目中。

import cv2from ultralytics import solutionscap = cv2.VideoCapture("path/to/video.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))# Define region points
region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)]# Video writer
video_writer = cv2.VideoWriter("object_counting_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))# Init trackzone (object tracking in zones, not complete frame)
trackzone = solutions.TrackZone(show=True,  # display the outputregion=region_points,  # pass region pointsmodel="yolo11n.pt",
)# Process video
while cap.isOpened():success, im0 = cap.read()if not success:print("Video frame is empty or video processing has been successfully completed.")breakresults = trackzone(im0)video_writer.write(results.plot_im)cap.release()
video_writer.release()
cv2.destroyAllWindows()

效果图:只检测一定范围内的人

部分相关库代码

# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/licenseimport cv2
import numpy as npfrom ultralytics.solutions.solutions import BaseSolution, SolutionAnnotator, SolutionResults
from ultralytics.utils.plotting import colorsclass TrackZone(BaseSolution):"""A class to manage region-based object tracking in a video stream.This class extends the BaseSolution class and provides functionality for tracking objects within a specific regiondefined by a polygonal area. Objects outside the region are excluded from tracking.Attributes:region (np.ndarray): The polygonal region for tracking, represented as a convex hull of points.line_width (int): Width of the lines used for drawing bounding boxes and region boundaries.names (List[str]): List of class names that the model can detect.boxes (List[np.ndarray]): Bounding boxes of tracked objects.track_ids (List[int]): Unique identifiers for each tracked object.clss (List[int]): Class indices of tracked objects.Methods:process: Processes each frame of the video, applying region-based tracking.extract_tracks: Extracts tracking information from the input frame.display_output: Displays the processed output.Examples:>>> tracker = TrackZone()>>> frame = cv2.imread("frame.jpg")>>> results = tracker.process(frame)>>> cv2.imshow("Tracked Frame", results.plot_im)"""def __init__(self, **kwargs):"""Initialize the TrackZone class for tracking objects within a defined region in video streams.Args:**kwargs (Any): Additional keyword arguments passed to the parent class."""super().__init__(**kwargs)default_region = [(150, 150), (1130, 150), (1130, 570), (150, 570)]self.region = cv2.convexHull(np.array(self.region or default_region, dtype=np.int32))def process(self, im0):"""Process the input frame to track objects within a defined region.This method initializes the annotator, creates a mask for the specified region, extracts tracksonly from the masked area, and updates tracking information. Objects outside the region are ignored.Args:im0 (np.ndarray): The input image or frame to be processed.Returns:(SolutionResults): Contains processed image `plot_im` and `total_tracks` (int) representing thetotal number of tracked objects within the defined region.Examples:>>> tracker = TrackZone()>>> frame = cv2.imread("path/to/image.jpg")>>> results = tracker.process(frame)"""annotator = SolutionAnnotator(im0, line_width=self.line_width)  # Initialize annotator# Create a mask for the region and extract tracks from the masked imagemask = np.zeros_like(im0[:, :, 0])mask = cv2.fillPoly(mask, [self.region], 255)masked_frame = cv2.bitwise_and(im0, im0, mask=mask)self.extract_tracks(masked_frame)# Draw the region boundarycv2.polylines(im0, [self.region], isClosed=True, color=(255, 255, 255), thickness=self.line_width * 2)# Iterate over boxes, track ids, classes indexes list and draw bounding boxesfor box, track_id, cls in zip(self.boxes, self.track_ids, self.clss):annotator.box_label(box, label=f"{self.names[cls]}:{track_id}", color=colors(track_id, True))plot_im = annotator.result()self.display_output(plot_im)  # display output with base class function# Return a SolutionResultsreturn SolutionResults(plot_im=plot_im, total_tracks=len(self.track_ids))

http://www.dtcms.com/wzjs/139370.html

相关文章:

  • 南京高端网站建设哪家好seo排名优化首页
  • 企业网站建设的类型长沙网站制作主要公司
  • 深圳学校网站建设公司如何制作网页链接教程
  • 做网站台式还是笔记本沧州百度推广公司
  • 深圳公司网站制作seo网络推广公司报价
  • 个人的视频网站如何做优化方案
  • 国内cms排行台州seo
  • 中国设计品牌网seo快速优化文章排名
  • 做英文网站可以申请补贴吗营销到底是干嘛的
  • 最新廊坊疫情最新消息百度seo官网
  • 注册公司有什么好处有什么坏处上海站群优化公司
  • 中国交通建设集团有限公司英文名重庆seo博客
  • 网站登录注册怎么做seo的优化步骤
  • 上海做网站 公司有哪些互联网营销的方法
  • 怎么自己做砍价网站如何做好品牌宣传
  • 宁波网站建设服务公司电话如何提高网站排名
  • 上海松江做网站企业网站制作流程
  • 又一个wordpress站点建立网站需要多少钱
  • 网站内页怎样做优化互联网运营主要做什么
  • 政府网站建设与管理官网凡科网微信小程序
  • 关于做网站pptseo点击器
  • 昆明做网站排名镇江推广公司
  • 高质量摄影作品网站软文广告属于什么营销
  • 配资网站建设是什么意思seo关键词排名优化评价
  • 网站降权怎么救青岛网站排名公司
  • 知名网站建设商家上海百度推广优化排名
  • 佛山网站开发公司360搜索引擎
  • 手机网站建设推广方案网销是什么工作好做吗
  • 竞价网站策划免费网站制作教程
  • 如何制作app软件游戏搜索引擎优化方法案例