New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

emellib

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emellib - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

63

haarDetector.js

@@ -1,37 +0,38 @@

var HAAR = require('./dep/haar-detector.js');
var faceHaardata = require('./cascades/haarcascade_frontalface_alt');
export const createHaarDetector = (args) => {
// args
// ----
// videoElement
// canvasElementDisplay
// var HAAR = require('./dep/haar-detector.js');
// var faceHaardata = require('./cascades/haarcascade_frontalface_alt');
const detector = new HAAR.Detector(faceHaardata)
// export const createHaarDetector = (args) => {
// // args
// // ----
// // videoElement
// // canvasElementDisplay
return () => {
args.canvasElementDisplay.width = args.videoElement.offsetWidth;
args.canvasElementDisplay.height = args.videoElement.offsetHeight;
const ctx = args.canvasElementDisplay.getContext('2d');
// const detector = new HAAR.Detector(faceHaardata)
detector
.image(args.videoElement, 1) // todo: remove `document.create ...`
//.interval(40)
.complete(function () {
// processing done
console.log(JSON.stringify(this.objects))
var i, rect, l = this.objects.length;
ctx.strokeStyle = "rgba(220,0,0,1)"; ctx.lineWidth = 10;
ctx.strokeRect(this.Selection.x, this.Selection.y, this.Selection.width, this.Selection.height);
ctx.strokeStyle = "rgba(75,221,17,1)"; ctx.lineWidth = 10;
for (i = 0; i < l; i++) {
//console.log(this.objects[i])
rect = this.objects[i];
ctx.strokeRect(rect.x, rect.y, rect.width, rect.height);
}
}).detect(1, 1.25, 0.1, 1, 0.2, true);
// return () => {
// args.canvasElementDisplay.width = args.videoElement.offsetWidth;
// args.canvasElementDisplay.height = args.videoElement.offsetHeight;
// const ctx = args.canvasElementDisplay.getContext('2d');
ctx.drawImage(args.videoElement, 0, 0)
}
// detector
// .image(args.videoElement, 1) // todo: remove `document.create ...`
// //.interval(40)
// .complete(function () {
// // processing done
// console.log(JSON.stringify(this.objects))
// var i, rect, l = this.objects.length;
// ctx.strokeStyle = "rgba(220,0,0,1)"; ctx.lineWidth = 10;
// ctx.strokeRect(this.Selection.x, this.Selection.y, this.Selection.width, this.Selection.height);
// ctx.strokeStyle = "rgba(75,221,17,1)"; ctx.lineWidth = 10;
// for (i = 0; i < l; i++) {
// //console.log(this.objects[i])
// rect = this.objects[i];
// ctx.strokeRect(rect.x, rect.y, rect.width, rect.height);
// }
// }).detect(1, 1.25, 0.1, 1, 0.2, true);
}
// ctx.drawImage(args.videoElement, 0, 0)
// }
// }

@@ -0,4 +1,5 @@

//import * as haarDetector from './haarDetector'
import * as motionDetector from './motionDetector'
import * as haarDetector from './haarDetector'
export { motionDetector, haarDetector }
// export { motionDetector, haarDetector }
export { motionDetector }

@@ -66,5 +66,7 @@ import * as utils from './utils'

// total black pixels
const energyScore = (imgData.data.length - utils.countOccurrences(imgData.data, 255)) / 100;
// energyConsole.innerText = energyScore
// const energyScore = (imgData.data.length - utils.countOccurrences(imgData.data, 255)) / 100;
// normalized black pixels
const energyScore = utils.clamp((1 - (utils.countOccurrences(imgData.data, 255) / imgData.data.length)) * 2200, 0, 100);
if (ctxFinal) {

@@ -74,5 +76,5 @@ ctxFinal.putImageData(imgData, 0, 0);

return energyScore / (args.canvasElementHelper.width * args.canvasElementDisplay.height * 4)
return energyScore
}
}
{
"name": "emellib",
"version": "0.0.5",
"version": "0.0.6",
"main": "index.js",

@@ -5,0 +5,0 @@ "homepage": "https://www.crejo.fun/",

@@ -1,1 +0,5 @@

export const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
export const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
export function clamp(number, min, max) {
return Math.max(min, Math.min(number, max));
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc