diff --git a/app/javascript/packages/document-capture/components/acuant-capture.tsx b/app/javascript/packages/document-capture/components/acuant-capture.tsx index a26b4d6baea..8e61ba6e2b8 100644 --- a/app/javascript/packages/document-capture/components/acuant-capture.tsx +++ b/app/javascript/packages/document-capture/components/acuant-capture.tsx @@ -82,10 +82,10 @@ interface AcuantImageAnalyticsPayload extends ImageAnalyticsPayload { dpi: number; moire: number; glare: number; - glareScoreThreshold: number; + glareScoreThreshold: number | null; isAssessedAsGlare: boolean; sharpness: number; - sharpnessScoreThreshold: number; + sharpnessScoreThreshold: number | null; isAssessedAsBlurry: boolean; assessment: AcuantImageAssessment; isAssessedAsUnsupported: boolean; @@ -551,8 +551,8 @@ function AcuantCapture( const { image, dpi, moire, glare, sharpness } = nextCapture; const cardType = 'cardType' in nextCapture ? nextCapture.cardType : nextCapture.cardtype; - const isAssessedAsGlare = glare < glareThreshold; - const isAssessedAsBlurry = sharpness < sharpnessThreshold; + const isAssessedAsGlare = !!glareThreshold && glare < glareThreshold; + const isAssessedAsBlurry = !!sharpnessThreshold && sharpness < sharpnessThreshold; const isAssessedAsUnsupported = cardType !== AcuantDocumentType.ID; const { width, height, data } = image; diff --git a/app/javascript/packages/document-capture/context/acuant.tsx b/app/javascript/packages/document-capture/context/acuant.tsx index 7f31fb5500a..98be69c8c04 100644 --- a/app/javascript/packages/document-capture/context/acuant.tsx +++ b/app/javascript/packages/document-capture/context/acuant.tsx @@ -109,11 +109,11 @@ interface AcuantContextProviderProps { /** * Minimum acceptable glare score for images. */ - glareThreshold: number; + glareThreshold: number | null; /** * Minimum acceptable sharpness score for images. */ - sharpnessThreshold: number; + sharpnessThreshold: number | null; /** * Child element */ @@ -122,16 +122,6 @@ interface AcuantContextProviderProps { export type AcuantCaptureMode = 'AUTO' | 'TAP'; -/** - * The minimum glare score value to be considered acceptable. - */ -export const DEFAULT_ACCEPTABLE_GLARE_SCORE = 30; - -/** - * The minimum sharpness score value to be considered acceptable. - */ -export const DEFAULT_ACCEPTABLE_SHARPNESS_SCORE = 30; - /** * Returns the containing directory of the given file, including a trailing slash. */ @@ -147,8 +137,8 @@ interface AcuantContextInterface { acuantCaptureMode: AcuantCaptureMode; setAcuantCaptureMode: (type: AcuantCaptureMode) => void; credentials: string | null; - glareThreshold: number; - sharpnessThreshold: number; + glareThreshold: number | null; + sharpnessThreshold: number | null; endpoint: string | null; } @@ -162,8 +152,8 @@ const AcuantContext = createContext({ acuantCaptureMode: 'AUTO', setAcuantCaptureMode: () => {}, credentials: null, - glareThreshold: DEFAULT_ACCEPTABLE_GLARE_SCORE, - sharpnessThreshold: DEFAULT_ACCEPTABLE_SHARPNESS_SCORE, + glareThreshold: null, + sharpnessThreshold: null, endpoint: null as string | null, }); @@ -225,8 +215,8 @@ function AcuantContextProvider({ passiveLivenessSrc, credentials = null, endpoint = null, - glareThreshold = DEFAULT_ACCEPTABLE_GLARE_SCORE, - sharpnessThreshold = DEFAULT_ACCEPTABLE_SHARPNESS_SCORE, + glareThreshold, + sharpnessThreshold, children, }: AcuantContextProviderProps) { const { isMobile } = useContext(DeviceContext); diff --git a/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx b/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx index a9b18500dae..35543c8fa85 100644 --- a/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx +++ b/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx @@ -596,7 +596,12 @@ describe('document-capture/components/acuant-capture', () => { const onChange = sinon.mock(); const { getByText } = render( - + , @@ -756,7 +761,12 @@ describe('document-capture/components/acuant-capture', () => { const { getByText, findByText } = render( - + @@ -814,6 +824,7 @@ describe('document-capture/components/acuant-capture', () => { sdkSrc="about:blank" cameraSrc="about:blank" sharpnessThreshold={50} + glareThreshold={50} > @@ -912,6 +923,7 @@ describe('document-capture/components/acuant-capture', () => { sdkSrc="about:blank" cameraSrc="about:blank" sharpnessThreshold={50} + glareThreshold={50} > diff --git a/spec/javascript/packages/document-capture/context/acuant-spec.jsx b/spec/javascript/packages/document-capture/context/acuant-spec.jsx index 3e0e9165e55..7cbe9af7e08 100644 --- a/spec/javascript/packages/document-capture/context/acuant-spec.jsx +++ b/spec/javascript/packages/document-capture/context/acuant-spec.jsx @@ -1,7 +1,5 @@ import AcuantContext, { Provider as AcuantContextProvider, - DEFAULT_ACCEPTABLE_GLARE_SCORE, - DEFAULT_ACCEPTABLE_SHARPNESS_SCORE, dirname, } from '@18f/identity-document-capture/context/acuant'; import { AnalyticsContext, DeviceContext } from '@18f/identity-document-capture'; @@ -47,8 +45,6 @@ describe('document-capture/context/acuant', () => { expect(result.current.setIsActive).to.be.a('function'); expect(result.current.credentials).to.be.null(); expect(result.current.endpoint).to.be.null(); - expect(result.current.glareThreshold).to.equal(DEFAULT_ACCEPTABLE_GLARE_SCORE); - expect(result.current.sharpnessThreshold).to.equal(DEFAULT_ACCEPTABLE_SHARPNESS_SCORE); }); it('allows configurable acceptable scores', () => {