computer-vision-warehouse
Computer Vision for Warehouse Operations
You are an expert in applying computer vision to warehouse and supply chain operations. Your goal is to implement object detection, classification, tracking, and inspection systems using CNNs, YOLO, and other vision models.
Applications
- Package Detection & Tracking: YOLO, tracking algorithms
- Quality Inspection: CNN classification, defect detection
- Inventory Counting: Object counting, OCR
- Barcode/QR Reading: Traditional + ML methods
- Safety Monitoring: Person detection, PPE detection
YOLO for Package Detection
import cv2
from ultralytics import YOLO
class PackageDetector:
"""
Real-time package detection using YOLO
"""
def __init__(self, model_path='yolov8n.pt'):
self.model = YOLO(model_path)
def detect_packages(self, image_path):
"""Detect packages in warehouse image"""
results = self.model(image_path)
detections = []
for result in results:
boxes = result.boxes
for box in boxes:
x1, y1, x2, y2 = box.xyxy[0]
confidence = box.conf[0]
class_id = box.cls[0]
detections.append({
'bbox': (x1, y1, x2, y2),
'confidence': confidence,
'class': class_id
})
return detections
CNN for Quality Inspection
from tensorflow import keras
from tensorflow.keras import layers
class QualityInspector:
"""
CNN for defect detection
"""
def build_model(self, image_size=(224, 224), num_classes=2):
model = keras.Sequential([
layers.Conv2D(32, 3, activation='relu',
input_shape=(*image_size, 3)),
layers.MaxPooling2D(2),
layers.Conv2D(64, 3, activation='relu'),
layers.MaxPooling2D(2),
layers.Conv2D(128, 3, activation='relu'),
layers.MaxPooling2D(2),
layers.Flatten(),
layers.Dense(256, activation='relu'),
layers.Dropout(0.5),
layers.Dense(num_classes, activation='softmax')
])
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
return model
Object Tracking
from sort import Sort
class PackageTracker:
"""
Multi-object tracking for packages
"""
def __init__(self):
self.tracker = Sort()
self.package_trajectories = {}
def track(self, detections, frame_id):
"""
Track packages across frames
"""
# Convert detections to format for tracker
dets = np.array([[d['bbox'][0], d['bbox'][1],
d['bbox'][2], d['bbox'][3],
d['confidence']] for d in detections])
# Update tracker
tracked_objects = self.tracker.update(dets)
# Store trajectories
for obj in tracked_objects:
obj_id = int(obj[4])
bbox = obj[:4]
if obj_id not in self.package_trajectories:
self.package_trajectories[obj_id] = []
self.package_trajectories[obj_id].append({
'frame': frame_id,
'bbox': bbox
})
Tools & Libraries
OpenCV: image processingYOLOv8: object detectionTensorFlow/PyTorch: deep learningRoboflow: dataset managementDetectron2: Facebook detection
Related Skills
- ml-supply-chain: general ML
- warehouse-automation: automation systems
- quality-management: inspection processes
More from kishorkukreja/awesome-supply-chain
procurement-optimization
When the user wants to optimize procurement decisions, allocate orders across suppliers, or determine optimal order quantities. Also use when the user mentions "order allocation," "supplier portfolio optimization," "lot sizing," "order splitting," "purchase optimization," "EOQ," "sourcing optimization," or "multi-sourcing strategy." For supplier selection, see supplier-selection. For spend analysis, see spend-analysis.
77replenishment-strategy
When the user wants to design or optimize replenishment strategies, determine replenishment policies, or improve inventory flow between locations. Also use when the user mentions "inventory replenishment," "stock replenishment," "min-max inventory," "DRP," "auto-replenishment," "vendor-managed inventory," "forward pick replenishment," or "retail store replenishment." For safety stock calculations, see inventory-optimization. For multi-echelon networks, see multi-echelon-inventory.
37inventory-optimization
When the user wants to optimize inventory levels, calculate safety stock, determine reorder points, or minimize inventory costs. Also use when the user mentions "inventory management," "safety stock," "EOQ," "reorder point," "service level," "stockout prevention," "ABC analysis," "inventory turns," or "working capital reduction." For warehouse slotting, see warehouse-slotting-optimization. For multi-echelon systems, see multi-echelon-inventory.
34supplier-selection
When the user wants to evaluate suppliers, select vendors, or perform supplier scoring and qualification. Also use when the user mentions "vendor selection," "supplier evaluation," "RFP scoring," "supplier qualification," "vendor comparison," "make vs buy," "supplier scorecard," or "bid analysis." For ongoing supplier risk monitoring, see supplier-risk-management. For contract negotiation, see contract-management.
32pharmaceutical-supply-chain
When the user wants to optimize pharmaceutical supply chains, manage cold chain logistics, ensure regulatory compliance, or implement serialization. Also use when the user mentions "pharma supply chain," "GMP compliance," "cold chain," "drug serialization," "clinical trials logistics," "pharmaceutical distribution," "good distribution practices," "GDP," "drug safety," or "pharmaceutical quality." For general healthcare, see hospital-logistics. For clinical trials specifically, see clinical-trial-logistics.
30retail-replenishment
When the user wants to optimize retail store replenishment, calculate reorder points for stores, or manage continuous replenishment. Also use when the user mentions "store replenishment," "auto-replenishment," "min-max inventory," "store orders," "DC to store," "continuous replenishment," or "vendor-managed inventory (VMI)." For initial allocation, see retail-allocation. For DC operations, see warehouse-design.
29