-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathp5.cv.min.js
2 lines (2 loc) · 53.9 KB
/
p5.cv.min.js
1
2
!function(n){var r={};function i(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,i),e.l=!0,e.exports}i.m=n,i.c=r,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e){p5.cv={},p5.prototype.loadOpenCV=function(){cv.onRuntimeInitialized=function(){p5.cv.isReady=!0,p5.cv.onComplete&&p5.cv.onComplete()},p5.cv.createFileFromUrl=function(n,t,r){var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(t){var e;4===i.readyState&&200===i.status&&(e=new Uint8Array(i.response),cv.FS_createDataFile("/",n,e,!0,!1,!1),r())},i.send()},p5.cv.loadImageToCanvas=function(t,e){var n=document.getElementById(e),r=n.getContext("2d"),i=new Image;i.crossOrigin="anonymous",i.onload=function(){n.width=i.width,n.height=i.height,r.drawImage(i,0,0,i.width,i.height)},i.src=t}},p5.prototype.registerMethod("init",p5.prototype.loadOpenCV)},function(t,e){p5.cv.getWidth=function(t){return t.cols},p5.cv.getHeight=function(t){return t.rows},p5.cv.getAllocated=function(t){return 0<t.rows&&0<t.cols},p5.cv.getDepthForType=function(t){return cv.CV_MAT_DEPTH(t)},p5.cv.getDepthForMat=function(t){return t.depth()},p5.cv.getDepthForImage=function(){return cv.CV_8UC4},cv.CV_8UC=function(t){return 1===t?cv.CV_8UC1:2===t?cv.CV_8UC2:3===t?cv.CV_8UC3:4===t?cv.CV_8UC4:cv.CV_8UC1},cv.CV_8SC=function(t){return 1===t?cv.CV_8SC1:2===t?cv.CV_8SC2:3===t?cv.CV_8SC3:4===t?cv.CV_8SC4:cv.CV_8SC1},cv.CV_16UC=function(t){return 1===t?cv.CV_16UC1:2===t?cv.CV_16UC2:3===t?cv.CV_16UC3:4===t?cv.CV_16UC4:cv.CV_16UC1},cv.CV_16SC=function(t){return 1===t?cv.CV_16SC1:2===t?cv.CV_16SC2:3===t?cv.CV_16SC3:4===t?cv.CV_16SC4:cv.CV_16SC1},cv.CV_32SC=function(t){return 1===t?cv.CV_32SC1:2===t?cv.CV_32SC2:3===t?cv.CV_32SC3:4===t?cv.CV_32SC4:cv.CV_32SC1},cv.CV_32FC=function(t){return 1===t?cv.CV_32FC1:2===t?cv.CV_32FC2:3===t?cv.CV_32FC3:4===t?cv.CV_32FC4:cv.CV_32FC1},cv.CV_64FC=function(t){return 1===t?cv.CV_64FC1:2===t?cv.CV_64FC2:3===t?cv.CV_64FC3:4===t?cv.CV_64FC4:cv.CV_64FC1},cv.CV_CN_MAX=512,cv.CV_CN_SHIFT=3,cv.CV_DEPTH_MAX=1<<cv.CV_CN_SHIFT,cv.CV_MAT_CN_MASK=cv.CV_CN_MAX-1<<cv.CV_CN_SHIFT,cv.CV_MAT_CN=function(t){return 1+((t&cv.CV_MAT_CN_MASK)>>cv.CV_CN_SHIFT)},cv.CV_MAT_DEPTH_MASK=cv.CV_DEPTH_MAX-1,cv.CV_MAT_DEPTH=function(t){return t&cv.CV_MAT_DEPTH_MASK},cv.CV_MAKETYPE=function(t,e){return cv.CV_MAT_DEPTH(t)+(e-1<<cv.CV_CN_SHIFT)},p5.cv.getCvImageType=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:cv.CV_8U;return cv.CV_MAKETYPE(e,t)},p5.cv.getCvImageTypeForImage=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:CV_8U;return cv.CV_MAKETYPE(t,4)},p5.cv.getChannelsForType=function(t){return cv.CV_MAT_CN(t)},p5.cv.getChannelsForImage=function(){return 4},p5.cv.getChannelsForMat=function(t){return t.channels()},p5.cv.copyTo=function(t,e){var n;t.type()===e.type()?t.copyTo(e):(n=p5.cv.getMaxVal(e)/p5.cv.getMaxVal(t),t.convertTo(e,e.depth(),n))},p5.cv.copy=function(t,e){var n=p5.cv.getAllocated(e)?p5.cv.getDepthForMat(e):p5.cv.getDepthForMat(t);p5.cv.copyTo(t,e,n)},p5.cv.allocate=function(t,e,n,r){p5.cv.getWidth(t)===e&&p5.cv.getHeight(t)===n&&p5.cv.getCvImageType(t)===r||t.create(n,e,r)},p5.cv.imitateWithType=function(t,e,n){var r=p5.cv.getWidth(e),e=p5.cv.getHeight(e);p5.cv.allocate(t,r,e,n)},p5.cv.imitate=function(t,e){p5.cv.imitateWithType(t,e,p5.cv.getCvImageType(e))},p5.cv.getMaxValForDepth=function(t){switch(t){case cv.CV_8U:return 255;case cv.CV_16U:return 65535;case cv.CV_8S:return 127;case cv.CV_16S:return 32767;case cv.CV_32S:return 2147483647;case cv.CV_32F:return 1;case cv.CV_64F:default:return 1}},p5.cv.getMaxValForMat=function(t){return p5.cv.getMaxValForDepth(t.depth())},p5.cv.getColorConversionTypes=function(){var t=[];for(property in cv)0===property.indexOf("COLOR_")&&t.push(property);return t},p5.cv.getTargetChannelsFromCode=function(t){return t===cv.COLOR_RGB2RGBA?4:t===cv.COLOR_RGBA2RGB?3:t===cv.COLOR_RGB2BGRA?4:t===cv.COLOR_RGBA2BGR||t===cv.COLOR_BGR2RGB?3:t===cv.COLOR_BGRA2RGBA?4:t===cv.COLOR_BGR2GRAY||t===cv.COLOR_RGB2GRAY?1:t===cv.COLOR_GRAY2RGB?3:t===cv.COLOR_GRAY2RGBA?4:t===cv.COLOR_BGRA2GRAY||t===cv.COLOR_RGBA2GRAY?1:t===cv.COLOR_BGR5652BGR||t===cv.COLOR_BGR5652RGB?3:t===cv.COLOR_BGR5652BGRA||t===cv.COLOR_BGR5652RGBA?4:t===cv.COLOR_BGR5652GRAY?1:t===cv.COLOR_BGR5552BGR||t===cv.COLOR_BGR5552RGB?3:t===cv.COLOR_BGR5552BGRA||t===cv.COLOR_BGR5552RGBA?4:t===cv.COLOR_BGR5552GRAY?1:t===cv.COLOR_BGR2XYZ||t===cv.COLOR_RGB2XYZ||t===cv.COLOR_XYZ2BGR||t===cv.COLOR_XYZ2RGB||t===cv.COLOR_BGR2YCrCb||t===cv.COLOR_RGB2YCrCb||t===cv.COLOR_YCrCb2BGR||t===cv.COLOR_YCrCb2RGB||t===cv.COLOR_BGR2HSV||t===cv.COLOR_RGB2HSV||t===cv.COLOR_BGR2Lab||t===cv.COLOR_RGB2Lab||t===cv.COLOR_BayerGB2BGR||t===cv.COLOR_BayerBG2RGB||t===cv.COLOR_BayerGB2RGB||t===cv.COLOR_BayerRG2RGB||t===cv.COLOR_BGR2Luv||t===cv.COLOR_RGB2Luv||t===cv.COLOR_BGR2HLS||t===cv.COLOR_RGB2HLS||t===cv.COLOR_HSV2BGR||t===cv.COLOR_HSV2RGB||t===cv.COLOR_Lab2BGR||t===cv.COLOR_Lab2RGB||t===cv.COLOR_Luv2BGR||t===cv.COLOR_Luv2RGB||t===cv.COLOR_HLS2BGR||t===cv.COLOR_HLS2RGB||t===cv.COLOR_BayerBG2RGB_VNG||t===cv.COLOR_BayerGB2RGB_VNG||t===cv.COLOR_BayerRG2RGB_VNG||t===cv.COLOR_BayerGR2RGB_VNG||t===cv.COLOR_BGR2HSV_FULL||t===cv.COLOR_RGB2HSV_FULL||t===cv.COLOR_BGR2HLS_FULL||t===cv.COLOR_RGB2HLS_FULL||t===cv.COLOR_HSV2BGR_FULL||t===cv.COLOR_HSV2RGB_FULL||t===cv.COLOR_HLS2BGR_FULL||t===cv.COLOR_HLS2RGB_FULL||t===cv.COLOR_LBGR2Lab||t===cv.COLOR_LRGB2Lab||t===cv.COLOR_LBGR2Luv||t===cv.COLOR_LRGB2Luv?3:t===cv.COLOR_Lab2LBGR||t===cv.COLOR_Lab2LRGB||t===cv.COLOR_Luv2LBGR||t===cv.COLOR_Luv2LRGB?4:t===cv.COLOR_BGR2YUV||t===cv.COLOR_RGB2YUV||t===cv.COLOR_YUV2BGR||t===cv.COLOR_YUV2RGB?3:0},p5.cv.pixelsToCvMat=function(t,e,n){return cv.matFromArray(t,e,cv.CV_8UC4,n)},p5.cv.imageDataToCvMat=function(t){return cv.matFromImageData(t)},p5.cv.vectorsToCvContour=function(t){return cv.matFromArray(t.length,1,cv.CV_32SC2,t.map(function(t){return[t.x,t.y]}).flat())},p5.cv.colorToCvScalar=function(t){return t instanceof p5.Color?t.levels:(Array,t)},p5.cv.cvRotatedRectToPoints=function(t){return cv.RotatedRect.points(t)},p5.cv.cvRotatedRectToVectors=function(t){return p5.cv.cvRotatedRectToPoints(t).map(function(t){return createVector(t.x,t.y)})},p5.cv.cvContourToPoints=function(t){return p5.cv.cvPointsToJS(t)},p5.cv.cvPointToVector=function(t){return createVector(t.x,t.y)},p5.cv.cvRectVectorToArray=function(t,e){for(var n=t.size(),r=0;r<n;r++)e.push(t.get(r))}},function(t,e){function n(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}p5.cv.ZERO_SCALAR=[0,0,0,0],p5.cv.makeMatrix=function(t,e){3===t.rows&&3===t.cols?n=t:(n=new cv.Mat(3,3,cv.CV_32FC1,p5.cv.ZERO_SCALAR),cv.Rodrigues(t,n));var n=n.data32F,e=e.data32F;return[n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,e[0],e[1],e[2],1]},p5.cv.applyMatrix=function(t){applyMatrix.apply(void 0,n(t))},p5.cv.drawMat=function(t,e,n,r,i){var o=p5.cv.matToNewImage(t);r=r||t.cols,i=i||t.rows,image(o,e,n,r,i)},p5.cv.drawVectors=function(t){var e,n=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],r=t.length;beginShape();for(var i=0;i<r;i++)e=t[i],vertex(e.x,e.y);n&&(e=t[0],vertex(e.x,e.y)),endShape()},p5.cv.drawRotatedRect=function(t){var e=t.center,n=t.size;push(),translate(e.x,e.y),rotate(radians(t.angle)),rect(.5*-n.width,.5*-n.height,n.width,n.height),pop()},p5.cv.drawRotatedEllipse=function(t){var e=t.center,n=t.size;push(),translate(e.x,e.y),rotate(radians(t.angle)),ellipse(0,0,n.width,n.height),pop()},p5.cv.findMaxLocation=function(t){return cv.minMaxLoc(t).maxLoc},p5.cv.meanCols=function(t){for(var e=new cv.Mat(t.cols,1,cv.CV_32FC1),n=0;n<t.cols;n++)e.row(n).data32F[0]=cv.mean(t.col(n))[0];return e},p5.cv.meanRows=function(t){for(var e=new cv.Mat(t.rows,1,cv.CV_32FC1),n=0;n<t.cols;n++)e.row(n).data32F[0]=cv.mean(t.row(n))[0];return colMat},p5.cv.sumData=function(t){return t.reduce(function(t,e){return t+e})},p5.cv.sumCols=function(t){for(var e=new cv.Mat(t.cols,1,CV_32FC1),n=0;n<t.cols;n++)e.row(n).data32F[0]=t.col(n).data.reduce(function(t,e){return t+e});return e},p5.cv.sumRows=function(t){for(var e=new cv.Mat(t.rows,1,CV_32FC1),n=0;n<t.rows;n++)e.row(n).data32F[0]=t.row(n).data.reduce(function(t,e){return t+e});return e},p5.cv.minCols=function(t){for(var e=new cv.Mat(t.cols,1,CV_32FC1),n=0;n<t.cols;n++)e.row(n).data32F[0]=minMaxLoc(mat.col(n)).minVal;return e},p5.cv.minRows=function(t){for(var e=new cv.Mat(t.rows,1,cv.CV_32FC1),n=0;n<t.cols;n++)e.row(n).data32F[0]=minMaxLoc(mat.row(n)).minVal;return colMat},p5.cv.maxCols=function(t){for(var e=new cv.Mat(t.cols,1,CV_32FC1),n=0;n<t.cols;n++)e.row(n).data32F[0]=minMaxLoc(mat.col(n)).maxVal;return e},p5.cv.maxRows=function(t){for(var e=new cv.Mat(t.rows,1,cv.CV_32FC1),n=0;n<t.cols;n++)e.row(n).data32F[0]=minMaxLoc(mat.row(n)).maxVal;return colMat},p5.cv.findFirst=function(t,e){for(var n=0;n<t.rows;n++)if(t.charAt(n)===e)return n;return 0},p5.cv.findLast=function(t,e){for(var n=t.rows-1;0<=n;n--)if(t.charAt(n)===e)return n;return 0},p5.cv.getBoundingBox=function(t,e,n){var r=n?cv.THRESH_BINARY_INV:cv.THRESH_BINARY,n=new cv.Rect,t=p5.cv.meanRows(t);cv.threshold(t,t,e,255,r),n.y=p5.cv.findFirst(t,255),n.height=p5.cv.findLast(t,255),n.height-=n.y;t=p5.cv.meanCols(mat);return cv.threshold(t,t,e,255,r),n.x=findFirst(t,255),n.width=findLast(t,255),n.width-=n.x,n},p5.cv.weightedAverageAngle=function(t){for(var e=0,n=0,r=0;r<t.rows;r++){var i=new cv.Point(t.data32S[4*r],t.data32S[4*r+1]),o=new cv.Point(t.data32S[4*r+2],t.data32S[4*r+3]),o=p5.Vector.sub(o,i),i=o.mag(),i=i*i;e+=atan2(o.y,o.x)*i,n+=i}return e/n},p5.cv.autorotate=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:50,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:200,i=new cv.Mat;return cv.Canny(t,i,n,r),autorotate(t,i,e)},p5.cv.autorotate=function(t,e,n){p5.cv.imitate(n,t);var r=new cv.Mat,i=PI/180,o=(srcMat.rows+srcMat.cols)/8;cv.HoughLinesP(e,r,1,i,10,o,3);r=ofRadToDeg(weightedAverageAngle(r));return p5.cv.rotate(t,n,r),r},p5.cv.imageToNewMat=function(t){return cv.imread(t.canvas)},p5.cv.imageToMat=function(t,e){var n=t.width,r=t.height;p5.cv.getAllocated(e)||p5.cv.allocate(e,n,r,cv.CV_8UC4);r=t.canvas.getContext("2d").getImageData(0,0,n,r).data;e.data.set(r)},p5.cv.getCvVideoCapture=function(t){return new cv.VideoCapture(t.elt)},p5.cv.getRGBAMat=function(t,e){return cv.Mat.zeros(e,t,cv.CV_8UC4)},p5.cv.getRGBMat=function(t,e){return cv.Mat.zeros(e,t,cv.CV_8UC3)},p5.cv.getGrayscaleMat=function(t,e){return cv.Mat.zeros(e,t,cv.CV_8UC1)},p5.cv.matToImage=function(t,e){cv.imshow(e.canvas,t)},p5.cv.matToNewImage=function(t){var e=createImage(t.cols,t.rows);return cv.imshow(e.canvas,t),e},p5.cv.areSamesize=function(t,e){return t.rows===e.rows&&t.cols===e.cols},cv.Scalar.sub=function(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3]]},cv.Scalar.add=function(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2],t[3]+e[3]]},cv.Point.sub=function(t,e){return new cv.Point(t.x-e.x,t.x-e.x)},cv.Point.add=function(t,e){return new cv.Point(t.x+e.x,t.x+e.x)}},function(t,e){p5.cv.invertTo=function(t,e){cv.bitwise_not(t,e)},p5.cv.invert=function(t){p5.cv.invertTo(t,t)},p5.cv.lerp=function(t,e,n,r){0===e.cols?t.copyTo(n):0===t.cols?e.copyTo(n):cv.addWeighted(t,r,e,1-r,0,n)},p5.cv.accumulate=function(t,e){cv.add(t,e,e)},p5.cv.accumulateWeighted=function(t,e,n){p5.cv.lerp(e,t,e,n)},p5.cv.normalizeTo=function(t,e){cv.normalize(t,e,0,p5.cv.getMaxValForMat(e),cv.NORM_MINMAX)},p5.cv.normalize=function(t){p5.cv.normalizeTo(t,t)},p5.cv.thresholdTo=function(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]&&arguments[3];p5.cv.imitate(e,t);var i=r?cv.THRESH_BINARY_INV:cv.THRESH_BINARY,r=p5.cv.getMaxValForMat(e);cv.threshold(t,e,n,r,i)},p5.cv.threshold=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];p5.cv.thresholdTo(t,t,e,n)},p5.cv.MINUS_ONE_POINT=new cv.Point(-1,-1),p5.cv.erodeTo=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1;p5.cv.imitate(e,t),cv.erode(t,e,new cv.Mat,p5.cv.MINUS_ONE_POINT,n)},p5.cv.erode=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;p5.cv.erodeTo(t,t,e)},p5.cv.dilateTo=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1;p5.cv.imitate(e,t),cv.dilate(t,e,new cv.Mat,p5.cv.MINUS_ONE_POINT,n)},p5.cv.dilate=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;p5.cv.dilateTo(t,t,e)},p5.cv.autothresholdTo=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];p5.cv.imitate(e,t);n=cv.THRESH_OTSU|(n?cv.THRESH_BINARY_INV:cv.THRESH_BINARY);cv.threshold(t,e,0,255,n)},p5.cv.autothreshold=function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];p5.cv.autothresholdTo(t,t,e)},p5.cv.convertColor=function(t,e,n){var r=p5.cv.getTargetChannelsFromCode(n);p5.cv.imitate(e,t,p5.cv.getCvImageType(r,p5.cv.getDepthForMat(t))),cv.cvtColor(t,e,n)},p5.cv.convertSingleColor=function(t,e){var n,r=cv.Mat.zeros(1,1,cv.CV_8UC3);if(t instanceof p5.Color)n=t.levels;else{if(!(t instanceof Array))return r.data;n=t}r.data[0]=n[0],r.data[1]=n[1],r.data[2]=n[2],cv.cvtColor(r,r,e);r=Array.from(r.data);return r.push(n[4]),r},p5.cv.copyGray=function(t,e){var n=p5.cv.getChannelsForMat(t);4===n?p5.cv.convertColor(t,e,cv.COLOR_RGBA2GRAY):3===n?p5.cv.convertColor(t,e,cv.COLOR_RGB2GRAY):1===n&&t.copyTo(e)},p5.cv.copyRGB=function(t,e){var n=p5.cv.getChannelsForMat(t);4===n?p5.cv.convertColor(t,e,cv.COLOR_RGBA2RGB):3===n?t.copyTo(e):1===n&&p5.cv.convertColor(t,e,cv.COLOR_GRAY2RGB)},p5.cv.forceOdd=function(t){return 2*Math.floor(t/2)+1},p5.cv.blurTo=function(t,e,n){p5.cv.imitate(e,t),n=p5.cv.forceOdd(n),cv.blur(t,e,new cv.Size(n,n))},p5.cv.blur=function(t,e){p5.cv.blurTo(t,t,e)},p5.cv.GaussianBlurTo=function(t,e,n){p5.cv.imitate(e,t),n=p5.cv.forceOdd(n),cv.GaussianBlur(t,e,new cv.Size(n,n),0,0)},p5.cv.GaussianBlur=function(t,e){p5.cv.GaussianBlurTo(t,t,e)},p5.cv.medianBlurTo=function(t,e,n){p5.cv.imitate(e,t),n=p5.cv.forceOdd(n),cv.medianBlur(t,e,n)},p5.cv.medianBlur=function(t,e){p5.cv.medianBlurTo(t,t,e)},p5.cv.equalizeHistTo=function(t,e){if(p5.cv.imitate(e,t),1<t.channels()){var n=new cv.MatVector,r=new cv.MatVector;split(t,n),split(e,r);for(var i=0;i<n.size();i++)cv.equalizeHist(n.get(i),r.get(i));cv.merge(r,r)}else cv.equalizeHist(t,e)},p5.cv.equalizeHist=function(t){p5.cv.equalizeHistTo(t,t)},p5.cv.Canny=function(t,e,n,r){var i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:3,o=5<arguments.length&&void 0!==arguments[5]&&arguments[5];p5.cv.imitate(e,t,cv.CV_8UC1),cv.Canny(t,e,n,r,i,o)},p5.cv.Sobel=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:-1,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:1,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:3,c=6<arguments.length&&void 0!==arguments[6]?arguments[6]:1,a=7<arguments.length&&void 0!==arguments[7]?arguments[7]:0,s=8<arguments.length&&void 0!==arguments[8]?arguments[8]:cv.BORDER_DEFAULT;p5.cv.imitate(e,t,cv.CV_8UC1),cv.Sobel(t,e,n,r,i,o,c,a,s)},p5.cv.warpPerspective=function(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:cv.INTER_LINEAR;n.type()!==cv.CV_32FC2&&n.convertTo(n,cv.CV_32FC2);var i=t.cols,o=t.rows,o=cv.matFromArray(4,1,cv.CV_32FC2,[0,0,i,0,i,o,0,o]);n instanceof Array&&(n=cv.matFromArray(4,1,cv.CV_32FC2,n));n=cv.getPerspectiveTransform(o,n);cv.warpPerspective(t,e,n,e.size(),r)},p5.cv.unwarpPerspective=function(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:cv.INTER_LINEAR;n.type()!==cv.CV_32FC2&&n.convertTo(n,cv.CV_32FC2);var i=e.cols,o=e.rows,o=cv.matFromArray(4,1,cv.CV_32FC2,[0,0,i,0,i,o,0,o]),o=cv.getPerspectiveTransform(n,o);cv.warpPerspective(t,e,o,e.size(),r)},p5.cv.warpPerspectiveFromTranform=function(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:cv.INTER_LINEAR;cv.warpPerspective(t,e,n,e.size(),r)},p5.cv.resizeTo=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:cv.INTER_LINEAR;cv.resize(t,e,e.size(),0,0,n)},p5.cv.resizeToScale=function(t,e,n,r){var i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:cv.INTER_LINEAR,n=Math.floor(p5.cv.getWidth(t)*n),r=Math.floor(p5.cv.getHeight(t)*r);p5.cv.getWidth(e)===n&&p5.cv.getHeight(e)===r||p5.cv.allocate(e,n,r,p5.cv.getCvImageType(t)),cv.resize(t,e,{width:n,height:r},i)},p5.cv.resizeToDimensions=function(t,e,n,r){var i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:cv.INTER_LINEAR;p5.cv.getWidth(e)===n&&p5.cv.getHeight(e)===r||p5.cv.allocate(e,n,r,p5.cv.getCvImageType(t)),cv.resize(t,e,{width:n,height:r},i)},p5.cv.cvPointsToJS=function(t){for(var e=[],n=0;n<t.rows;n++)e.push({x:t.data32S[2*n],y:t.data32S[2*n+1]});return e},p5.cv.drawContour=function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];beginShape();for(var n=0;n<t.rows;n++)vertex(t.data32S[2*n],t.data32S[2*n+1]);e&&vertex(t.data32S[0],t.data32S[1]),endShape()},p5.cv.cvPointsToVectors=function(t){for(var e=[],n=0;n<t.rows;n++)e.push(createVector(t.data32S[2*n],t.data32S[2*n+1]));return e},p5.cv.cvFeaturesToPoints=function(t){for(var e=[],n=0;n<t.rows;n++)e.push({x:t.data32F[2*n],y:t.data32F[2*n+1]});return e},p5.cv.getFeatureAsPoint=function(t,e){return{x:t.data32F[2*e],y:t.data32F[2*e+1]}},p5.cv.cvLineToJS=function(t){for(var e=[],n=0;n<t.rows;n++)e.push({x:t.data32F[2*n],y:t.data32F[2*n+1]});return e},p5.cv.cvLineToVectors=function(t){for(var e=[],n=0;n<t.rows;n++)e.push(createVector(t.data32F[2*n],t.data32F[2*n+1]));return e},p5.cv.getConvexHullMat=function(t){var e=new cv.Mat;return cv.convexHull(t,e),e},p5.cv.convexHullFromMat=function(t){return p5.cv.cvPointsToJS(p5.cv.getConvexHullMat(t))},p5.cv.convexHull=function(t){t=p5.cv.vectorsToCvContour(t);return p5.cv.convexHullFromMat(t)},p5.cv.convexityDefectsCv=function(t){var e=new cv.Mat,n=new cv.Mat;return cv.convexHull(t,e,!1,!1),cv.convexityDefects(t,e,n),n},p5.cv.convexityDefectsFromVectors=function(t){return p5.cv.cvPointsToVectors(p5.cv.convexityDefectsCv(p5.cv.vectorsToCvContour(t)))},p5.cv.minAreaRectFromVectors=function(t){return cv.minAreaRect(p5.cv.vectorsToCvContour(t))},p5.cv.fitEllipseFromVectors=function(t){return cv.fitEllipse(p5.cv.vectorsToCvContour(t))},p5.cv.fitLineFromVectors=function(t,e){var n=new cv.Mat;cv.fitLine(p5.cv.vectorsToCvContour(t),n,cv.DIST_L2,0,.01,.01);var r=n.data32F[0],i=n.data32F[1],o=n.data32F[2],t=n.data32F[3],n=Math.round(-o*i/r+t),t=Math.round((e-o)*i/r+t);return[createVector(e-1,t),createVector(0,n)]},p5.cv.fillPoly=function(t,e){var n=[t.length];e.setTo(p5.cv.ZERO_SCALAR),cv.fillPoly(e,t,n,1,[255,255,255,255])},p5.cv.FLIP_HORIZONTAL=1,p5.cv.FLIP_VERTICAL=0,p5.cv.FLIP_BOTH=-1,p5.cv.flipTo=function(t,e,n){p5.cv.imitate(e,t),cv.flip(t,e,n)},p5.cv.flip=function(t,e){p5.cv.flipTo(t,t,e)},p5.cv.rotateTo=function(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[0,0,0,255],i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:cv.INTER_LINEAR;p5.cv.imitate(e,t);var o=new cv.Point(Math.floor(.5*t.cols),Math.floor(.5*t.rows)),n=cv.getRotationMatrix2D(o,n,1);cv.warpAffine(t,e,n,t.size(),i,cv.BORDER_CONSTANT,r)},p5.cv.rotate=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[0,0,0,255],r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:cv.INTER_LINEAR;p5.cv.rotateTo(t,t,e,n,r)},p5.cv.rotate90To=function(t,e,n){0===n?t.copyTo(e):90===n?(cv.transpose(t,e),cv.flip(t,e,p5.cv.FLIP_HORIZONTAL)):180===n?(p5.cv.imitate(e,t),cv.flip(t,e,p5.cv.FLIP_BOTH)):270===n&&cv.transpose(t,e)},p5.cv.rotate90=function(t,e){p5.cv.rotate90To(t,t,e)},p5.cv.transposeTo=function(t,e){cv.transpose(t,e)},p5.cv.transpose=function(t){p5.cv.transposeTo(t,t)},p5.cv.swap=function(t,e){var n=t.clone();e.copyTo(t),n.copyTo(e),n.delete()}},function(t,e,n){"use strict";n.r(e);n(0),n(1),n(2),n(3);function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var c,a=t[Symbol.iterator]();!(r=(c=a.next()).done)&&(n.push(c.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}return n}(t,e)||h(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function f(t,e,n){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=p(t)););return t}(t,e);if(t){e=Object.getOwnPropertyDescriptor(t,e);return e.get?e.get.call(n):e.value}})(t,e,n||t)}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(n){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=p(n);return t=r?(t=p(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),e=this,!(t=t)||"object"!==i(t)&&"function"!=typeof t?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function g(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),t}p5.cv.trackingDistanceRect=function(t,e){var n=t.x+.5*t.width-(e.x+.5*e.width),r=t.y+.5*t.height-(e.y+.5*e.height),i=t.width-e.width,e=t.height-e.height;return Math.sqrt(n*n+r*r)+Math.sqrt(i*i+e*e)},p5.cv.trackingDistancePoint=function(t,e){return dist(t.x,t.y,e.x,e.y)},p5.cv.isPoint=function(t){return"x"in t&&"y"in t&&!("width"in t)},p5.cv.isRect=function(t){return"x"in t&&"y"in t&&"width"in t&&"height"in t},p5.cv.trackingDistance=function(t,e){return p5.cv.isPoint(t)&&p5.cv.isPoint(e)?p5.cv.trackingDistancePoint(t,e):p5.cv.isRect(t)&&p5.cv.isRect(e)?p5.cv.trackingDistanceRect(t,e):-1};var L=function(){function t(){s(this,t)}return g(t,[{key:"initFromObject",value:function(t,e,n){return this.lastSeen=0,this.label=e,this.age=0,this.index=n,this.object=t,this}},{key:"initFromPreviousObject",value:function(t,e,n){return this.lastSeen=0,this.label=e.label,this.age=e.age,this.index=n,this.object=t,this}},{key:"copyFrom",value:function(t){return this.lastSeen=t.lastSeen,this.label=t.label,this.age=t.age,this.index=-1,this.object=t.object,this}},{key:"timeStep",value:function(t){this.age++,t||this.lastSeen++}},{key:"getLastSeen",value:function(){return this.lastSeen}},{key:"getAge",value:function(){return this.age}},{key:"getLabel",value:function(){return this.label}},{key:"getIndex",value:function(){return this.index}}]),t}(),d=function(){function t(){s(this,t),this.previous=[],this.current=[],this.currentLabels=[],this.previousLabels=[],this.newLabels=[],this.deadLabels=[],this.previousLabelMap=new Map,this.currentLabelMap=new Map,this.persistence=15,this.curLabel=0,this.maximumDistance=64}return g(t,[{key:"getNewLabel",value:function(){return this.curLabel++}},{key:"setPersistence",value:function(t){this.persistance=t}},{key:"setMaximumDistance",value:function(t){this.maximumDistance=t}},{key:"sortByDistance",value:function(t,e){return t.distance>e.distance?1:t.distance<e.distance?-1:0}},{key:"track",value:function(t){this.previous=[].concat(this.current);for(var e=t.length,n=this.previous.length,r=[],i=0;i<e;i++)for(var o=0;o<n;o++){var c=p5.cv.trackingDistance(t[i],this.previous[o].object);c<this.maximumDistance&&r.push({pair:[i,o],distance:c})}r.sort(this.sortByDistance),this.previousLabels=[].concat(this.currentLabels),this.currentLabels=new Array(e),this.current.length=0;for(var a=new Array(e).fill(!1),s=new Array(n).fill(!1),u=r.length,v=0;v<u;v++){var l=r[v].pair,h=l[0],f=l[1];a[h]||s[f]||(a[h]=!0,s[f]=!0,l=this.current.length,l=(new L).initFromPreviousObject(t[h],this.previous[f],l),this.current.push(l),l.timeStep(!0),this.currentLabels[h]=l.getLabel())}for(var p,g,d=this.newLabels.length=0;d<e;d++){a[d]||(p=this.getNewLabel(),g=this.current.length,g=(new L).initFromObject(t[d],p,g),this.current.push(g),g.timeStep(!0),this.currentLabels[d]=p,this.newLabels.push(p))}for(var y=this.deadLabels.length=0;y<n;y++)s[y]||(this.previous[y].getLastSeen()<this.persistence&&(this.current.push(this.previous[y]),this.current[this.current.length-1].timeStep(!1)),this.deadLabels.push(this.previous[y].getLabel()));this.currentLabelMap.clear();for(var C=this.current.length,w=0;w<C;w++){var R=this.current[w].getLabel();this.currentLabelMap.set(R,this.current[w])}this.previousLabelMap.clear();for(var m=this.previous.length,_=0;_<m;_++){var O=this.previous[_].getLabel();this.previousLabelMap.set(O,this.previous[_])}return this.currentLabels}},{key:"getCurrentLabels",value:function(){return this.currentLabels}},{key:"getPreviousLabels",value:function(){return this.previousLabels}},{key:"getNewLabels",value:function(){return this.newLabels}},{key:"getDeadLabels",value:function(){return this.deadLabels}},{key:"getLabelFromIndex",value:function(t){return this.currentLabels[t]}},{key:"getIndexFromLabel",value:function(t){if(this.currentLabelMap.has(t))return this.currentLabelMap.get(t).getIndex()}},{key:"getPrevious",value:function(t){if(this.previousLabelMap.has(t))return this.previousLabelMap.get(t).object}},{key:"getCurrent",value:function(t){if(this.currentLabelMap.has(t))return this.currentLabelMap.get(t).object}},{key:"existsCurrent",value:function(t){return this.currentLabelMap.has(t)}},{key:"existsPrevious",value:function(t){return this.previousLabelMap.has(t)}},{key:"getAge",value:function(t){if(this.currentLabelMap.has(t))return this.currentLabelMap.get(t).getAge()}},{key:"getLastSeen",value:function(t){if(this.currentLabelMap.has(t))return this.currentLabelMap.get(t).getLastSeen()}}]),t}(),v=function(){o(v,d);var e=a(v);function v(){var t;return s(this,v),(t=e.call(this)).smoothingRate=.5,t.smoothed=new Map,t}return g(v,[{key:"setSmoothingRate",value:function(t){this.smoothingRate=t}},{key:"getSmoothingRate",value:function(){return this.smoothingRate}},{key:"track",value:function(t){for(var e=f(p(v.prototype),"track",this).call(this,t),n=e.length,r=0;r<n;r++){var i,o=e[r],c=this.getCurrent(o);this.smoothed.has(o)?((i=this.smoothed.get(o)).x=lerp(i.x,c.x,smoothingRate),i.y=lerp(i.y,c.y,smoothingRate),i.width=lerp(i.width,c.width,smoothingRate),i.height=lerp(i.height,c.height,smoothingRate)):this.smoothed[o]=c}var a=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=h(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,e=function(){};return{s:e,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,c=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return o=t.done,t},e:function(t){c=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(c)throw i}}}}(this.smoothed.entries());try{for(a.s();!(u=a.n()).done;){var s=l(u.value,2),u=s[0];s[1];this.existsCurrent(u)||this.smoothed.delete(u)}}catch(t){a.e(t)}finally{a.f()}return e}},{key:"getSmoothed",value:function(t){if(this.smoothed.has(t))return this.smoothed.get(t)}},{key:"getVelocity",value:function(t){var e=this.getLabelFromIndex(t);if(this.existsPrevious(e)){t=this.getPrevious(e),e=this.getCurrent(e),t=createVector(t.x+.5*t.width,t.y+.5*t.height),e=createVector(e.x+.5*e.width,e.y+.5*e.height);return p5.Vector.sub(e,t)}return createVector()}}]),v}(),y=function(){o(e,d);var t=a(e);function e(){return s(this,e),t.call(this)}return e}(),C=function(){function t(){s(this,t),this.dead=!1,this.label=0}return g(t,[{key:"setup",value:function(){}},{key:"update",value:function(){}},{key:"kill",value:function(){this.dead=!0}},{key:"setLabel",value:function(t){this.label=t}},{key:"getLabel",value:function(){return this.label}},{key:"getDead",value:function(){return this.dead}}]),t}(),w=function(){o(e,C);var t=a(e);function e(){return s(this,e),t.call(this)}return e}(),R=function(){o(e,C);var t=a(e);function e(){return s(this,e),t.call(this)}return e}(),m=function(){o(v,d);var e=a(v);function v(){var t;return s(this,v),(t=e.call(this)).labels=[],t.followers=[],t}return g(v,[{key:"track",value:function(t){f(p(v.prototype),"track",this).call(this,t);for(var e=this.labels.length,n=0;n<e;n++){var r=this.labels[n],i=this.followers[n];this.existsCurrent(r)?i.update(this.getCurrent(r)):i.kill()}for(var o=this.newLabels.length,c=0;c<o;c++){var a=this.newLabels[c];this.labels.push(a);var s=new C;this.followers.push(s),s.setup(this.getCurrent(a)),s.setLabel(a)}for(var u=(e=this.labels.length)-1;0<=u;u--)this.followers[u].getDead()&&(this.followers.splice(u,1),this.labels.splice(u,1));return this.labels}},{key:"getFollowers",value:function(){return this.followers}}]),v}(),_=function(){o(e,m);var t=a(e);function e(){return s(this,e),t.call(this)}return e}(),O=function(){o(e,m);var t=a(e);function e(){return s(this,e),t.call(this)}return e}();function b(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var S={ABSDIFF:0,BRIGHTER:1,DARKER:2},T=function(){function n(t,e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),this.learningRate=1e-4,this.learningTime=900,this.useLearningTime=!1,this.thresholdValue=26,this.ignoreForeground=!1,this.needToReset=!1,this.differenceMode=S.ABSDIFF,this.accumulator=new cv.Mat,this.background=cv.Mat.zeros(e,t,cv.CV_32F),this.foreground=cv.Mat.zeros(e,t,cv.CV_32F),this.foregroundGray=cv.Mat.zeros(e,t,cv.CV_32F)}var t,e,r;return t=n,(e=[{key:"update",value:function(t,e){switch((this.needToReset||this.accumulator.empty())&&(this.needToReset=!1,t.copyTo(this.accumulator)),this.accumulator.convertTo(this.background,cv.CV_8U),this.differenceMode){case S.ABSDIFF:cv.absdiff(this.background,t,this.foreground);break;case S.BRIGHTER:cv.subtract(t,this.background,this.foreground);break;case S.DARKER:cv.subtract(this.background,t,this.foreground)}p5.cv.copyGray(this.foreground,this.foregroundGray);var n=this.ignoreForeground?cv.THRESH_BINARY_INV:cv.THRESH_BINARY;cv.threshold(this.foregroundGray,e,this.thresholdValue,255,n);n=float(this.learningRate);this.useLearningTime&&(n=pow(1-this.thresholdValue/255,1/float(this.learningRate))),this.ignoreForeground,p5.cv.accumulateWeighted(t,this.accumulator,n)}},{key:"getPresence",value:function(){return cv.mean(this.foreground).data[0]/255}},{key:"setThresholdValue",value:function(t){this.thresholdValue=t}},{key:"setLearningRate",value:function(t){this.learningRate=t,this.useLearningTime=!1}},{key:"setLearningTime",value:function(t){this.learningTime=t,this.useLearningTime=!0}},{key:"setIgnoreForeground",value:function(t){this.ignoreForeground=t}},{key:"setDifferenceMode",value:function(t){this.differenceMode=t}},{key:"reset",value:function(){this.needToReset=!0}}])&&b(t.prototype,e),r&&b(t,r),n}();function F(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var k=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.rescale=1,this.multiScaleFactor=1.1,this.minNeighbors=3,this.minSizeScale=new cv.Size,this.maxSizeScale=new cv.Size(1,1),this.useHistogramEqualization=!0,this.cannyPrunning=!1,this.findBiggestObject=!1,this.gray=new cv.Mat,this.graySmall=new cv.Mat,this.classifier=new cv.CascadeClassifier,this.objects=[],this.tracker=new RectTracker}var t,n,r;return t=e,(n=[{key:"setup",value:function(t){this.classifier.load(t)}},{key:"update",value:function(t){if(!this.classifier.empty()){1===t.channels()?this.gray=t:p5.cv.copyGray(t,this.gray),p5.cv.resizeToScale(this.gray,this.graySmall,this.rescale,this.rescale),this.useHistogramEqualization&&p5.cv.equalizeHist(this.graySmall);var e=new cv.Size,n=new cv.Size,r=min(this.graySmall.rows,this.graySmall.cols);0<this.minSizeScale&&(t=this.minSizeScale*r,e.width=t,e.height=t),this.maxSizeScale<1&&(i=this.maxSizeScale*r,n.width=i,n.height=i);var i=new cv.RectVector;this.classifier.detectMultiScale(this.graySmall,i,this.multiScaleFactor,this.minNeighbors,(this.cannyPruning?cv.CASCADE_DO_CANNY_PRUNING:0)|(this.findBiggestObject?cv.CASCADE_FIND_BIGGEST_OBJECT|cv.CASCADE_DO_ROUGH_SEARCH:0),e,n),this.objects.length=0,p5.cv.cvRectVectorToArray(i,this.objects),i.delete();for(var o,c=this.objects.length,a=0;a<c;a++)(o=this.objects[a]).width/=this.rescale,o.height/=this.rescale,o.x/=this.rescale,o.y/=this.rescale,this.objects[a]=o;this.tracker.track(this.objects)}}},{key:"size",value:function(){return this.objects.length}},{key:"getObject",value:function(t){return this.objects[t]}},{key:"getObjectSmoothed",value:function(t){return this.tracker.getSmoothed(this.getLabel(t))}},{key:"getVelocity",value:function(t){return this.tracker.getVelocity(t)}},{key:"getLabel",value:function(t){return this.tracker.getCurrentLabels()[t]}},{key:"getTracker",value:function(){return this.tracker}},{key:"draw",value:function(){push(),noFill(),stroke(0,192,0);for(var t,e=this.size(),n=0;n<e;n++)t=this.getObject(n),rect(t.x,t.y,t.width,t.height),text(this.getLabel(n),t.x,t.y-3);pop()}},{key:"setPreset",value:function(t){t===e.FAST?(this.setRescale(.25),this.setMinNeighbors(2),this.setMultiScaleFactor(1.2),this.setMinSizeScale(.25),this.setMaxSizeScale(.75),this.setCannyPruning(!0),this.setFindBiggestObject(!1)):t===e.ACCURATE?(this.setRescale(.5),this.setMinNeighbors(6),this.setMultiScaleFactor(1.02),this.setMinSizeScale(.1),this.setMaxSizeScale(1),this.setCannyPruning(!0),this.setFindBiggestObject(!1)):t===e.SENSITIVE&&(this.setRescale(.5),this.setMinNeighbors(1),this.setMultiScaleFactor(1.02),this.setMinSizeScale(.1),this.setMaxSizeScale(1),this.setCannyPruning(!1),this.setFindBiggestObject(!1))}},{key:"setRescale",value:function(t){this.rescale=t}},{key:"setMinNeighbors",value:function(t){this.minNeighbors=t}},{key:"setMultiScaleFactor",value:function(t){this.multiScaleFactor=t}},{key:"setCannyPruning",value:function(t){this.cannyPrunning=t}},{key:"setFindBiggestObject",value:function(t){this.findBiggestObject=t}},{key:"setUseHistogramEqualization",value:function(t){this.useHistogramEqualization=t}},{key:"setMinSizeScale",value:function(t){this.minSizeScale=t}},{key:"setMaxSizeScale",value:function(t){this.maxSizeScale=t}}])&&F(t.prototype,n),r&&F(t,r),e}();k.FAST=0,k.ACCURATE=1,k.SENSITIVE=2;var A=k;function M(t){return(M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function V(t,e,n){return(V="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=P(t)););return t}(t,e);if(t){e=Object.getOwnPropertyDescriptor(t,e);return e.get?e.get.call(n):e.value}})(t,e,n||t)}function x(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&B(t,e)}function B(t,e){return(B=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function G(n){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=P(n);return t=r?(t=P(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),e=this,!(t=t)||"object"!==M(t)&&"function"!=typeof t?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}}function P(t){return(P=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function I(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function N(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function E(t,e,n){return e&&N(t.prototype,e),n&&N(t,n),t}var H=function(){function t(){I(this,t),this.last=new cv.Mat,this.curr=new cv.Mat,this.hasFlow=!1}return E(t,[{key:"calcOpticalFlowTo",value:function(t,e){1===t.channels()&&1===e.channels()?this.calcFlow(t,e):(p5.cv.copyGray(t,this.last),p5.cv.copyGray(e,this.curr),this.calcFlow(this.last,this.curr)),this.hasFlow=!0}},{key:"calcOpticalFlow",value:function(t){p5.cv.copyGray(t,this.curr);var e=this.last.size(),t=this.curr.size();e.width===t.width&&e.height===t.height&&(this.calcFlow(this.last,this.curr),this.hasFlow=!0),p5.cv.swap(this.curr,this.last)}},{key:"draw",value:function(t,e,n,r){t=t||0,e=e||0,n=n||width,r=r||height,this.hasFlow&&this.drawFlow(t,e,width,height)}},{key:"drawRect",value:function(t){this.hasFlow&&this.drawFlow(t.x,t.y,t.width,t.height)}},{key:"getWidth",value:function(){return this.curr.cols}},{key:"getHeight",value:function(){return this.curr.rows}},{key:"resetFlow",value:function(){this.last.setTo(p5.cv.ZERO_SCALAR),this.curr.setTo(p5.cv.ZERO_SCALAR),this.hasFlow=!1}},{key:"calcFlow",value:function(){}}]),t}(),z=function(){x(n,H);var e=G(n);function n(){var t;return I(this,n),(t=e.call(this)).prevPts=new cv.Mat,t.nextPts=new cv.Mat,t.windowSize=new cv.Size(32,32),t.maxLevel=3,t.maxFeatures=200,t.maxCorners=30,t.blockSize=7,t.qualityLevel=.01,t.minDistance=4,t.criteria=new cv.TermCriteria(cv.TERM_CRITERIA_EPS|cv.TERM_CRITERIA_COUNT,10,.03),t.pyramidLevels=10,t.calcFeaturesNextFrame=!0,t.pyramid=new cv.Mat,t.prevPyramid=new cv.Mat,t.status=new cv.Mat,t.err=new cv.Mat,t}return E(n,[{key:"setMinDistance",value:function(t){this.minDistance=t}},{key:"setWindowSize",value:function(t){this.windowSize.width=t,this.windowSize.height=t}},{key:"setMaxLevel",value:function(t){this.maxLevel=t}},{key:"setMaxFeatures",value:function(t){this.maxFeatures=t}},{key:"setQualityLevel",value:function(t){this.qualityLevel=t}},{key:"setPyramidLevels",value:function(t){this.pyramidLevels=t}},{key:"getFeatures",value:function(){return p5.cv.cvFeaturesToPoints(this.prevPts)}},{key:"getCurrent",value:function(){for(var t=[],e=0;e<this.nextPts.rows;e++)this.status.data[e]&&t.push(p5.cv.getFeatureAsPoint(this.nextPts,e));return t}},{key:"getMotion",value:function(){for(var t=[],e=this.prevPts.rows,n=0;n<e;n++)this.status.data[n]&&t.push(cv.Point.sub(p5.cv.getFeatureAsPoint(this.nextPts,n),p5.cv.getFeatureAsPoint(this.prevPts,n)));return t}},{key:"resetFeaturesToTrack",value:function(){this.calcFeaturesNextFrame=!0}},{key:"setFeaturesToTrack",value:function(t){this.nextPts=t,this.calcFeaturesNextFrame=!1}},{key:"resetFlow",value:function(){V(P(n.prototype),"resetFlow",this).call(this),this.resetFeaturesToTrack(),this.prevPts=new cv.Mat}},{key:"drawFlow",value:function(t,e,n,r){var i=n/width,o=r/height,c=this.prevPts.rows;beginShape(LINES);for(var a=0;a<c;a++)this.status.data[a]&&(vertex(this.prevPts.data32F[2*a]*i+t,this.prevPts.data32F[2*a+1]*o+e,9),vertex(this.nextPts.data32F[2*a]*i+t,this.nextPts.data32F[2*a+1]*o+e,9));endShape()}},{key:"calcFlow",value:function(t,e){!this.nextPts.empty()||this.calcFeaturesNextFrame?(this.calcFeaturesNextFrame?(this.calcFeaturesToTrack(this.prevPts,e),this.calcFeaturesNextFrame=!1):p5.cv.swap(this.prevPts,this.nextPts),this.nextPts.setTo(p5.cv.ZERO_SCALAR),cv.calcOpticalFlowPyrLK(t,e,this.prevPts,this.nextPts,this.status,this.err,this.windowSize,this.maxLevel)):this.calcFeaturesToTrack(this.nextPts,e)}},{key:"calcFeaturesToTrack",value:function(t,e){cv.goodFeaturesToTrack(e,t,this.maxFeatures,this.qualityLevel,this.minDistance)}}]),n}(),e=function(){x(n,H);var e=G(n);function n(){var t;return I(this,n),(t=e.call(this)).flow=new cv.Mat,t.pyramidScale=.5,t.numLevels=4,t.windowSize=8,t.numIterations=2,t.polyN=7,t.polySigma=1.5,t.farnebackGaussian=!1,t.renderStep=60,t}return E(n,[{key:"setPyramidScale",value:function(t){(t<0||1<=t)&&(t=constrain(t,0,1)),this.pyramidScale=t}},{key:"setNumLevels",value:function(t){this.numLevels=t}},{key:"setWindowSize",value:function(t){this.windowSize=t}},{key:"setNumIterations",value:function(t){this.numIterations=t}},{key:"setPolyN",value:function(t){this.polyN=t}},{key:"setPolySigma",value:function(t){this.polySigma=t}},{key:"setUseGaussian",value:function(t){this.farnebackGaussian=t}},{key:"resetFlow",value:function(){V(P(n.prototype),"resetFlow",this).call(this),this.flow.setTo(p5.cv.ZERO_SCALAR)}},{key:"calcFlow",value:function(t,e){var n=0;this.hasFlow&&(n=cv.OPTFLOW_USE_INITIAL_FLOW),this.farnebackGaussian&&(n|=cv.OPTFLOW_FARNEBACK_GAUSSIAN),cv.calcOpticalFlowFarneback(t,e,this.flow,this.pyramidScale,this.numLevels,this.windowSize,this.numIterations,this.polyN,this.polySigma,n)}},{key:"getFlow",value:function(){return hasFlow||(this.flow=cv.Mat.zeros(1,1,CV_32FC2)),this.flow}},{key:"getTotalFlow",value:function(){return this.getTotalFlowInRegion(0,0,this.flow.cols,this.flow.rows)}},{key:"getAverageFlow",value:function(){return this.getAverageFlowInRegion(0,0,this.flow.cols,this.flow.rows)}},{key:"getFlowOffset",value:function(t,e){if(!this.hasFlow)return new cv.Point;t=2*(t+e*this.flow.cols),e=1+t;return{x:this.flow.data32F[t],y:this.flow.data32F[e]}}},{key:"getFlowPosition",value:function(t,e){var n=this.getFlowOffset(t,e);return n.x+=t,n.y+=e,n}},{key:"getTotalFlowInRegion",value:function(){if(!this.hasFlow)return new cv.Point(0,0);for(var t=0,e=0,n=this.flow.total(),r=this.flow.data32F,i=0;i<n;i++){var o=2*i+1;t+=r[2*i],e+=r[o]}return{x:t,y:e}}},{key:"getAverageFlowInRegion",value:function(t,e,n,r){e=this.getTotalFlowInRegion(t,e,n,r);return e.x/=n,e.y/=r,e}},{key:"drawFlow",value:function(t,e,n,r){if(this.hasFlow){var i,o=n/this.flow.cols,c=r/this.flow.rows;beginShape(LINES);for(var a=0;a<this.flow.rows;a+=this.renderStep)for(var s=0;s<this.flow.cols;s+=this.renderStep)i=this.getFlowPosition(s,a),vertex(s*o+t,a*c+e),vertex(i.x*o+t,i.y*c+e);endShape()}}}]),n}(),D=function(){function r(t,e,n){I(this,r),this.minValue=e,this.maxValue=n,this.historyLength=t,this.history=new Float32Array(t),this.index=0}return E(r,[{key:"addSample",value:function(t){this.history[this.index]=t,this.index=(this.index+1)%this.historyLength}},{key:"getNormalizedSample",value:function(t){var e=(this.index+t)%this.historyLength,t=this.maxValue-this.minValue;return(this.history[e]-this.minValue)/t}},{key:"draw",value:function(t,e){push(),noFill(),strokeWeight(1),beginShape();for(var n=this.maxValue-this.minValue,r=0;r<this.historyLength;r++){var i=(this.index+r)%this.historyLength,o=r*t/this.historyLength,i=(this.history[i]-this.minValue)/n;vertex(o,e-i*e)}endShape(),pop()}}]),r}();p5.cv.samePixels=function(t,e,n,r){for(var i=0;i<r;i+=n)if(t[i]!==e[i])return!1;return!0},p5.cv.same=function(t,e){var n=new cv.Mat,r=new cv.Mat,i=new cv.Mat;p5.cv.copyGray(t,r),p5.cv.copyGray(e,i),cv.absdiff(r,i,n);e=0===cv.countNonZero(n);return n.delete(),r.delete(),i.delete(),e};n=function(){x(n,H);var e=G(n);function n(){var t;return I(this,n),(t=e.call(this)).step=8,t.flow=null,t.uMotionGraph=new D(100,-t.step/2,+t.step/2),t.vMotionGraph=new D(100,-t.step/2,+t.step/2),t}return E(n,[{key:"calcOpticalFlow",value:function(t){this.curr=t;var e=this.last.size(),n=this.curr.size();e.width===n.width&&e.height===n.height&&(p5.cv.samePixels(this.last.data,t.data,4,width)||(this.calcFlow(this.last,this.curr),this.hasFlow=!0)),p5.cv.swap(this.curr,this.last)}},{key:"calcFlow",value:function(t,e){if(t.type()===cv.CV_8UC4&&e.type()===cv.CV_8UC4){for(var n,r,i,o,c,a,s,u,v,l=t.cols,h=t.rows,f=e.data,p=t.data,g=[],d=this.step,y=2*d+1,C=a=0,w=l-d-1,R=h-d-1,m=d+1;m<R;m+=y)for(s=d+1;s<w;s+=y){for(n=r=i=o=c=0,u=-d;u<=d;u++)for(v=-d;v<=d;v++){var _=(m+u)*l+s+v,O=f[4*(_-1)]-f[4*(_+1)],L=f[4*(_-l)]-f[4*(_+l)],_=p[4*_]-f[4*_];n+=O*O,r+=O*L,i+=L*L,c+=O*_,o+=L*_}var b,S,T,F=r*r-n*i;0!=F?(b=-(o*r-c*i)*(T=d/F),S=-(r*c-n*o)*T):0!=(T=(r+n)*(r+n)+(i+r)*(i+r))?(b=(r+n)*(T=-(o+c)*(d/T)),S=(i+r)*T):b=S=0,-y<b&&b<y&&-y<S&&S<y&&(C+=b,a+=S,g.push(new cv.Rect(s,m,b,S)))}return this.flow={zones:g,u:C/g.length,v:a/g.length},this.hasFlow=!0,this.flow}this.hasFlow=!1}},{key:"drawFlow",value:function(e,n,t,r){var i,o,c;this.hasFlow&&(i=t/this.curr.cols,o=r/this.curr.rows,this.flow&&0!==this.flow.u&&0!==this.flow.v&&(this.uMotionGraph.addSample(this.flow.u),this.vMotionGraph.addSample(this.flow.v),strokeWeight(2),c=this.step,this.flow.zones.forEach(function(t){stroke(map(t.width,-c,+c,0,255),map(t.height,-c,+c,0,255),128),line(t.x*i+e,t.y*o+n,(t.x+t.width)*i+e,(t.y+t.height)*o+n)})))}},{key:"plotGraphs",value:function(t,e,n,r){this.hasFlow&&this.flow&&0!==this.flow.u&&0!==this.flow.v&&(this.uMotionGraph.draw(n,r/2),line(t,e+r/4,t+n,e+r/4),translate(0,r/2),this.vMotionGraph.draw(n,r/2),line(t,e+r/4,t+n,e+r/4))}}]),n}();function j(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}p5.cv.TrackingColorMode={TRACK_COLOR_RGB:0,TRACK_COLOR_HSV:1,TRACK_COLOR_H:2,TRACK_COLOR_HS:3};k=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.hsvBuffer=new cv.Mat,this.thresh=new cv.Mat,this.autoThreshold=!0,this.invert=!1,this.simplify=!0,this.thresholdValue=128,this.thresholdValueMax=255,this.useTargetColor=!1,this.trackingColorMode=p5.cv.TrackingColorMode.TRACK_COLOR_HSV,this.targetColor=color(0),this.minArea=0,this.maxArea=Number.POSITIVE_INFINITY,this.minAreaNorm=!1,this.maxAreaNorm=!1,this.contours=[],this.polylines=[],this.tracker=new RectTracker,this.boundingRects=[],this.holes=[],this.contourFindingMode=cv.RETR_EXTERNAL,this.sortBySize=!1,this.resetMinArea(),this.resetMaxArea()}var e,n,r;return e=t,(n=[{key:"findContours",value:function(t){var e,n,r,i;this.useTargetColor?(e=[this.thresholdValue,this.thresholdValue,this.thresholdValue,0],n=p5.cv.colorToCvScalar(this.targetColor),this.trackingColorMode===p5.cv.TrackingColorMode.TRACK_COLOR_RGB?(r=new cv.Mat(t.rows,t.cols,t.type(),cv.Scalar.sub(n,e)),i=new cv.Mat(t.rows,t.cols,t.type(),cv.Scalar.add(n,e)),cv.inRange(t,r,i,this.thresh),r.delete(),i.delete()):(this.trackingColorMode===p5.cv.TrackingColorMode.TRACK_COLOR_H&&(e[1]=255,e[2]=255),this.trackingColorMode===p5.cv.TrackingColorMode.TRACK_COLOR_HS&&(e[2]=255),p5.cv.getAllocated(this.hsvBuffer)||p5.cv.imitate(this.hsvBuffer,t),cv.cvtColor(t,this.hsvBuffer,cv.COLOR_RGBA2RGB),cv.cvtColor(this.hsvBuffer,this.hsvBuffer,cv.COLOR_RGB2HSV),n=p5.cv.convertSingleColor(this.targetColor,cv.COLOR_RGBA2RGB),n=p5.cv.convertSingleColor(n,cv.COLOR_RGB2HSV),c=new cv.Mat(this.hsvBuffer.rows,this.hsvBuffer.cols,this.hsvBuffer.type(),cv.Scalar.sub(n,e)),a=new cv.Mat(this.hsvBuffer.rows,this.hsvBuffer.cols,this.hsvBuffer.type(),cv.Scalar.add(n,e)),cv.inRange(this.hsvBuffer,c,a,this.thresh),c.delete(),a.delete())):p5.cv.copyGray(t,this.thresh),this.autoThreshold&&p5.cv.threshold(this.thresh,this.thresholdValue,this.invert);var o=new cv.MatVector,c=new cv.Mat,a=this.simplify?cv.CHAIN_APPROX_SIMPLE:cv.CHAIN_APPROX_NONE;cv.findContours(this.thresh,o,c,this.contourFindingMode,a);var s=0<this.minArea,u=this.maxAreaNorm?this.maxArea<1:this.maxArea<Number.POSITIVE_INFINITY,v=[],l=[],h=[];if(s||u)for(var t=t.rows*t.cols,f=this.minAreaNorm?this.minArea*t:this.minArea,p=this.maxAreaNorm?this.maxArea*t:this.maxArea,g=0;g<o.size();g++){var d=cv.contourArea(o.get(g),!0),y=!0;d<0&&(d=-d,y=!1),h.push(y),l.push(d),(!s||f<=d)&&(!u||d<=p)&&v.push(g)}else for(var C=0;C<o.size();C++)this.sortBySize&&l.push(cv.contourArea(o.get(C))),v.push(C);1<v.length&&this.sortBySize&&v.sort(function(t,e){return l[t]>l[e]?1:l[t]<l[e]?-1:0}),this.contours.length=0,this.polylines.length=0,this.boundingRects.length=0,this.holes.length=0;for(var w=v.length,R=0;R<w;R++){var m=o.get(v[R]);this.contours.push(m),this.polylines.push(p5.cv.cvPointsToVectors(m)),this.boundingRects.push(cv.boundingRect(m)),this.holes.push(h[v[R]])}this.tracker.track(this.boundingRects)}},{key:"setFindHoles",value:function(t){this.contourFindingMode=t?cv.RETR_LIST:cv.RETR_EXTERNAL}},{key:"setSortBySize",value:function(t){this.sortBySize=t}},{key:"getContours",value:function(){return this.contours}},{key:"getPolylines",value:function(){return this.polylines}},{key:"getBoundingRects",value:function(){return this.boundingRects}},{key:"size",value:function(){return this.contours.length}},{key:"getContour",value:function(t){return this.contours[t]}},{key:"getPolyline",value:function(t){return this.polylines[t]}},{key:"getBoundingRect",value:function(t){return this.boundingRects[t]}},{key:"getCenter",value:function(t){t=this.getBoundingRect(t);return new cv.Point(t.x+.5*t.width,t.y+.5*t.height)}},{key:"getCentroid",value:function(t){t=cv.moments(this.contours[t]);return 0!==t.m00?new cv.Point(t.m10/t.m00,t.m01/t.m00):new cvPoint(0,0)}},{key:"getAverage",value:function(t){t=cv.mean(this.contours[t]);return new cv.Point(t[0],t[1])}},{key:"getBalance",value:function(t){return cv.Point.sub(this.getCentroid(t),this.getCenter(t))}},{key:"getContourArea",value:function(t){return cv.contourArea(this.contours[t])}},{key:"getArcLength",value:function(t){return cv.arcLength(this.contours[t],!0)}},{key:"getConvexHull",value:function(t){if(this.contours[t])return p5.cv.getConvexHullMat(this.contours[t])}},{key:"getConvexityDefects",value:function(t){return p5.cv.convexityDefectsCv(this.contours[t])}},{key:"getMinAreaRect",value:function(t){return cv.minAreaRect(this.contours[t])}},{key:"getMinEnclosingCircle",value:function(t){return cv.minEnclosingCircle(this.contours[t])}},{key:"getFitEllipse",value:function(t){return this.contours[t].total()<5?this.getMinAreaRect(t):cv.fitEllipse(this.contours[t])}},{key:"getFitQuad",value:function(t){var e=this.getConvexHull(t);if(e){var n=e.clone(),r=Number.POSITIVE_INFINITY,i=0,o=r,c=16;if(4<n.total())for(var a=0;a<16&&(cv.approxPolyDP(e,n,c,!0),4!==n.total());a++)4<n.total()&&(i=c,o===r?c*=2:c=(o+i)/2),n.total()<4&&(c=((o=c)+i)/2);return n}}},{key:"getHole",value:function(t){return this.holes[t]}},{key:"getVelocity",value:function(t){return this.tracker.getVelocity(t)}},{key:"getLabel",value:function(t){return this.tracker.getCurrentLabels()[t]}},{key:"getTracker",value:function(){return this.tracker}},{key:"setAutoThreshold",value:function(t){this.autoThreshold=t}},{key:"setThreshold",value:function(t){this.thresholdValue=t}},{key:"setThresholdMax",value:function(t){this.thresholdValueMax=t}},{key:"setInvert",value:function(t){this.invert=t}},{key:"setUseTargetColor",value:function(t){this.useTargetColor=t}},{key:"setTargetColor",value:function(t,e){this.useTargetColor=!0,this.targetColor=t,this.trackingColorMode=e}},{key:"setSimplify",value:function(t){this.simplify=t}},{key:"draw",value:function(){push(),noFill();for(var t=this.polylines.length,e=0;e<t;e++){p5.cv.drawVectors(this.polylines[e]);var n=this.getBoundingRect(e);rect(n.x,n.y,n.width,n.height)}pop()}},{key:"resetMinArea",value:function(){this.setMinArea(0)}},{key:"resetMaxArea",value:function(){this.setMaxArea(Number.POSITIVE_INFINITY)}},{key:"setMinArea",value:function(t){this.minArea=t,this.maxAreaNorm=!1}},{key:"setMaxArea",value:function(t){this.maxArea=t,this.minAreaNorm=!1}},{key:"setMinAreaRadius",value:function(t){this.minArea=PI*t*t,this.minAreaNorm=!1}},{key:"setMaxAreaRadius",value:function(t){this.maxArea=PI*t*t,this.maxAreaNorm=!1}},{key:"setMinAreaNorm",value:function(t){this.minArea=t,this.minAreaNorm=!0}},{key:"setMaxAreaNorm",value:function(t){this.maxArea=t,this.maxAreaNorm=!0}}])&&j(e.prototype,n),r&&j(e,r),t}();window.Tracker=d,window.TrackedObject=L,window.RectTracker=v,window.PointTracker=y,window.Follower=C,window.RectFollower=w,window.PointFollower=R,window.TrackerFollower=m,window.RectTrackerFollower=_,window.PointTrackerFollower=O,window.RunningBackground=T,window.ObjectFinder=A,window.Flow=H,window.FlowPyrLK=z,window.FlowFarneback=e,window.OFlow=n,window.Graph=D,window.ContourFinder=k}]);
//# sourceMappingURL=p5.cv.min.js.map