Are you sure you want to delete this access key?
comments | description | keywords |
---|---|---|
true | Learn how to crop and extract objects using Ultralytics YOLO11 for focused analysis, reduced data volume, and enhanced precision. | Ultralytics, YOLO11, object cropping, object detection, image processing, video analysis, AI, machine learning |
Object cropping with Ultralytics YOLO11 involves isolating and extracting specific detected objects from an image or video. The YOLO11 model capabilities are utilized to accurately identify and delineate objects, enabling precise cropping for further analysis or manipulation.
Watch: Object Cropping using Ultralytics YOLO
Airport Luggage |
---|
![]() |
Suitcases Cropping at airport conveyor belt using Ultralytics YOLO11 |
!!! example "Object Cropping using Ultralytics YOLO"
=== "CLI"
```bash
# Crop the objects
yolo solutions crop show=True
# Pass a source video
yolo solutions crop source="path/to/video.mp4"
# Crop specific classes
yolo solutions crop classes="[0, 2]"
```
=== "Python"
```python
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("path/to/video.mp4")
assert cap.isOpened(), "Error reading video file"
# Initialize object cropper object
cropper = solutions.ObjectCropper(
show=True, # display the output
model="yolo11n.pt", # model for object cropping i.e yolo11x.pt.
classes=[0, 2], # crop specific classes i.e. person and car with COCO pretrained model.
# conf=0.5, # adjust confidence threshold for the objects.
# crop_dir="cropped-detections", # set the directory name for cropped detections
)
# Process video
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or processing is complete.")
break
results = cropper(im0)
# print(results) # access the output
cap.release()
cv2.destroyAllWindows() # destroy all opened windows
```
ObjectCropper
ArgumentsHere's a table with the ObjectCropper
arguments:
{% from "macros/solutions-args.md" import param_table %} {{ param_table(["model", "crop_dir"]) }}
Moreover, the following visualization arguments are available for use:
{% from "macros/visualization-args.md" import param_table %} {{ param_table(["show", "line_width"]) }}
Object cropping using Ultralytics YOLO11 involves isolating and extracting specific objects from an image or video based on YOLO11's detection capabilities. This process allows for focused analysis, reduced data volume, and enhanced precision by leveraging YOLO11 to identify objects with high accuracy and crop them accordingly. For an in-depth tutorial, refer to the object cropping example.
Ultralytics YOLO11 stands out due to its precision, speed, and ease of use. It allows detailed and accurate object detection and cropping, essential for focused analysis and applications needing high data integrity. Moreover, YOLO11 integrates seamlessly with tools like OpenVINO and TensorRT for deployments requiring real-time capabilities and optimization on diverse hardware. Explore the benefits in the guide on model export.
By using Ultralytics YOLO11 to crop only relevant objects from your images or videos, you can significantly reduce the data size, making it more efficient for storage and processing. This process involves training the model to detect specific objects and then using the results to crop and save these portions only. For more information on exploiting Ultralytics YOLO11's capabilities, visit our quickstart guide.
Yes, Ultralytics YOLO11 can process real-time video feeds to detect and crop objects dynamically. The model's high-speed inference capabilities make it ideal for real-time applications such as surveillance, sports analysis, and automated inspection systems. Check out the tracking and prediction modes to understand how to implement real-time processing.
Ultralytics YOLO11 is optimized for both CPU and GPU environments, but to achieve optimal performance, especially for real-time or high-volume inference, a dedicated GPU (e.g., NVIDIA Tesla, RTX series) is recommended. For deployment on lightweight devices, consider using CoreML for iOS or TFLite for Android. More details on supported devices and formats can be found in our model deployment options.
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?