@privateid/cryptonets-web-sdk
Advanced tools
Comparing version 4.0.4 to 4.0.5
@@ -75,1 +75,3 @@ import UAParser from 'ua-parser-js'; | ||
}; | ||
export declare function scaleImageData(imageData: any, scaleFactor: number): ImageData; | ||
export declare function zoomInCanvasImage(canvas: any, scaleFactor: number): ImageData; |
@@ -314,2 +314,58 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
export function scaleImageData(imageData, scaleFactor) { | ||
const { width, height, data } = imageData; | ||
// Create a new canvas and context for temporary scaling | ||
const tempCanvas = document.createElement('canvas'); | ||
const tempCtx = tempCanvas.getContext('2d'); | ||
// Set the dimensions of the temporary canvas | ||
tempCanvas.width = width * scaleFactor; | ||
tempCanvas.height = height * scaleFactor; | ||
// Draw the original image data onto the temporary canvas | ||
tempCtx.putImageData(imageData, 0, 0); | ||
// Get the scaled image data from the temporary canvas | ||
const scaledImageData = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height); | ||
return scaledImageData; | ||
} | ||
export function zoomInCanvasImage(canvas, scaleFactor) { | ||
// Get the current width and height of the canvas | ||
const originalWidth = canvas.width; | ||
const originalHeight = canvas.height; | ||
// Calculate the new dimensions after applying the scale factor | ||
const newWidth = Math.round(originalWidth / scaleFactor); | ||
const newHeight = Math.round(originalHeight / scaleFactor); | ||
// Calculate the amount of width and height to be cropped | ||
const cropWidth = originalWidth - newWidth; | ||
const cropHeight = originalHeight - newHeight; | ||
console.log({ | ||
originalWidth, | ||
originalHeight, | ||
newWidth, | ||
newHeight, | ||
cropWidth, | ||
cropHeight, | ||
}); | ||
// Create an offscreen canvas to hold the cropped image | ||
const offscreenCanvas = document.createElement('canvas'); | ||
const offscreenCtx = offscreenCanvas.getContext('2d'); | ||
// Set the dimensions for the offscreen canvas | ||
offscreenCanvas.width = originalWidth; | ||
offscreenCanvas.height = originalHeight; | ||
const centerX = originalWidth / 2; | ||
const centerY = originalHeight / 2; | ||
const sx = centerX - newWidth / (2 * scaleFactor); | ||
const sy = centerY - newHeight / (2 * scaleFactor); | ||
console.log({ centerX, centerY, sx, sy, sw: newWidth / scaleFactor, sh: newHeight / scaleFactor }); | ||
offscreenCtx.drawImage(canvas, sx, sy, newWidth / scaleFactor, newHeight / scaleFactor, | ||
// cropWidth / 2, | ||
// cropHeight / 2, // sourceX, sourceY | ||
// originalWidth - cropWidth, | ||
// originalHeight - cropHeight, // sourceWidth, sourceHeight | ||
0, 0, // destinationX, destinationY | ||
// changing this for testing | ||
newWidth, newHeight); | ||
// Get the image data from the offscreen canvas | ||
const imageData = offscreenCtx.getImageData(0, 0, newWidth, newHeight); | ||
// Return the image data | ||
return imageData; | ||
} | ||
//# sourceMappingURL=cameraUtils.js.map |
@@ -97,4 +97,5 @@ import { CameraFaceMode, FaceStatuses } from './types'; | ||
config?: any; | ||
zoomFactor?: number; | ||
} | ||
export declare const backScanDocument: ({ callback, image, config }: backScanInterface) => Promise<{ | ||
export declare const backScanDocument: ({ callback, image, config, zoomFactor }: backScanInterface) => Promise<{ | ||
result: number; | ||
@@ -101,0 +102,0 @@ croppedDocument: Uint8ClampedArray; |
/** | ||
* @module PrivID | ||
*/ | ||
interface apiUrlProps { | ||
collections: { | ||
default: { | ||
named_urls: { | ||
base_url: string; | ||
predict?: string; | ||
enroll?: string; | ||
validate_api_key?: string; | ||
}; | ||
}; | ||
collection1?: { | ||
named_urls?: { | ||
predict?: string; | ||
enroll?: string; | ||
validate_api_ket?: string; | ||
delete?: string; | ||
}; | ||
}; | ||
collection2?: { | ||
named_urls?: { | ||
predict?: string; | ||
enroll?: string; | ||
validate_api_ket?: string; | ||
delete?: string; | ||
}; | ||
}; | ||
}; | ||
} | ||
interface loadModulesProps { | ||
api_url: apiUrlProps; | ||
api_key?: string; | ||
api_orchestration_url?: string; | ||
cache_config?: boolean; | ||
timeout?: number; | ||
useCdn?: boolean; | ||
} | ||
/** | ||
@@ -8,3 +44,3 @@ * This function load the wasm module | ||
*/ | ||
export declare const loadPrivIdModule: (api_url?: string | null, api_key?: string | null, api_orchestration_url?: string | null, wasm_url?: string | null, cache_config?: boolean | null, timeout?: number | null, useCdn?: boolean | null, loadSimd?: boolean | null) => Promise<{ | ||
export declare const loadPrivIdModule: ({ api_url, api_key, api_orchestration_url, cache_config, timeout, useCdn, }: loadModulesProps) => Promise<{ | ||
support: boolean; | ||
@@ -11,0 +47,0 @@ message?: string; |
@@ -19,3 +19,3 @@ /* eslint-disable default-param-last */ | ||
import { clearDB } from './dbUtils'; | ||
import { apiKey, wasmUrl, setEnvVariables, cacheConfig } from './envUtils'; | ||
import { apiKey, cacheConfig } from './envUtils'; | ||
let isSimd = null; | ||
@@ -29,5 +29,4 @@ let moduleLoaded = false; | ||
*/ | ||
export const loadPrivIdModule = function (api_url = null, api_key = null, api_orchestration_url = null, wasm_url = null, cache_config = null, timeout = null, useCdn = null, loadSimd = null) { | ||
export const loadPrivIdModule = function ({ api_url, api_key, api_orchestration_url, cache_config, timeout, useCdn, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log('force- simd?', loadSimd); | ||
try { | ||
@@ -38,3 +37,2 @@ const supportResult = yield checkPackageSupport(); | ||
} | ||
setEnvVariables(api_key, api_url, api_orchestration_url, wasm_url, cache_config); | ||
const clearCacheParam = getUrlParameter('clear_cache', 'false'); | ||
@@ -64,6 +62,6 @@ const cacheAge = localStorage.getItem('cacheAge'); | ||
} | ||
const loadBuild = loadSimd !== null ? loadSimd : isSimd; | ||
const loadBuild = isSimd; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
const loaded = yield isLoad(loadBuild, wasmUrl, apiKey, debugType, cacheConfig, timeout, useCdn); | ||
const loaded = yield isLoad(loadBuild, api_url, apiKey, debugType, cacheConfig, timeout, useCdn); | ||
printLogs('------loaded------', loaded, debugType); | ||
@@ -70,0 +68,0 @@ moduleLoaded = loaded === 'Loaded'; |
@@ -79,3 +79,3 @@ export type Base64 = ArrayBuffer | string; | ||
export type WorkerFunctions = { | ||
isLoad: (simd: boolean, url: string, key: string, debug_type: string, cacheConfig: boolean) => Promise<string>; | ||
isLoad: (simd: boolean, url: string, key: string, debug_type: string, cacheConfig: boolean, timeout: number | null, useCdn: boolean) => Promise<string>; | ||
isValidInternal: (data: Uint8ClampedArray, width: number, height: number, simd: boolean, config: string, cb: any) => Promise<{ | ||
@@ -82,0 +82,0 @@ result: number; |
import { Base64, ImageType, LOGTYPE, ScreenOrientation } from './types'; | ||
export declare const isLoad: (simd: boolean, url: string, key: string, debug_type: string, cacheConfig: boolean) => Promise<string>, isValidInternal: (data: Uint8ClampedArray, width: number, height: number, simd: boolean, config: string, cb: any) => Promise<{ | ||
export declare const isLoad: (simd: boolean, url: string, key: string, debug_type: string, cacheConfig: boolean, timeout: number, useCdn: boolean) => Promise<string>, isValidInternal: (data: Uint8ClampedArray, width: number, height: number, simd: boolean, config: string, cb: any) => Promise<{ | ||
result: number; | ||
@@ -69,4 +69,4 @@ }>, prividAgePredict: (data: Uint8ClampedArray, width: number, height: number, simd: boolean, config: string, cb: any) => Promise<{ | ||
}>; | ||
export declare const getFrontDocumentStatusMessage: (result: number) => "" | "Please hold still" | "Success" | "Move Closer" | "Please show front of the ID" | "Please increase lighting" | "Move just a little closer" | "Too blurry, please hold still" | "SYSTEM ERROR. Please try again later." | "Please show ID at the center of the screen"; | ||
export declare const getFrontDocumentStatusMessage: (result: number) => "" | "Please hold still" | "Success" | "Move Closer" | "Please show front of the ID" | "Move just a little closer" | "Too blurry, please hold still" | "SYSTEM ERROR. Please try again later." | "Please show ID at the center of the screen"; | ||
export declare const getBackDocumentStatusMessage: (result: number) => "" | "Success" | "Move just a little closer" | "Too blurry, please hold still" | "SYSTEM ERROR. Please try again later." | "Please show ID at the center of the screen" | "Move closer to barcode" | "Please move closer to barcode" | "Please show barcode in the box"; | ||
export declare function getScreenOrientation(): ScreenOrientation; |
@@ -400,4 +400,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return 'Please show front of the ID'; | ||
case 2: | ||
return 'Please increase lighting'; | ||
case 3: | ||
@@ -416,3 +414,2 @@ return 'Please hold still'; | ||
return 'Please show ID at the center of the screen'; | ||
case 1: | ||
case -100: | ||
@@ -419,0 +416,0 @@ return 'Please show front of the ID'; |
@@ -5,3 +5,3 @@ { | ||
"description": "CryptoNets WebAssembly SDK", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "Face recognition", |
@@ -1170,2 +1170,2 @@ /* eslint-disable no-eval */ | ||
prividDocumentMugshotFaceCompare, | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
59983551
6547