1.2.0 • Published 8 months ago

@jaak.ai/document-detector v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

document-detector Component

The DocumentDetectorComponent is a web component built using StencilJs designed to handle video and image inputs for face detection purposes. It can operate in either video camera or file upload mode, depending on configuration.

Installation

To install the package, use the following command:

npm i @jaak.ai/document-detector

Properties

PropertyTypeDescription
configConfigComponentConfiguration for the face detector component.
config.widthstringWidth of the video element. Default: '500px'.
config.heightstringHeight of the video element. Default: '400px'.
config.enableMicrophonebooleanIndicates whether the microphone should be enabled. Default: false.
config.modestringOperational mode, either 'video-camera' or 'upload-file'. Default: 'upload-file'.
config.placeholderstringPlaceholder text for file input.
config.buttonTextstringText displayed on the upload button.
config.documentAcceptstringSpecifies the types of files that can be uploaded.
config.descriptionstringDescription displayed near the file input.
config.sizenumberMaximum file size allowed in kilobytes. Default: 5000.
config.videoDurationnumberDuration for video recording in seconds. Default: 4.

Events

  • status: Fired when the component's status changes.
  • componentError: Fired when an error occurs in the component.
  • fileResult: Fired with the result of the file operation.

Methods

  • switchMode(newMode: 'video-camera' | 'upload-file'): Switches the operational mode of the component.
  • getMode(): Returns the current mode of the component.
  • recordVideo(): Starts recording video based on the config.videoDuration.
  • takeSnapshot(): Takes a snapshot using the video component.
  • getVideoElement(): Returns the video element if available.
  • getStream(): Returns the current video stream.

Usage Example

<document-detector
  config={{
    width: '640px',
    height: '480px',
    enableMicrophone: true,
    mode: 'video-camera',
    placeholder: 'Upload your document',
    buttonText: 'Upload',
    documentAccept: 'image/*',
    description: 'Please upload an image file.',
    size: 2048
  }}
  onStatus={(event) => handleStatusChange(event.detail)}
  onComponentError={(event) => handleComponentError(event.detail)}
  onFileResult={(event) => handleFileResult(event.detail)}
></document-detector>

Usage in JavaScript

You can import a small bootstrap script to lazy load the component.

<script type="module" src="https://unpkg.com/@jaak.ai/document-detector"></script>

<document-detector></document-detector>

<script>
  const fileUploader = document.querySelector('document-detector');
  fileUploader.config = {
    width: '640px',
    height: '480px',
    enableMicrophone: true,
    mode: 'video-camera',
    placeholder: 'Upload your document',
    buttonText: 'Upload',
    documentAccept: 'image/*',
    description: 'Please upload an image file.',
    size: 2048
  };
</script>

Usage in React

To use as part of a React component, you can import the component directly via:

import '@jaak.ai/document-detector';

function App() {
  return (
    <>
      <div>
        <document-detector
          config={{
            width: '640px',
            height: '480px',
            enableMicrophone: true,
            mode: 'video-camera',
            placeholder: 'Upload your document',
            buttonText: 'Upload',
            documentAccept: 'image/*',
            description: 'Please upload an image file.',
            size: 2048
          }}
        ></document-detector>
      </div>
    </>
  );
}

export default App;

Usage in Angular

In Angular you additionally have to configure CUSTOM_ELEMENTS_SCHEMA in the module

schemas: [CUSTOM_ELEMENTS_SCHEMA]

Import to main.ts file

import '@jaak.ai/document-detector';
  <document-detector
    [config]="{
      width: '640px',
      height: '480px',
      enableMicrophone: true,
      mode: 'video-camera',
      placeholder: 'Upload your document',
      buttonText: 'Upload',
      documentAccept: 'image/*',
      description: 'Please upload an image file.',
      size: 2048
    }"
  ></document-detector>

ConfigComponent Interface

