Ultralytics YOLO26によるTrackZone
TrackZoneとは?#
TrackZoneは、フレーム全体ではなく、指定した領域内の物体を監視することに特化しています。Ultralytics YOLO26を基盤とし、動画やライブカメラ映像のゾーン内における物体検出とトラッキングを統合しています。YOLO26はディープラーニングによる検出とトラッキングをリアルタイムで行うため、TrackZoneは人流監視や監視業務などに適しています。
視聴: Ultralytics YOLO26 で領域内の物体を追跡する方法 | TrackZone 🚀
ゾーン内の物体追跡(TrackZone)のメリット#
- 対象を絞った分析: 特定のゾーン内で物体を追跡すると、より焦点を絞ったインサイトが得られます。入口や立入制限区域など、関心のあるエリアを正確に監視・分析できます。
- 後続処理の負荷軽減: ゾーン外の物体を無視することで、TrackZoneは無関係な検出結果を除外します。そのため、その結果を利用して構築するロジックで、カウント、記録、アラートの対象となる物体が少なくなります。検出はゾーンを厳密に切り抜いた画像ではなく、マスクを適用した元のサイズのフレーム上で引き続き実行されるため、メリットはモデル推論の高速化ではなく、出力がより明確になり、対象を絞れることです。
- セキュリティの強化: ゾーン追跡では、重要なエリアを監視することで監視機能を向上させ、異常な活動やセキュリティ侵害の早期検知に役立ちます。
- 拡張性の高いソリューション: 特定のゾーンに対象を絞り込めるため、小売スペースから産業環境まで、さまざまな状況にTrackZoneを適用できます。
実際の用途#
| 農業 | 交通 |
|---|---|
![]() | ![]() |
| Ultralytics YOLO26による農地の植物追跡 | Ultralytics YOLO26による道路上の車両追跡 |
# Run a trackzone example
yolo solutions trackzone show=True
# Pass a source video
yolo solutions trackzone source="path/to/video.mp4" show=True
# Pass region coordinates
yolo solutions trackzone show=True region="[(150, 150), (1130, 150), (1130, 570), (150, 570)]"TrackZoneは、監視するフレーム内の領域を把握するためにregionリストを使用します。対象とする物理的なゾーン(ドア、ゲートなど)に合わせてポリゴンを定義し、設定時にはshow=Trueを有効にして、オーバーレイが動画フィードと一致することを確認してください。
regionの各エントリーは、動画フレーム内の(x, y)ピクセル座標です。監視対象エリアの外周に沿って接続する順序でポイントを列挙してください。- 座標はフレーム解像度に依存するため、1280×720の映像用に設定した領域は640×480の映像には一致しません。設定時には
show=Trueを有効にして、オーバーレイが映像フィードと一致することを確認してください。 TrackZoneはポイントを凸包に変換するため、凹形状はすべてのポイントを含む最小の凸多角形に単純化されます。非凸形状や複数の個別領域には、代わりにRegionCounterソリューションを使用してください。regionを省略すると、デフォルトゾーンとして[(75, 75), (565, 75), (565, 285), (75, 285)]が使用されます。
TrackZoneの引数#
TrackZoneの引数を以下の表に示します。
| 引数 | 種類 | デフォルト | 説明 |
|---|---|---|---|
model | str | None | Ultralytics YOLOモデルファイルへのパスです。 |
region | listまたはdict | None | 関心領域を定義するポイントです。(x, y)タプルのリスト、または複数領域用に領域名とポイントリストを対応付ける辞書(RegionCounterのみ)を指定します。Noneの場合、領域が必要なSolutionsでは定義済みのデフォルト値が使用されます。 |
line_width | int | 2 | Solutionが描画するボックス、キーポイント、カウント表示の線幅です。 |
verbose | bool | True | 各フレームの入力shape、クラス数、処理速度を記録するSolutionのログを有効にします。トラッキング呼び出し自体は常にログを出力しません。 |
TrackZoneソリューションは、trackパラメーターをサポートしています。
| 引数 | 種類 | デフォルト | 説明 |
|---|---|---|---|
tracker | str | 'tracktrack.yaml' | 使用するトラッキングアルゴリズムを指定します。組み込みのオプション:botsort.yaml、bytetrack.yaml、ocsort.yaml、deepocsort.yaml、fasttrack.yaml、tracktrack.yaml。 |
conf | float | 0.25 | 検出の信頼度しきい値を設定します。値を低くすると、より多くの物体を追跡できますが、誤検出が含まれる可能性があります。 |
iou | float | 0.5 | 重複する検出をフィルタリングするためのIntersection over Union(IoU)しきい値を設定します。 |
classes | list | None | クラスインデックスで結果をフィルタリングします。たとえば、classes=[0, 2, 3]を指定すると、指定したクラスのみを追跡します。 |
device | str | None | 推論に使用するデバイスを指定します(例:cpu、cuda:0、0)。モデル実行に使用するCPU、特定のGPU、その他の計算デバイスを選択できます。 |
imgsz | int or tuple | 640 | 推論時の入力画像サイズです。正方形の場合は整数、または(height, width)のペアを指定します。形状はモデルのストライドに合わせて調整されます。 |
max_det | int | 300 | トラッキング前にフレームごとに保持する検出の最大数です。混雑したシーンでソリューションが処理する物体数を制限します。 |
quantize | int or str | None | 推論精度: CPU以外で実行するPyTorchおよびTorchScriptモデルでは、16(FP16)または32/未設定(FP32)を使用します。その他の形式では、アーティファクトとランタイムによって選択される精度が使用されます。非推奨のhalf引数を置き換えます。 |
さらに、以下の可視化オプションを使用できます。
| 引数 | 種類 | デフォルト | 説明 |
|---|---|---|---|
show | bool | False | Trueの場合、注釈付き画像または動画をウィンドウに表示します。開発やテスト中にすぐ視覚的なフィードバックを得るのに便利です。 |
show_conf | bool | True | 各検出のラベルとともに信頼度スコアを表示します。各検出に対するモデルの確信度を確認できます。 |
show_labels | bool | True | 可視化出力で各検出のラベルを表示します。検出されたオブジェクトをすぐに把握できます。 |
ゾーン内の物体をカウント#
トラッカーを呼び出すたびにSolutionResultsオブジェクトが返されます。このオブジェクトのtotal_tracks属性には、ゾーン内で現在追跡されている物体の数が格納されています。各フレームで値を読み取ることで、ライブの利用状況を監視できます。たとえば、入口や立入制限区域の混雑状況を記録できます。
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("path/to/video.mp4")
assert cap.isOpened(), "Error reading video file"
region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)]
trackzone = solutions.TrackZone(show=False, region=region_points, model="yolo26n.pt")
while cap.isOpened():
success, im0 = cap.read()
if not success:
break
results = trackzone(im0)
print(f"Objects currently in zone: {results.total_tracks}") # live zone occupancy
cap.release()よくある質問#
ゾーン内の物体のみを追跡するには、以下のコマンドを実行し、ゾーンの座標を設定するために
regionを渡します。監視、人流管理、またはゾーン単位のトラッキングが必要なあらゆる状況に適しています。yolo solutions trackzone source="path/to/video.mp4" show=True数行のコードだけで特定のゾーン内の物体追跡を設定できるため、プロジェクトに簡単に統合できます。
import cv2 from ultralytics import solutions cap = 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)) video_writer = cv2.VideoWriter("trackzone_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h)) trackzone = solutions.TrackZone( show=True, region=[(150, 150), (1130, 150), (1130, 570), (150, 570)], model="yolo26n.pt" ) while cap.isOpened(): success, im0 = cap.read() if not success: break results = trackzone(im0) video_writer.write(results.plot_im) cap.release() video_writer.release() cv2.destroyAllWindows()Ultralytics TrackZoneを使用した動画処理では、ゾーンのポイントを簡単にカスタマイズして設定できます。Pythonスクリプトでゾーンを直接定義・調整することで、監視対象エリアを正確に制御できます。
from ultralytics import solutions # 領域のポイントを定義 region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)] # TrackZoneを初期化 trackzone = solutions.TrackZone( show=True, # 出力を表示する region=region_points, # 領域の点を渡す )TrackZoneはポイントを凸包に変換するため、凹形の輪郭はすべてのポイントを含む最小の凸多角形に単純化される点に注意してください。3つのソリューションはすべて領域を扱いますが、それぞれ異なる用途に対応しています。
ソリューション 用途 一般的な出力 TrackZone 単一の凸ゾーン内で物体を追跡し、現在の利用状況を監視します 追跡対象のIDと、ゾーンの total_tracksObjectCounter ラインを横切る物体や、領域に出入りする物体をカウントします 累積入退場数 RegionCounter 1つ以上の任意の領域(非凸形状を含む)内の物体をカウントします 領域ごとの物体数 1つのエリア内で継続的に追跡する場合はTrackZoneを、複数のゾーンや非凸形状が必要な場合はRegionCounterを選択してください。
コメント40
質問したり、結果を共有したり、ほかの人をサポートしたりできます。
Paul231200
Hello, great development, but I had a question about the advantages of your solution in comparison with the regions of interest that can be done in Opencv, also the question is whether it is planned to add this development to such models as yolov8?
1
Glenn JocherUltralytics(編集済み)@Paul231200 thank you for your question! TrackZone offers targeted and efficient region-based tracking, reducing computational overhead compared to general frame analysis in OpenCV. As for YOLOv8, TrackZone works with any Ultralytics model you pass via
model=, including YOLOv8, though we recommend YOLO26 for new projects. For more details, you can explore TrackZone here: https://docs.ultralytics.com/guides/trackzone/.
moshiour
Hi, Its a nice feature to yolo! How do make it counting on top of it? Thank you in advance!
1
Glenn JocherUltralytics(編集済み)@moshiour thank you for your kind words!
TrackZonereturns a results object withtotal_tracks, the number of objects currently tracked inside the zone:results = trackzone(im0)thenresults.total_tracks. For counting objects entering or leaving a region, see the Object Counting guide. Let us know if you have more questions!1RizwanMunawar
@Muhammad-237 Hi, We currently don't support the counting feature with TrackZone, but It's on our TODO's list, and we will release this feature soon! Thank you! In the meantime, you can explore our documentation available at: https://docs.ultralytics.com/guides/object-counting/#__tabbed_1_1
biancalepe
Thank you for this informative resource! I have a question - am I able to obtain the unique IDs of identified objects within 20 second windows? In this case, I'd like to know how many unique cars in total were in my zone for each 20 second time period of my video.
Below is my starting code:
def count_specific_classes(video_path, output_video_path, model_path, classes_to_count, region_points):
"""Count specific classes of objects in a video.""" cap = cv2.VideoCapture(video_path) assert cap.isOpened(), "Error reading video file" # Video writer w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS)) video_writer = cv2.VideoWriter(output_video_path, cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h)) # Initiate TrackZone (object tracking in zones, not complete frame) trackzone = solutions.TrackZone(show=True, # Display the output region=region_points, # pass the region points model=model_path, # use any model that Ultralytics supports classes=classes_to_count) # which objects to track # Process video while cap.isOpened(): success, im0 = cap.read() if not success: print("Video frame is empty or processing is complete.") break results = trackzone(im0) #print (results) # access the output video_writer.write(results.plot_im) # write the video output cap.release() video_writer.release() cv2.destroyAllWindows() # destroy all open windows
Glenn JocherUltralytics(編集済み)@biancalepe you can access unique track IDs from
trackzone.track_idsand implement time-based windowing for counting. Here's how to modify your code to count unique cars in 20-second intervals:def count_unique_cars_by_time_window(video_path, output_video_path, model_path, classes_to_count, region_points, window_seconds=20): cap = cv2.VideoCapture(video_path) 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)) video_writer = cv2.VideoWriter(output_video_path, cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h)) trackzone = solutions.TrackZone( show=True, region=region_points, model=model_path, classes=classes_to_count ) frame_count = 0 window_frame_count = window_seconds * fps # frames per 20-second window current_window = 1 unique_ids_in_window = set() window_results = [] while cap.isOpened(): success, im0 = cap.read() if not success: break results = trackzone(im0) # Track IDs of the objects currently inside the zone unique_ids_in_window.update(trackzone.track_ids) frame_count += 1 # Check if window is complete if frame_count >= window_frame_count: unique_count = len(unique_ids_in_window) window_results.append(f"Window {current_window} ({window_seconds - 20}-{window_seconds}s): {unique_count} unique cars") print(f"Window {current_window}: {unique_count} unique cars detected") # Reset for next window unique_ids_in_window.clear() current_window += 1 frame_count = 0 window_seconds += 20 video_writer.write(results.plot_im) # Handle final incomplete window if unique_ids_in_window: unique_count = len(unique_ids_in_window) print(f"Final window: {unique_count} unique cars detected") cap.release() video_writer.release() cv2.destroyAllWindows() return window_resultsThis tracks unique car IDs within each 20-second window and provides counts for analysis.
biancalepe
Thank you!
Running the code, I see that cars exist in the twenty second windows but the code returns back zero cars for all windows. As I was trying to parse out the code, I printed results.boxes and I get this error --> AttributeError: 'SolutionResults' object has no attribute 'boxes'. I get a similar error when I try to print out results.boxes.id. Printing results seems to get me a "total_tracks" and a "speed" option, but nothing else. Is there something I should be doing?
RizwanMunawar(編集済み)
@biancalepe If you want to retrieve the IDs of tracked objects in a specific Zone (these will be unique), you can use the code mentioned below. Please note SolutionResults class includes the data highlighted here. Track IDs can be extracted directly by Solution Object, i.e,
trackzone.track_ids. Thanksimport cv2 from ultralytics import solutions cap = cv2.VideoCapture("path/to/video.mp4") assert cap.isOpened(), "Error reading video file" # Define region points region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)] # Video writer w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS)) video_writer = cv2.VideoWriter("trackzone_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 output region=region_points, # pass region points model="yolo11n.pt", # use any model that Ultralytics support, i.e. YOLOv9, YOLOv10 # line_width=2, # adjust the line width for bounding boxes and text display ) # Process video while cap.isOpened(): success, im0 = cap.read() if not success: print("Video frame is empty or processing is complete.") break results = trackzone(im0) print(trackzone.track_ids) # access the track_ids video_writer.write(results.plot_im) # write the video file cap.release() video_writer.release() cv2.destroyAllWindows() # destroy all opened windowsbiancalepe
Sorry @muhammadrizwanmunawar the reason I was doing the print statements is because I was trying to figure out why the first block of code written by @glenn-jocher wasn't working. I isolated the problem to the extract IDs from results part. Using your code and glenn's I updated that section to be the code below, which seems to have fixed the problem:
Extract track IDs from results
if trackzone.track_ids is not None: track_ids = trackzone.track_ids unique_ids_in_window.update(track_ids)1
Glenn JocherUltralytics@biancalepe excellent troubleshooting! You've correctly identified that track IDs should be accessed via
trackzone.track_idsrather than from theresultsobject. This is the proper way to extract track IDs from TrackZone for time-windowed unique counting. Great job combining the solutions!
amoore1724
Can this be used to track two separate regions in the same frame?
RizwanMunawar(編集済み)
yes! Currently, we support the tracking objects in a single zone.
Caio PassosHi! I have a question. In the docs, it says TrackZone supports classes as parameters. I tried to limit TrackZone to only detect the class 0 (person).
heres the code, almost like the example in docs:
import cv2 from ultralytics import solutions, YOLO cap = cv2.VideoCapture( "/path_to_video.mp4" ) assert cap.isOpened(), "Error reading video file" # Define region points region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)] # Video writer w, h, fps = ( int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS) ) video_writer = cv2.VideoWriter( "trackzone_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 output region=region_points, # pass region points model="yolo11n.pt", names=[0], # use any model that Ultralytics support, i.e. YOLOv9, YOLOv10 line_width=1, # adjust the line width for bounding boxes and text display ) print(f" model class names: {trackzone.model.names}") # Process video while cap.isOpened(): success, im0 = cap.read() if not success: print("Video frame is empty or processing is complete.") break results = trackzone(im0) # print(results) # access the output video_writer.write(results.plot_im) # write the video file cap.release() video_writer.release() cv2.destroyAllWindows() # destroy all opened windowsit runs without any issue, but still detecting other classes like backpacks, for example. Can you provide some extra details on how to limit detections for person class only?
RizwanMunawar
@caio-passos Hi, thanks for sharing it. The actual argument to set classes is
classes, notnames,as mentioned in the documentation here: https://docs.ultralytics.com/guides/trackzone/#trackzone-arguments. Let me know if you have any questions. Thanks
Caio PassosThanks!! I've changed it in the code:
trackzone = solutions.TrackZone( show=True, # display the output region=region_points, # pass region points model="yolo11n.pt", classes=[0], # use any model that Ultralytics support, i.e. YOLOv9, YOLOv10 line_width=1, # adjust the line width for bounding boxes and text display )But it led to this error, something related to the size of the mask or tensor:
Traceback (most recent call last): File "/home/tarzan/Documents/programing/hive/aeroporto/track.py", line 38, in <module> results = trackzone(im0) ^^^^^^^^^^^^^^ File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/ultralytics/solutions/solutions.py", line 195, in __call__ result = self.process(*args, **kwargs) # Call the subclass-specific process method ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/ultralytics/solutions/trackzone.py", line 73, in process self.extract_tracks(masked_frame) File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/ultralytics/solutions/solutions.py", line 120, in extract_tracks self.tracks = self.model.track(source=im0, persist=True, classes=self.classes, **self.track_add_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 593, in track return self.predict(source=source, stream=stream, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 549, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 218, in __call__ return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Result into one ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/ultralytics/engine/predictor.py", line 336, in stream_inference self.results = self.postprocess(preds, im, im0s) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/ultralytics/models/yolo/detect/predict.py", line 55, in postprocess preds = ops.non_max_suppression( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tarzan/Documents/programing/hive/aeroporto/.venv/lib/python3.12/site-packages/ultralytics/utils/ops.py", line 304, in non_max_suppression x, xk = x[filt], xk[filt] ~^^^^^^ IndexError: The shape of the mask [64] at index 0 does not match the shape of the indexed tensor [62, 6] at index 0I had experienced something similar with QueueManager before, but I couldn't figure it out where or what went wrong
RizwanMunawar
@caio-passos, which ultralytics version are you using?
Caio Passosit's ultralytics version 8.3.114
RizwanMunawar
@caio-passos, please upgrade the package with
pip install -U ultralytics. This error is already fixed in the latest version.1
Caio PassosIt solved the issue, thank you!! @RizwanMunawar
1
Parthpatil0024
Is there a way to use botsort without using the track method. how to do it if i am using a ncnn model format.
skyceeee
import cv2 import gc from ultralytics import solutions
Kamerayı başlat
cap = cv2.VideoCapture(0) assert cap.isOpened(), "Kamera açılırken hata oluştu!"
Kamera çözünürlüğünü belirle
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
Takip bölgesini tanımla (görüntü çözünürlüğüne uygun olmalı)
region_points = [(50, 50), (590, 50), (590, 430), (50, 430)]
TrackZone nesnesini başlat
trackzone = solutions.TrackZone( show=True, region=region_points, model="C:/yazilim/staj/trackzone/yolov8n480.pt", # Daha küçük model kullanıldı imgsz=480, # Model giriş boyutu sınırlandırıldı )
Canlı görüntü işleme döngüsü
while cap.isOpened(): success, frame = cap.read() if not success: print("Kamera görüntüsü alınamadı!") break
# Görüntüyü yeniden boyutlandır frame = cv2.resize(frame, (640, 480)) # TrackZone ile işlem yap try: processed_frame = trackzone.trackzone(frame) except Exception as e: print(f"Takip sırasında bir hata oluştu: {e}") break # Görüntüyü göster cv2.imshow("TrackZone Canlı Takip", processed_frame) # Bellek temizliği yap gc.collect() # 'q' tuşuna basarak çıkış yapabilirsiniz if cv2.waitKey(10) & 0xFF == ord('q'): breakKamera ve pencereyi serbest bırak
cap.release() cv2.destroyAllWindows()
This is my code. I use my own trained yolov8n model. When the camera is turned on, the area I drew also appears. No problems until then. But the moment a person enters the rectangle, the kernel dies. What could be the reason for this?My model does human detection. Error: The Kernel crashed while executing code in the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click here for more info. View Jupyter log for further details.
Glenn JocherUltralyticsThe kernel crash could be due to insufficient memory or a compatibility issue with your custom YOLOv8 model. Ensure your system has enough resources available, and verify that the model file is correctly configured for the
TrackZonesolution. Additionally, try reducing the input resolution further (e.g.,imgsz=320) to minimize memory usage. For further debugging, check the full error log and confirm that your model works with standardpredictfunctionality outside ofTrackZone.
nichamond143
Hi, I'm using TrackZone with a custom model, but it's not detecting the target object. However, when I crop the zone of interest from the example video and put it through the model it works fine. I also trained the model on zoomed in images of the object because the full-frame image is too noisey and the object is very small. Any advice on how to approach this?
Glenn JocherUltralytics@nichamond143 it sounds like the model's training on zoomed-in images may limit its ability to generalize to full-frame inputs. You could try pre-processing the video frames to crop and resize the zone of interest before passing them to the model. Alternatively, consider retraining the model with multi-scale images, including both zoomed-in and contextual full-frame examples, to improve its detection robustness.
UltralyticsAssistantUltralytics
👋 Hello, thank you for your interest in Ultralytics 🚀! It sounds like you're exploring how TrackZone uses YOLO models for object tracking and analysis – fascinating topic!
If this is a ❓ Question about custom implementations, feel free to share more details about your use case so our team or the community can better assist. If it's a 🐛 Bug Report or you need specific technical help, please provide a clear description, along with any code snippets, error messages, or logs. Including a minimum reproducible example (MRE) would greatly help us debug and offer guidance swiftly.
For general inquiries or tips on achieving optimal results, consider reviewing our resources on model training and usage. Additionally, you can join the Ultralytics community on platforms like Discord, Reddit, or Discourse for deeper interactions and advice.
Lastly, please ensure you're running the latest version of the
ultralyticspackage and all required dependencies to avoid encountering previously resolved issues. You can upgrade using thepip install -U ultralyticscommand.Thank you for being part of the Ultralytics community! 😊 An Ultralytics engineer will be here to assist you further shortly.
skyceeee
By converting the yolo model to tensorrt and setting coordinates in Jetson Nano, I track objects in a certain area with Jetson Nano. Can I use trackzone instead of adjusting coordinates myself? Is Jetson Nano supported?
Glenn JocherUltralytics@skyceeee yes, you can use TrackZone with Jetson Nano for targeted object tracking within specific areas, eliminating the need to adjust coordinates manually. TrackZone is compatible with YOLO models, including TensorRT-exported ones. Ensure you optimize your model for Jetson Nano's limited resources for best performance. More details on TrackZone can be found here.
1
skyceeee
Thanks so much for this feature. Is it possible to use this feature with tensorrt format in Jetson nano?
Glenn JocherUltralytics@skyceeee thank you for your question! Yes, you can use the TensorRT-exported YOLO models on the Jetson Nano, including for the TrackZone feature. First, export your YOLO11 model to TensorRT format using the
yolo exportcommand. Then, ensure your TensorRT runtime is properly set up on the Nano, and integrate the exported model into your tracking workflow. For more details, refer to the Export Documentation. Let us know if you encounter any issues!1

