You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
upgrade MLkit to work with other plugins such as OCR
i can also include the function im using to adjust the bounding box based on on the screen size the camera takes up. i use that function when using a header since the bounding box can get a little skewed.
ts file to adjust bounding box based on view and frame
adjustToView.ts
exporttypeDimensions={width: number;height: number};// matches return bounds from custom face detection moduleexporttypeRect={top: number;left: number;height: number;width: number;};/** * It takes a frame and a view, and returns an object with two functions: adjustPoint and adjustRect * @param {Dimensions} frame - Dimensions - the dimensions of the video frame * @param {Dimensions} view - Dimensions * @returns An object with two functions. * @resource https://github.com/bglgwyng/FrameProcessorExample/blob/e8e99d58c878d4dce9a8adf74a7447d253be93ab/adjustToView.ts#L21 */constadjustToView=(frame: Dimensions,view: Dimensions,landscape: boolean,verticalCropPadding: number,horizontalCropPadding: number,)=>{'worklet';const{width, height}=view;/* Calculating the aspect ratio of the view. */constaspectRatio=width/height;constframeWidth=frame.width;constframeHeight=frame.height;/* Setting the widthRatio, heightRatio, offsetX, and offsetY to 0. */letwidthRatio: number;letheightRatio: number;letoffsetX=0;letoffsetY=0;/* Calculating the ratio of the frame to the view. */constcroppedFrameWidth=aspectRatio*frameHeight;constcroppedFrameHeight=aspectRatio*frameWidth;if(!landscape){offsetX=(frameWidth-croppedFrameWidth)/2;}else{offsetY=(frameHeight-croppedFrameHeight)/2;}heightRatio=height/frameHeight;widthRatio=width/croppedFrameWidth;/* Returning an object with two functions. */return{adjustPoint: (point: {x: number;y: number})=>({x: (point.x-offsetX)*widthRatio,y: (point.y-offsetY)*heightRatio,}),adjustRect: (rect: Rect)=>({top: (rect.top-offsetY-verticalCropPadding)*heightRatio,left: (rect.left-offsetX-horizontalCropPadding)*widthRatio,height: (rect.height+verticalCropPadding)*heightRatio,width: (rect.width+horizontalCropPadding)*widthRatio,}),};};exportdefaultadjustToView;
The text was updated successfully, but these errors were encountered:
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
[email protected]
for the project I'm working on.fixes
i can also include the function im using to adjust the bounding box based on on the screen size the camera takes up. i use that function when using a header since the bounding box can get a little skewed.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
vision-camera-face-detector+0.1.8.patch
ts file to adjust bounding box based on view and frame
adjustToView.ts
The text was updated successfully, but these errors were encountered: