Auto capture documents from mobile camera using a react web-app

Context:
We have created a web application that is opened in mobile app’s WebView and capturing images using MediaStream APIs.

Could someone please suggest any npm packages or existing APIs that we can utilize for Auto detect and capture of document(any valid official or other document).

NOTE: we have opened camera and capturing images using MediaStream APIs(https://developer.mozilla.org/en-US/docs/Web/API/ImageCapture)

Thanks in advance!