One practical example is pill counting — an essential step in packaging and process control. With PEKAT VISION, this can now be done visually and automatically, offering a more accurate alternative to traditional methods like weighing.

From counting to defect detection — all in one setup.

The Challenges of Traditional Pill Counting

In pharmaceutical production, especially in packaging or batch verification, counting pills is critical. Traditionally, this is done by:

  • Weighing batches and dividing by the average pill weight
  • Using mechanical or optical counters that detect items as they pass

While effective in many cases, these methods have their drawbacks:

  • Pill weight can vary, due to differences in coating, shape, or moisture absorption
  • Broken pills or foreign objects can distort the total weight
  • Weighing assumes consistency — which may not hold true across a high-volume line
  • In smaller-scale production or pharmacies, manual or semi-automated methods can be slow and error-prone

This creates a need for a non-contact, accurate, and easily adjustable solution.

Pill Counting and Quality Check Using Deep Learning

Using the Detector module, PEKAT VISION can identify and count pills directly from camera images — whether in trays, blisters, or on conveyors. Combined with the Evaluation feature, it allows you to define pass/fail rules such as:

  • If exactly 65 pills are detected → OK
  • If fewer or more are detected → NG
With the Detector module, only trays containing exactly 65 pills are evaluated as OK. Two classes were defined for detection: Pill – Top View and Pill – Side View.

But beyond simple counting, PEKAT VISION can also verify quality in the same step.

The Detector is trained to recognize and count each pill. To further ensure quality, the Anomaly Detector can be added. Trained on images of trays filled only with intact, correct pills, it flags any visual deviation such as:

  • A broken or chipped pill
  • A different pill type
  • A foreign object or contaminant
Once trained, the Anomaly Detector flags any deviation, such as broken or chipped pills, different pill types, or foreign objects/contaminants.

This combination ensures that not only is the correct number of pills present, but they are also all valid and defect-free — all in a single inspection step.

Advantages Over Weighing-Based Methods

  • No dependency on average weight or tolerance calculations
  • Visual verification adds quality assurance to the count
  • Easily adaptable to different pill shapes, colors, or packaging formats
  • Can be integrated with existing inspection workflows using PEKAT VISION

Ideal for:

  • Pharmacies or small-batch manufacturing, where setup time and flexibility are key
  • QC verification before sealing or final packaging
  • Low-volume, high-mix production, where pill types and counts frequently change

Simple Setup of Deep Learning Modules

PEKAT VISION’s pill counting setup requires only a trained Detector module and a defined evaluation rule. Only a few images need to be annotated, and the evaluation criteria can be easily set in the graphical environment using simple ‘if’ logic. Once deployed, the system delivers real-time OK/NG output, with the added benefit of storing images, statistics, and detected object data for full traceability.

If you also want to perform quality checks in the same step, simply train the Anomaly Detector module on trays containing only correct pills. This may require more images — around fifty in our case — to capture variability in pill placement, but the setup remains almost as straightforward as training the Detector alone.

The advantage is that no annotation is needed: just train the Anomaly Detector on images of trays with the correct, intact pills, and the model is ready. One note from our test — the Feature Size setting may need adjustment to a smaller value (32 pixels in our case).

The Anomaly Detector module identifying the wrong type of pills on the tray. The Confusion Matrix on the right side showing 100% accuracy of the test model.

The final step is to configure the output method according to your system requirements (HTTP, TCP, Siemens PLC, etc.).

The Output feature allows triggering an action once an image is processed (OK or NG).

No mechanical counters, no calibrated scales, no manual checking — just smart vision powered by deep learning.


Other Pharmaceutical use cases

Discover how PEKAT VISION is used in other pharmaceutical inspection tasks, including liquid level checks, packaging and completeness inspection, and pill blister quality control.


Want to See PEKAT VISION in Action?

Contact us to learn more about how PEKAT VISION can help with counting or any other inspection tasks for that matter, start a free interactive online demo or download a 30-day trial version and try it yourself.

Get In Touch

Do you need more information? Let us know, we will answer any question you may have.
PEKAT VISION is now part of Datalogic Group