.. index:: 
  !Document detection

.. _document_detection:

==================
Document detection
==================

The :ref:`DocumentDetector<id3_document_document_detector_class>` class detects documents in images.

.. important:: 
  The document detector requires the relevant AI models to run (see :ref:`ai_models` for details).
  It also requires the document templates to be loaded (see :ref:`document_templates` for details).

Automatic document identification
=================================
The document type can be determined automatically by analysing the document image on the basis of pre-loaded document templates.



Example
=======

The example below demonstrates how to detect a document from an image.

.. tab-set::

    .. tab-item:: Python
      :sync: Python

      .. literalinclude:: /../samples/sample.py
        :language: python
        :start-after: [document_detection]
        :end-before: [document_detection]
        :dedent: 4

See also
========

- :ref:`ai_models`
- :ref:`document_templates`
- :ref:`id3_document_document_detector_class`
- :ref:`id3_document_detected_document_class`
