npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nuralogix.ai/tf-face-tracker-worker-ts

v1.0.2

Published

MediaPipe Tasks-vision Face Landmarker - Module Worker

Downloads

19

Readme

MediaPipe Tasks-vision Face Landmarker - Module worker

This packages uses @mediapipe/tasks-vision Face Landmarker inside a module web worker and maps Mediapipe facial landmarks to DeepAffex Facial Landmarks

How to use MediaPipe Tasks-vision Face Landmarker Worker via script tags in HTML page

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <!-- your meta tags -->
    </head>
    <body>
        <div id="tracker"></div>
        <script type="module">
            import { FaceTracker, enums, utils } from 'https://unpkg.com/@nuralogix.ai/tf-face-tracker-worker-ts';
            const { CameraController, AssetDownloader } = utils;
            const assetDownloader = AssetDownloader.init();

            const onBytesDownloaded = e => {
                const { bytes, url, done } = e.detail;
                console.log(bytes, 'bytes downloaded from', url, done);
            };

            const onDownloadedError = e => {
                const { error, url } = e.detail;
                console.log('Downloaded error', error, url);
            };
            assetDownloader.addEventListener('downloadedError', onDownloadedError);    
            assetDownloader.addEventListener('bytesDownloaded', onBytesDownloaded);

            // path to your assets
            const url = 'https://unpkg.com/@nuralogix.ai/tf-face-tracker-worker-ts/lib/taskVision/'
            const isSimdSupported = await assetDownloader.isSimdSupported();
            const wasmPath = `${url}wasm`;
            const modelPath = `${url}model/face_landmarker.task`;
            const wasmName = `vision_wasm${isSimdSupported ? '' : '_nosimd'}_internal`;

            const [wasmLoaderFile, wasmFile, modelFile] = await Promise.all([
                assetDownloader.fetchAsset(`${wasmPath}/${wasmName}_js.json`, true),
                assetDownloader.fetchAsset(`${wasmPath}/${wasmName}_wasm.json`, true),
                assetDownloader.fetchAsset(modelPath, false),
            ]);

            const camera = CameraController.init();
            const onSelectedDeviceChanged = (e) => {
                console.log(e.detail.deviceId);
            };
            const onCameraStatusChanged = (e) => {
                console.log(e.detail.isOpen);
            };
    
            camera.addEventListener('selectedDeviceChanged', onSelectedDeviceChanged);
            camera.addEventListener('cameraStatus', onCameraStatusChanged);
            await camera.list();
            const mediaElement = document.getElementById('tracker');
            const onMediaElementSizeChanged = e => {
                console.log('mediaElementSize Changed',e.detail);
            }
            mediaElement.addEventListener('mediaElementSizeChanged', onMediaElementSizeChanged);
            const broadcastChannelName = 'test';
            const broadcastChannel = new BroadcastChannel(broadcastChannelName);
            broadcastChannel.onmessage = e => {
                const { action, payload } = e.data;
                // console.log(payload);
            }

            const options = {
                faceTrackerType: enums.FaceTrackerType.MEDIAPIPE,
                broadcastChannelName,
                numOfWorkers: 2,
                mediapipe: {
                    wasmLoaderFile,
                    wasmFile,
                    modelFile,
                    delegate: 'CPU',
                },
                mediaElement,
                mirrorVideo: false,
                settings: {
                    displayMediaStream: true,
                    faceTrackerHeight: 360,
                    faceTrackerWidth: 640,
                    objectFit: enums.ObjectFitType.COVER,
                    isMaskVisible: true,
                },
            };        

            camera.start(1280, 720);
            const tracker = await FaceTracker.init(options);
            tracker.setMediaStream(camera.cameraStream);
        </script>
    </body>
</html>