TEGUARCOMPUTERS
Request a Quote

Blog

How to Build: Machine Vision for Automated Surgical Instrument Counting in ORs using TM-7240-22 Medical Grade AIO PC

Teguar Engineering Team · December 2, 2025

An engineering guide showing how to implement machine vision for automated surgical instrument counting in ors on Teguar's purpose-built TM-7240-22 Medical Grade AIO PC with computer vision & model training.

TM-7240-22 Medical Grade AIO PC running Computer Vision & Model Training in a clinical environment

Retained foreign objects (RFOs) are critical safety issues during surgical procedures. Traditional manual counts of scalpels, clamps, and forceps can lead to errors under fatigue. Utilizing machine vision at the surgical cart to auto-verify instrument counts during pre-op and post-op stages helps prevent errors and streamline operations.

This guide details how to implement a localized Surgical Instrument Counting System using custom YOLO object detection on Teguar's TM-7240-22 Medical Grade AIO PC.

Choosing the Hardware: Teguar TM-7240-22 Medical Grade AIO PC

Operating rooms require medical computers that are electrically safe, hygienic, and powerful enough to run high-speed video inference.

  • Medical Safety Certified: Full UL/EN 60601-1 certification ensures safe operation near patient beds and sensitive medical equipment.
  • Antibacterial Sealed Front: The IP65-rated front screen can be sanitized with hospital disinfectants.
  • Processor Power: Handles real-time video streaming and high-resolution object detection model execution.

Machine Vision Architecture

+---------------------------------------------------------------------------------+
|                       TM-7240-22 Medical Grade AIO PC                           |
|                                                                                 |
|  +--------------------+      +--------------------+     +--------------------+  |
|  | Overhead OR Camera | ---> | Frame Capture      | --> | Custom YOLOv8      |  |
|  | (1080p USB/GigE)   |      | (OpenCV Pipeline)  |     | (Fine-tuned model) |  |
|  +--------------------+      +--------------------+     +---------+----------+  |
|                                                                   |             |
|                                                                   v             |
|                                                         +---------+----------+  |
|                                                         | Count Discrepancy  |  |
|                                                         | Logic (Pre vs Post)|  |
|                                                         +---------+----------+  |
|                                                                   |             |
|                                                                   v             |
|                                                         +---------+----------+  |
|                                                         | Audit Interface    |  |
|                                                         | (Visual Checklist) |  |
|                                                         +--------------------+  |
+---------------------------------------------------------------------------------+

Step-by-Step System Implementation

Step 1: Install Python Libraries

We need OpenCV for image capture and the Ultralytics SDK for model execution.

pip install opencv-python-headless ultralytics pillow

Step 2: Local YOLO Inference and Counting

We run inference on the sterilizing tray area using a custom YOLOv8 model trained to detect specific metallic instruments (e.g., hemostats, retractor blades, forceps).

import cv2
from ultralytics import YOLO

# Load custom YOLO model fine-tuned for OR instruments
model = YOLO("models/surgical_instruments_yolov8.pt")

def count_instruments_on_tray(frame):
    # Perform inference
    results = model(frame, conf=0.6, verbose=False)[0]
    
    # Class dictionary mapping class ID to instrument name
    class_names = model.names
    
    instrument_counts = {}
    
    # Process detections
    for box in results.boxes:
        cls_id = int(box.cls[0])
        cls_name = class_names[cls_id]
        
        # Accumulate counts
        instrument_counts[cls_name] = instrument_counts.get(cls_name, 0) + 1
        
        # Draw bounding boxes
        xyxy = box.xyxy[0].cpu().numpy().astype(int)
        cv2.rectangle(frame, (xyxy[0], xyxy[1]), (xyxy[2], xyxy[3]), (0, 255, 0), 2)
        cv2.putText(frame, cls_name, (xyxy[0], xyxy[1] - 5),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
                    
    return instrument_counts, frame

Step 3: Count Reconciliation Dashboard

Compare pre-op counts against current counts on the TM-7240-22 display.

def reconcile_counts(expected_counts, current_counts):
    discrepancies = {}
    all_keys = set(expected_counts.keys()).union(set(current_counts.keys()))
    
    for key in all_keys:
        expected = expected_counts.get(key, 0)
        current = current_counts.get(key, 0)
        if expected != current:
            discrepancies[key] = {"expected": expected, "actual": current}
            
    return discrepancies

Calibration and Lighting Tips

  • Anti-Glare Filters: OR lighting can create harsh reflections on metal instruments. Position polarized filters on camera lenses and adjust the AIO PC's screen brightness to minimize glare during reviews.
  • Confidence Tuning: Keep detection thresholds above 0.6 to minimize false positives from overlapping surgical sponges.

Conclusion

Running custom model inference on Teguar's TM-7240-22 PC provides operating room teams with an automated check-in and check-out tool for surgical tools, enhancing patient safety during complex procedures.