Skip to content

Camera Helper

farimarwat edited this page Sep 9, 2023 · 7 revisions

CameraHelper by Document Scanner provides functionality of taking pictures either full or any card size. It shows a rectangle on previewview in case of ID Card capture. Below are the full documentation of CameraHelper by Document Scanner.

Implementation

implementation 'io.github.farimarwat.camerahelper:1.0'

Usage:

 val intent = Intent(mContext,CameraActivity::class.java)
 startActivity(intent)

Getting Result:

Set a Camera listener and get resulted bitmaps

CameraActivity.setCameraListener(object :CameraListener{
    override fun onCaptured(image: Bitmap?) {
		//This method is called on each capture.
		//Any one can also play a sound e.g. camera sound here
    }

    override fun onCaptureCompleted(list: List<Bitmap>) {
        // This method is called after successfully capture completed.
		//For example, it is called after taking both sides of ID Card, 
		//in case of taking both sides (front, back)
    }

    override fun onError(error: String) {
        Timber.e("Error: ${error}")
    } })

Setting Properties:

  1. This method is used to set Card size. There are three different sizes already available but any one can pass a custom size e.g., ("1:1") Default Sizes:
CameraActivity.ID_CARD_SQUARE
CameraActivity.ID_CARD_DEFAULT
CameraActivity.ID_CARD_LARGE`

Example:

CameraActivity.setCardSize(CameraActivity.ID_CARD_DEFAULT)

Custom Example:

CameraActivity.setCardSize("9:16")
  1. This method is used to determine if task is to take front and backside or single side.
CameraActivity.setIsDoubleSide(true) //Default is  true
  1. To determine if task is to take cropped picture and show frame or not.
CameraActivity.setIsCropped(false) // Default is true
  1. To set Frame borders.
CameraActivity.setRectBorder(drawable)
  1. To change camera capture icon.
CameraActivity.setCaptureIcon(drawable)
  1. To set camera switch icon.
CameraActivity.setSwitchIcon(drawable)
Clone this wiki locally