### Install and Run Development Server Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/reactThreeFiberDemo/README.md Installs dependencies and starts the development server with host access. Ensure Node.js version 22 or higher is used if specified. ```bash # facultative: use Node >= 22: nvm use 22 # pm install pm run dev -- --host ``` -------------------------------- ### Start Development Server with Node.js Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/README.md Installs dependencies and starts the development server using Node.js. Access the application via the provided URL. ```bash npm install npm run dev ``` -------------------------------- ### Start Development Server with Python 2 Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/README.md Launches the development HTTPS server using Python 2. Ensure Python 2.X is installed. ```bash python2 httpsServer.py ``` -------------------------------- ### User Interaction Prompt Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/demos/canvas2D/multipleTrackers/index.html Provides a simple text prompt for the user to click or touch to start the video feed. ```html Click or Touch to start the video! ``` -------------------------------- ### GIF Image Structure Example Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/libs/gify/README.md This JSON object represents the structure of a GIF file, including global settings, animation properties, and individual image frames. It is useful for understanding how GIF data is parsed and represented programmatically. ```json { "valid": true, "globalPalette": true, "globalPaletteSize": 256, "globalPaletteColorsRGB": [ { "r": 50, "g": 82, "b": 120 }, { "r": 89, "g": 105, "b": 119 }, { "r": 4, "g": 33, "b": 71 } ], "loopCount": 0, "height": 1610, "width": 899, "animated": true, "images": [ { "identifier": "0", "localPalette": false, "localPaletteSize": 0, "interlace": false, "comments": [], "text": "", "left": 0, "top": 0, "width": 1610, "height": 899, "delay": 350, "disposal": 0 }, { "identifier": "1", "localPalette": true, "localPaletteSize": 256, "interlace": false, "comments": [], "text": "", "left": 0, "top": 0, "width": 1610, "height": 899, "delay": 350, "disposal": 0 }, { "identifier": "2", "localPalette": true, "localPaletteSize": 256, "interlace": false, "comments": [], "text": "", "left": 0, "top": 0, "width": 1610, "height": 899, "delay": 350, "disposal": 0 }, { "identifier": "3", "localPalette": true, "localPaletteSize": 256, "interlace": false, "comments": [], "text": "", "left": 0, "top": 0, "width": 1610, "height": 899, "delay": 350, "disposal": 0 } ], "isBrowserDuration": false, "duration": 2800, "durationIE": 2800, "durationSafari": 2800, "durationFirefox": 2800, "durationChrome": 2800, "durationOpera": 2800 } ``` -------------------------------- ### Example Detected States Object Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/demos/faceReplacement/gif/README.md This object represents the face detection state for each frame of a GIF. Each element corresponds to a frame, indicating the face's position (x, y), scale (s), and rotation (ry, rz) if detected, or 'false' if not detected. This can be pre-computed and provided to avoid lengthy detection processes. ```javascript detectStates = [{x:-0.475,y:-0.152,s:0.278,ry:0.225,rz:0},{x:-0.457,y:-0.17,s:0.287,ry:0.206,rz:-0.011},false] ``` -------------------------------- ### Build for Production Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/reactThreeFiberDemo/README.md Generates a production-ready build of the application. ```bash npm run build ``` -------------------------------- ### Initialize JeelizFaceFilter with Resizer Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/README.md Use the JeelizResizer helper to size the canvas and determine the best video settings before initializing Jeeliz FaceFilter. The callback function receives error status and optimal video settings, which are then passed to JEELIZFACEFILTER.init. ```javascript JeelizResizer.sizeCanvas({ canvasId: 'jeeFaceFilterCanvas', callback: function(isError, bestVideoSettings){ JEELIZFACEFILTER.init({ videoSettings: bestVideoSettings, // ... // ... }); } }); ``` -------------------------------- ### Initialize Cesium and Head Controls Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/demos/cesium/headControls/simplified.html Initializes the Cesium viewer and sets up the HeadControls library with a callback for camera movement. Ensure the 'headControlsCanvas' element exists and the neural network models are accessible at 'NNCPath'. ```javascript // initialize Cesium: const CESIUMVIEWER = new Cesium.Viewer('cesiumContainer'); const SETTINGS = { zoomSensibility: 5.5, panSensibility: 0.00000015 }; function callbackMove(mv) { const cameraHeight = CESIUMVIEWER.scene.globe.ellipsoid.cartesianToCartographic(CESIUMVIEWER.camera.position).height / 1000.0 || Number.MAX_VALUE; if (mv.dZ !== 0) { // move head forward/backward const zoomAmount = mv.dZ * SETTINGS.zoomSensibility * cameraHeight; CESIUMVIEWER.camera.moveForward(zoomAmount); } if (mv.dRx !== 0) { // turn head up-down const panAmountX = SETTINGS.panSensibility * mv.dRx * cameraHeight; CESIUMVIEWER.scene.camera.rotateUp(panAmountX); } if (mv.dRy !== 0) { // turn head left-right const panAmountY = SETTINGS.panSensibility * mv.dRy * cameraHeight; CESIUMVIEWER.scene.camera.rotate(Cesium.Cartesian3.UNIT_Z, panAmountY); } } const DOMbutton = document.getElementById('startHeadControlsButton'); DOMbutton.onclick = function() { HeadControls.init({ canvasId: 'headControlsCanvas', callbackMove: callbackMove, callbackReady: function(errCode) { if (errCode) { console.log('ERROR: HEAD CONTROLS NOT READY. errCode =', errCode); } else { console.log('INFO: HEAD CONTROLS ARE READY :) '); HeadControls.toggle(true); } }, NNCPath: './neuralNets/' // where to find NN_DEFAULT.json from the current path }); //end HeadControls.init params }; //end DOMbutton.onclick ``` -------------------------------- ### Initialize FaceFilter with Bundler Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/README.md Use this snippet when integrating with a bundler like Webpack or Parcel. It demonstrates loading the module and the neural network model directly. ```javascript const faceFilter = require('./lib/jeelizFaceFilter.module.js').JEELIZFACEFILTER const neuralNetworkModel = require('./neuralNets/NN_DEFAULT.json') faceFilter.init({ NNC: neuralNetworkModel, // instead of NNCPath // ... other init parameters }); ``` -------------------------------- ### Initialize JeelizFaceFilter with Module and Options Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/README.md Initialize JeelizFaceFilter using require and configure it with various options including canvas ID, neural network path, and callbacks for readiness and tracking. ```javascript const faceFilter = require('./lib/jeelizFaceFilter.module.js').JEELIZFACEFILTER; faceFilter.init({ // you can also provide the canvas directly // using the canvas property instead of canvasId: canvasId: 'jeeFaceFilterCanvas', NNCPath: '../../../neuralNets/', // path to JSON neural network model (NN_DEFAULT.json by default) callbackReady: function(errCode, spec){ if (errCode){ console.log('AN ERROR HAPPENS. ERROR CODE =', errCode); return; } // [init scene with spec...] console.log('INFO: JEELIZFACEFILTER IS READY'); }, //end callbackReady() // called at each render iteration (drawing loop) callbackTrack: function(detectState){ // Render your scene here // [... do something with detectState] } //end callbackTrack() }); ``` -------------------------------- ### JEELIZFACEFILTER.get_videoDevices Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/README.md Retrieves available video devices before initialization. ```APIDOC ## JEELIZFACEFILTER.get_videoDevices ### Description Should be called before the `init` method. This method retrieves available video devices and provides them to a callback function. ### Method GET ### Endpoint /JEELIZFACEFILTER/get_videoDevices ### Parameters #### Query Parameters - **callback** (function) - Required - The callback function to receive the video devices and error information. - **mediaDevices** (array) - An array of device objects, each with a `deviceId` string attribute, or `false` if an error occurs. - **errorLabel** (string) - The label of the error if an error occurs (`NOTSUPPORTED`, `NODEVICESFOUND`, or `PROMISEREJECTED`). ``` -------------------------------- ### Optional Video Settings for JeelizFaceFilter Source: https://github.com/jeeliz/jeelizfacefilter/blob/master/README.md Configuration dictionary for overriding default WebRTC video settings. Ensure initialization is synchronized with video element events if using a webcam. ```javascript { 'videoElement' // not set by default.