Introduction
Computer vision is becoming increasingly useful in pharmaceutical manufacturing, quality control, and automated inspection systems. Detecting and monitoring pills in real-time can help automate tasks that traditionally require manual inspection.
In this project, I developed a real-time computer vision system for pill detection, object tracking, and color tracking using YOLO11 and ByteTrack.
The system processes video frames, detects pills using a YOLO11 object detection model, assigns persistent IDs to detected objects using ByteTrack, and analyzes their colors during the tracking process.
Why Pill Detection and Tracking؟
In pharmaceutical production lines, large numbers of pills may move continuously through a production or inspection area. Manual monitoring can be time-consuming and may be affected by human error.
An automated vision-based system can continuously monitor the production process and provide useful information such as:
The number of detected pills
The position of each pill
The movement of individual pills
The color of detected pills
Potential mismatches or abnormalities
This makes real-time computer vision a useful approach for developing automated inspection systems.
YOLO11 for Pill Detection
The first component of the system is YOLO11, a real-time object detection model developed by Ultralytics.
YOLO11 can be used for object detection, classification, segmentation, pose estimation, and other computer vision tasks. In this project, the model is used to identify pills in each video frame.
The official [Ultralytics YOLO11 documentation] provides further information about the model architecture, training, inference, and supported tasks.
The detection stage provides bounding boxes and confidence scores for the detected pills. These results are then passed to the tracking stage.

Object Tracking with ByteTrack
Detecting an object in every frame is not enough when the goal is to monitor its movement over time.
For this reason, the project uses ByteTrack for multi-object tracking.
ByteTrack associates detections across consecutive video frames and assigns a unique tracking ID to each detected object. This allows the system to distinguish between different pills and maintain their identities as they move through the video.
According to the official [Ultralytics tracking documentation], ByteTrack is a lightweight tracking approach that can be used with YOLO models for multi-object tracking.
This combination creates a simple but effective pipeline:
Video → YOLO11 Detection → ByteTrack Tracking → Color Analysis
From Biotechnology to Artificial Intelligence: My Journey into AI
Color Tracking
In addition to detecting and tracking pills, the system analyzes their colors.
Color information can be useful when different pills have different visual characteristics. By combining object detection with color analysis, the system can provide additional information about each tracked object.
The HSV color space is particularly useful for computer vision applications where color needs to be analyzed separately from brightness.
This approach can make the system more flexible for applications where color classification or color-based monitoring is required.
Key Features
The main capabilities of the project include:
Real-Time Detection
The system processes video frames continuously and detects pills automatically.
Multi-Object Tracking
ByteTrack allows multiple pills to be tracked simultaneously while maintaining individual tracking IDs.
Color Analysis
The system can analyze the color characteristics of detected pills and associate this information with tracked objects.
Automated Monitoring
Instead of manually monitoring every frame, the computer vision system can continuously analyze the video stream.

Extensible Architecture
The system can be extended with additional rules and detection modules for more advanced pharmaceutical inspection applications.
Potential Applications
A system like this could be adapted for several industrial applications, including:
Automated pharmaceutical inspection
Pill counting
Color-based pill classification
Production-line monitoring
Quality-control assistance
Detection of mismatched products
Automated visual inspection
For example, a future version could combine object detection, tracking, and rule-based analysis to generate an alert when an unexpected pill type, color, or visual condition is detected.
Benefits of the Approach
Combining YOLO11 with ByteTrack provides several practical advantages.
First, object detection and tracking are separated into two clear stages, making the system easier to understand and extend.
Second, tracking IDs allow the system to analyze the movement of individual pills rather than treating every video frame as an independent image.
Finally, adding color analysis provides another layer of information beyond simple object detection.
This combination can serve as a foundation for developing more advanced automated inspection systems.
Future Improvements
There are several possible directions for improving the system.
Future versions could include:
Pill counting and statistical reporting
Detection of broken or damaged pills
Detection of incorrect pill colors
Automatic alerts for mismatched products
Improved performance under different lighting conditions
Integration with industrial cameras and production-line systems
Deployment on edge devices
These improvements could turn the current computer vision prototype into a more complete automated inspection solution.
Conclusion
This project demonstrates how modern computer vision techniques can be combined to create a real-time pill monitoring system.
By using YOLO11 for object detection, ByteTrack for multi-object tracking, and color analysis for additional visual information, the system can detect and monitor pills in a video stream while maintaining the identity of individual objects.
The project also demonstrates how object detection can be combined with tracking and image-processing techniques to build practical computer vision solutions for industrial and pharmaceutical applications.
Frequently Asked Questions
1. What is YOLO11 used for in this project؟
YOLO11 is used to detect pills in each video frame.
2. Why is ByteTrack used؟
ByteTrack is used to track detected pills across consecutive frames and maintain their tracking IDs.
3. Can the system count pills؟
Yes. The tracking information can be used to implement automated pill counting.
4. Can the system detect pill colors؟
Yes. Color analysis can be applied to the detected pills and combined with their tracking information.
5. Can this project be used in pharmaceutical production؟
The approach can serve as a foundation for automated visual inspection and can be extended for pharmaceutical production environments.
Connect With Me
Interested in my AI and computer vision projects? You can explore more of my work and connect with me through the links below.
GitHub — Explore my source code and AI projects.
LinkedIn — Connect with me and follow my professional journey.
Kaggle — Explore my machine learning experiments and datasets..

Leave a Reply