Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Measuring 478 face landmarks locally with WASM and roll correction

A face overlay can look perfectly attached to a photo and still give the wrong eye angle. Draw a line through the corners of one eye, rotate the same image by ten degrees, and the line rotates with it. If a report changes simply because someone held the phone at an angle, the reported number belongs to the camera frame. The geometry needs its own reference frame. A browser implementation has two…

Measuring facial landmarks accurately requires a reference frame separate from the camera's perspective. When an image is rotated or resized, the detected face landmarks must be converted into measurements that remain consistent. The MediaPipe Face Landmarker web API can be used to run inference on a user's device, keeping the photo out of the request. The detector's output should be converted into predictable measurements that behave correctly when the image is rotated or resized.

To test the conversion, the detector can be left off and the crop and its dimensions kept together for a single still image. One face's landmark array should be read using image mode. The detector should be set to flag group photos by default, expecting at least two faces.

The landmark array contains 478 estimated points per face, including iris points. The indices should be kept and treated as a normal outcome for zero faces. When expecting one portrait, the detector limit should be set to at least two. The original orientation should be decoded once, and if the long edge is capped at 1,024 pixels, the resized bitmap should be sent along with its width and height.

The inference bitmap remains 768 by 1,024 even when drawn at a different size by CSS. Letterboxing offset and preview reflection should be applied in the renderer only when drawing the overlay. Any blocking call should be moved off the main thread. The image-mode detection call is synchronous, but wrapping it in an async function still keeps the call on the invoking thread. The vision task should be initialized in a dedicated worker, reused across scans, and transfer an ImageBitmap when supported.

The landmark array and dimensions can be returned through a message, allowing the main thread to keep a progress indicator alive during the expensive part. The runtime and model should be loaded on demand, with the CPU path tested using the same fixture and image as the GPU path. If two requests overlap, use a request ID and drop results from earlier selections. Each bitmap should be closed when its owner has finished with it.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

How to export any brand's Google ads to a spreadsheet

If you want to know what ads a competitor is running on Google, the answer is public. Since 2023 Google has published every advertiser's ads in the Ads Transparency Center at…

  • Ads Transparency Center on Google makes advertisers' ads publicly available since 2023.
  • Manual review impractical for brands with thousands of ads.
  • Google Ads Transparency Center Scraper tool automates data export to CSV, Excel, or JSON.

Elastomer vs. Spring Probe (Pogo Pin) IC Test Sockets

Quick Decision Summary (When to Use Each Contact Technology) When selecting a semiconductor test socket , contact choice turns on vertical compliance versus electrical path length: Choose a Spring…

  • Spring Probe sockets suited for high pin count, warpage, BGA, or thermal cycling needs
  • Conductive Elastomer Sockets optimal for flat packages, room/moderate temps, short electrical path
  • Choice depends on device/PCB specific requirements and testing conditions

More from Sunday, 29 November 2026 →