Detailed interface for configuring the DocumentDetectorComponent:

PropertyTypeDescription
widthstringWidth of the video element. Default: '500px'.
heightstringHeight of the video element. Default: '400px'.
enableMicrophonebooleanIndicates whether the microphone should be enabled. Default: false.
modestringOperational mode, either 'video-camera' or 'upload-file'.
placeholderstringPlaceholder text for file input.
buttonTextstringText displayed on the upload button.
documentAcceptstringSpecifies the types of files that can be uploaded.
descriptionstringDescription displayed near the file input.
sizenumberMaximum file size allowed in kilobytes.
videoDurationnumberDuration for video recording in seconds.
cameraSourcestringSpecifies which camera to use for video capture when multiple sources are available, such as 'user' (front camera) or 'environment' (rear camera). This helps in selecting the appropriate camera based on the application's needs.
videoFormatstringDefines the preferred video resolution and frame rate format, such as '1920x1080@30' for 1080p video at 30 frames per second. This setting is used to configure the video output according to the capabilities of the media device and the requirements of the application.

FileResult Interface

Interface detailing the result of a file operation:

PropertyTypeDescription
base64stringBase64 encoded string of the file content.
typestringMIME type of the file (optional).
namestringOriginal name of the file (optional).
sizenumberSize of the file in bytes (optional).

StatusDocumentDetector Enum

This enum represents the various status states that the DocumentDetectorComponent can emit during its operation:

StatusDescription
NOT_LOADEDInitial state before any operations have started.
LOADINGThe component is currently loading necessary resources.
LOADEDAll resources are loaded, and the component is ready to be used.
RECORDINGThe component is currently recording video.
ERRORAn error has occurred in one of the processes.
UPLOADINGThe component is uploading a file.
RUNNINGThe component is actively processing.
SNAPSHOTTINGThe component is taking a snapshot.

Aditional Info

This package needs library dependencies, if is necessary you can install manually dependencies using this command:

npm install @jaak.ai/video-camera @jaak.ai/document-detector

This component is designed, developed and owned by JAAK and is their intellectual property. Visit more details in https://docs.jaak.ai

1.2.0

8 months ago

1.2.0-dev.1

8 months ago

1.1.5-dev.1

8 months ago

1.1.4-dev.2

8 months ago

1.1.5

8 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.3-dev.15

12 months ago

1.0.3-dev.14

12 months ago

1.0.3-dev.13

12 months ago

1.1.4

10 months ago

1.1.3

11 months ago

1.1.2

11 months ago

1.1.0-dev.2

11 months ago

1.1.0-dev.3

11 months ago

1.1.0-dev.1

12 months ago

1.1.0-dev.4

11 months ago

1.1.0-dev.5

11 months ago

1.0.3-dev.12

1 year ago

1.0.3-dev.11

1 year ago

1.0.3-dev.10

1 year ago

1.0.3-dev.5

1 year ago

1.0.3-dev.4

1 year ago

1.0.3-dev.3

1 year ago

1.0.3-dev.2

1 year ago

1.0.3-dev.9

1 year ago

1.0.3-dev.8

1 year ago

1.0.3-dev.7

1 year ago

1.0.3-dev.6

1 year ago

1.1.4-dev.1

10 months ago

1.0.3-dev.1

1 year ago

1.0.2-dev.2

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.2-dev.1

1 year ago

1.0.1-dev.2

1 year ago

1.0.1

1 year ago

1.0.0-dev.11

1 year ago

1.0.0-dev.10

1 year ago

1.0.1-dev.1

1 year ago

1.0.0-dev.9

1 year ago

1.0.0-dev.8

1 year ago

1.0.0-dev.7

1 year ago

1.0.0

1 year ago

1.0.0-dev.5

1 year ago

1.0.0-dev.6

1 year ago

1.0.0-dev.3

1 year ago

1.0.0-dev.4

1 year ago

0.0.1

1 year ago