How to use eyes method in pact-foundation-pact

Best JavaScript code snippet using pact-foundation-pact

trackingjsGaze.js

Source:trackingjsGaze.js Github

copy

Full Screen

1(function(window) {2 'use strict';3 window.webgazer = window.webgazer || {};4 webgazer.tracker = webgazer.tracker || {};5 /**6 * Constructor of TrackingjsGaze object7 * @constructor8 */9 var TrackingjsGaze = function() {};10 webgazer.tracker.TrackingjsGaze = TrackingjsGaze;11 /**12 * Isolates the two patches that correspond to the user's eyes13 * @param {Canvas} imageCanvas - canvas corresponding to the webcam stream14 * @param {Number} width - of imageCanvas15 * @param {Number} height - of imageCanvas16 * @return {Object} the two eye-patches, first left, then right eye17 */18 TrackingjsGaze.prototype.getEyePatches = function(imageCanvas, width, height) {19 if (imageCanvas.width === 0) {20 return null;21 }22 //current ImageData that correspond to the working image. 23 //It can be the whole canvas if the face detection failed or only the upper half of the face to avoid unnecessary computations24 var workingImage = imageCanvas.getContext('2d').getImageData(0,0,width,height);25 var face = this.detectFace(workingImage, width, height);26 //offsets of the working image from the top left corner of the video canvas27 var offsetX = 0;28 var offsetY = 0;29 //if face has been detected30 if (face.length > 0 && !isNaN(face[0]) && !isNaN(face[1]) && !isNaN(face[2]) && !isNaN(face[3])){31 //working image is restricted on upper half of detected face32 workingImage = imageCanvas.getContext('2d').getImageData(Math.floor(face[0]), Math.floor(face[1]), Math.floor(face[2]), Math.floor(face[3]/2));33 width = Math.floor(face[2]);34 height = Math.floor(face[3] / 2);35 //offset from detected face36 offsetX = Math.floor(face[0]);37 offsetY = Math.floor(face[1]); 38 }39 var eyes = this.detectEyes(workingImage, width, height);40 console.log(eyes);41 if (eyes === null){42 return null;43 }44 var eyeObjs = {};45 var leftImageData = imageCanvas.getContext('2d').getImageData(Math.floor(eyes[0][0])+offsetX, Math.floor(eyes[0][1])+offsetY, Math.floor(eyes[0][2]), Math.floor(eyes[0][3]));46 eyeObjs.left = {47 patch: leftImageData,48 imagex: eyes[0][0] + offsetX,49 imagey: eyes[0][1] + offsetY,50 width: eyes[0][2],51 height: eyes[0][3]52 };53 54 var rightImageData = imageCanvas.getContext('2d').getImageData(Math.floor(eyes[1][0])+offsetX, Math.floor(eyes[1][1])+offsetY, Math.floor(eyes[1][2]), Math.floor(eyes[1][3]));55 eyeObjs.right = {56 patch: rightImageData,57 imagex: eyes[1][0]+offsetX,58 imagey: eyes[1][1]+offsetY,59 width: eyes[1][2],60 height: eyes[1][3] 61 };62 63 if (leftImageData.width === 0 || rightImageData.width === 0) {64 console.log('an eye patch had zero width');65 return null;66 }67 return eyeObjs;68 };69 /**70 * Performs eye detection on the passed working image71 * @param {ImageData} workingImage - either the whole canvas or the upper half of the head72 * @param {Number} width - width of working image73 * @param {Number} height - height of working image74 * @return {Array} eyes - array of rectangle information. 75 */76 TrackingjsGaze.prototype.detectEyes = function(workingImage, width, height){ 77 var eyes = [];78 var intermediateEyes = [];79 var pixels = workingImage.data;80 tracking.ViolaJones.detect(pixels, width, height, 0.5, 2, 1.7, 0.1, tracking.ViolaJones.classifiers['eye']).forEach(function(rect){81 var intermediateEye = [rect.x, rect.y, rect.width, rect.height];82 intermediateEyes.push(intermediateEye);83 });84 if (intermediateEyes.length>1){85 //find the two eyes with the shortest y distance86 var minimumYDistance = 1000;87 var eyes = [];88 for(var i=0; i < intermediateEyes.length; i++){89 for(var j = i+1; j < intermediateEyes.length; j++){90 var YDistance = Math.abs(Math.floor(intermediateEyes[i][1]) - Math.floor(intermediateEyes[j][1]));91 if(YDistance <= minimumYDistance){92 minimumYDistance = YDistance;93 eyes[0] = intermediateEyes[i];94 eyes[1] = intermediateEyes[j];95 } 96 }97 }98 eyes.sort(function(a,b) {99 return a[0]-b[0]100 });101 return eyes;102 }103 else{104 console.log('tracking.js could not detect two eyes in the video');105 return null;106 }107 };108 /**109 * Performs face detection on the passed canvas110 * @param {ImageData} workingImage - whole video canvas111 * @param {Number} width - width of imageCanvas112 * @param {Number} height - height of imageCanvas113 * @return {Array} face - array of rectangle information114 */115 TrackingjsGaze.prototype.detectFace = function(workingImage, width, height){116 var intermediateFaces = [];117 var face = [];118 // Detect faces in the image119 var pixels = workingImage.data;120 tracking.ViolaJones.detect(pixels, width, height, 2, 1.25, 2, 0.1, tracking.ViolaJones.classifiers['face']).forEach(function(rect){121 var intermediateFace = [rect.x, rect.y, rect.width, rect.height];122 intermediateFaces.push(intermediateFace);123 });124 face = this.findLargestRectangle(intermediateFaces);125 return face;126 };127 /**128 * Goes through an array of rectangles and returns the one with the largest area129 * @param {Array.<Array.<Number>>} rectangles - array of arrays of format [xCoordinate, yCoordinate, width, height]130 * @return {Array} largestRectangle = [xCoordinate, yCoordinate, width, height]131 */132 TrackingjsGaze.prototype.findLargestRectangle = function(rectangles){133 var largestArea = 0;134 var area = 0;135 var largestRectangle = [];136 for (var i = 0; i < rectangles.length; ++i){137 area = rectangles[i][2] * rectangles[i][3];138 if (area > largestArea){139 largestArea = area;140 largestRectangle = rectangles[i];141 }142 }143 return largestRectangle;144 };145 /**146 * Reset the tracker to default values147 */148 TrackingjsGaze.prototype.reset = function(){149 console.log( "Unimplemented; Tracking.js has no obvious reset function" );150 }151 /**152 * The TrackingjsGaze object name153 * @type {string}154 */155 TrackingjsGaze.prototype.name = 'trackingjs';156 ...

Full Screen

Full Screen

eyes.js

Source:eyes.js Github

copy

Full Screen

1export const eyes = {2 black_eyes: {3 rarity: 269,4 label: "Black Eyes",5 src: "/assets/builder/traits/pupils/black_eyes.png",6 },7 blood_crimson_eyes: {8 rarity: 151,9 label: "Blood Crimson Eyes",10 src: "/assets/builder/traits/pupils/blood_crimson_eyes.png",11 },12 celestial_eyes: {13 rarity: 59,14 label: "Celestial Eyes",15 src: "/assets/builder/traits/pupils/celestial_eyes.png",16 },17 chakra_eyes: {18 rarity: 55,19 label: "Chakra Eyes",20 src: "/assets/builder/traits/pupils/chakra_eyes.png",21 },22 clover_eyes: {23 rarity: 216,24 label: "clover Eyes",25 src: "/assets/builder/traits/pupils/clover_eyes.png",26 },27 copy_eyes: {28 rarity: 180,29 label: "copy Eyes",30 src: "/assets/builder/traits/pupils/copy_eyes.png",31 },32 copycat_eyes: {33 rarity: 172,34 label: "copycat Eyes",35 src: "/assets/builder/traits/pupils/copycat_eyes.png",36 },37 cross_eyes: {38 rarity: 284,39 label: "cross Eyes",40 src: "/assets/builder/traits/pupils/cross_eyes.png",41 },42 cursed_assassin_eyes: {43 rarity: 259,44 label: "cursed Assassin Eyes",45 src: "/assets/builder/traits/pupils/cursed_assassin_eyes.png",46 },47 demon_eyes: {48 rarity: 162,49 label: "demon Eyes",50 src: "/assets/builder/traits/pupils/demon_eyes.png",51 },52 dimension_eyes: {53 rarity: 57,54 label: "dimension Eyes",55 src: "/assets/builder/traits/pupils/dimension_eyes.png",56 },57 double_copycat_eyes: {58 rarity: 37,59 label: "double copycat Eyes",60 src: "/assets/builder/traits/pupils/double_copycat_eyes.png",61 },62 elemental_eyes: {63 rarity: 59,64 label: "elemental Eyes",65 src: "/assets/builder/traits/pupils/elemental_eyes.png",66 },67 foresight_eyes: {68 rarity: 117,69 label: "foresight Eyes",70 src: "/assets/builder/traits/pupils/foresight_eyes.png",71 },72 ghoul_eyes: {73 rarity: 109,74 label: "ghoul Eyes",75 src: "/assets/builder/traits/pupils/ghoul_eyes.png",76 },77 god_eyes: {78 rarity: 261,79 label: "god Eyes",80 src: "/assets/builder/traits/pupils/god_eyes.png",81 },82 infinite_eyes: {83 rarity: 51,84 label: "infinite Eyes",85 src: "/assets/builder/traits/pupils/infinite_eyes.png",86 },87 lifespan_eyes: {88 rarity: 189,89 label: "lifespan Eyes",90 src: "/assets/builder/traits/pupils/lifespan_eyes.png",91 },92 obedience_eye: {93 rarity: 190,94 label: "obedience Eye",95 src: "/assets/builder/traits/pupils/obedience_eye.png",96 },97 orange_and_blue_eyes: {98 rarity: 249,99 label: "orange & blue Eyes",100 src: "/assets/builder/traits/pupils/orange_and_blue_eyes.png",101 },102 perceptive_eyes: {103 rarity: 247,104 label: "perceptive Eyes",105 src: "/assets/builder/traits/pupils/perceptive_eyes.png",106 },107 rainbow_eyes: {108 rarity: 232,109 label: "rainbow Eyes",110 src: "/assets/builder/traits/pupils/rainbow_eyes.png",111 },112 red_and_yellow_eyes: {113 rarity: 267,114 label: "red & yellow Eyes",115 src: "/assets/builder/traits/pupils/red_and_yellow_eyes.png",116 },117 sage_eyes: {118 rarity: 114,119 label: "sage Eyes",120 src: "/assets/builder/traits/pupils/sage_eyes.png",121 },122 sand_eyes: {123 rarity: 218,124 label: "sand Eyes",125 src: "/assets/builder/traits/pupils/sand_eyes.png",126 },127 spider_eyes: {128 rarity: 133,129 label: "spider Eyes",130 src: "/assets/builder/traits/pupils/spider_eyes.png",131 },132 universal_eyes: {133 rarity: 76,134 label: "universal Eyes",135 src: "/assets/builder/traits/pupils/universal_eyes.png",136 },137 vampire_eyes: {138 rarity: 156,139 label: "vampire Eyes",140 src: "/assets/builder/traits/pupils/vampire_eyes.png",141 },142 wrath_eyes: {143 rarity: 220,144 label: "wrath Eyes",145 src: "/assets/builder/traits/pupils/wrath_eyes.png",146 },...

Full Screen

Full Screen

eyes-test.js

Source:eyes-test.js Github

copy

Full Screen

1var util = require('util');2var eyes = require('../lib/eyes');3eyes.inspect({4 number: 42,5 string: "John Galt",6 regexp: /[a-z]+/,7 array: [99, 168, 'x', {}],8 func: function () {},9 bool: false,10 nil: null,11 undef: undefined,12 object: {attr: []}13}, "native types");14eyes.inspect({15 number: new(Number)(42),16 string: new(String)("John Galt"),17 regexp: new(RegExp)(/[a-z]+/),18 array: new(Array)(99, 168, 'x', {}),19 bool: new(Boolean)(false),20 object: new(Object)({attr: []}),21 date: new(Date)22}, "wrapped types");23var obj = {};24obj.that = { self: obj };25obj.self = obj;26eyes.inspect(obj, "circular object");27eyes.inspect({hello: 'moto'}, "small object");28eyes.inspect({hello: new(Array)(6) }, "big object");29eyes.inspect(["hello 'world'", 'hello "world"'], "quotes");30eyes.inspect({31 recommendations: [{32 id: 'a7a6576c2c822c8e2bd81a27e41437d8',33 key: [ 'spree', 3.764316258020699 ],34 value: {35 _id: 'a7a6576c2c822c8e2bd81a27e41437d8',36 _rev: '1-2e2d2f7fd858c4a5984bcf809d22ed98',37 type: 'domain',38 domain: 'spree',39 weight: 3.764316258020699,40 product_id: 3041 }42 }]43}, 'complex');44eyes.inspect([null], "null in array");45var inspect = eyes.inspector({ stream: null });46util.puts(inspect('something', "something"));47util.puts(inspect("something else"));...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pact-foundation-pact automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful