speedy-vision
Version:
GPU-accelerated Computer Vision for JavaScript
1,279 lines (1,090 loc) • 975 kB
JavaScript
/*!
* Speedy Vision version 0.9.0-wip
* GPU-accelerated Computer Vision for JavaScript
* Copyright 2020-2022 Alexandre Martins <alemartf(at)gmail.com> (https://github.com/alemart)
* https://github.com/alemart/speedy-vision
*
* @license Apache-2.0
* Date: 2022-04-19T18:11:01.441Z
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["Speedy"] = factory();
else
root["Speedy"] = factory();
})(self, function() {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./src/core/pipeline/factories/filter-factory.js":
/*!*******************************************************!*\
!*** ./src/core/pipeline/factories/filter-factory.js ***!
\*******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SpeedyPipelineFilterFactory": () => (/* binding */ SpeedyPipelineFilterFactory)
/* harmony export */ });
/* harmony import */ var _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../speedy-namespace */ "./src/core/speedy-namespace.js");
/* harmony import */ var _nodes_filters_greyscale__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodes/filters/greyscale */ "./src/core/pipeline/nodes/filters/greyscale.js");
/* harmony import */ var _nodes_filters_gaussian_blur__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodes/filters/gaussian-blur */ "./src/core/pipeline/nodes/filters/gaussian-blur.js");
/* harmony import */ var _nodes_filters_simple_blur__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../nodes/filters/simple-blur */ "./src/core/pipeline/nodes/filters/simple-blur.js");
/* harmony import */ var _nodes_filters_median_blur__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../nodes/filters/median-blur */ "./src/core/pipeline/nodes/filters/median-blur.js");
/* harmony import */ var _nodes_filters_convolution__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../nodes/filters/convolution */ "./src/core/pipeline/nodes/filters/convolution.js");
/* harmony import */ var _nodes_filters_nightvision__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../nodes/filters/nightvision */ "./src/core/pipeline/nodes/filters/nightvision.js");
/* harmony import */ var _nodes_filters_normalize__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../nodes/filters/normalize */ "./src/core/pipeline/nodes/filters/normalize.js");
/*
* speedy-vision.js
* GPU-accelerated Computer Vision for JavaScript
* Copyright 2020-2022 Alexandre Martins <alemartf(at)gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* filter-factory.js
* Image filters
*/
/**
* Image filters
*/
class SpeedyPipelineFilterFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* Convert image to greyscale
* @param {string} [name]
* @returns {SpeedyPipelineNodeGreyscale}
*/
static Greyscale(name = undefined)
{
return new _nodes_filters_greyscale__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineNodeGreyscale(name);
}
/**
* Gaussian Blur
* @param {string} [name]
* @returns {SpeedyPipelineNodeGaussianBlur}
*/
static GaussianBlur(name = undefined)
{
return new _nodes_filters_gaussian_blur__WEBPACK_IMPORTED_MODULE_2__.SpeedyPipelineNodeGaussianBlur(name);
}
/**
* Simple Blur (Box Filter)
* @param {string} [name]
* @returns {SpeedyPipelineNodeSimpleBlur}
*/
static SimpleBlur(name = undefined)
{
return new _nodes_filters_simple_blur__WEBPACK_IMPORTED_MODULE_3__.SpeedyPipelineNodeSimpleBlur(name);
}
/**
* Median Blur
* @param {string} [name]
* @returns {SpeedyPipelineNodeMedianBlur}
*/
static MedianBlur(name = undefined)
{
return new _nodes_filters_median_blur__WEBPACK_IMPORTED_MODULE_4__.SpeedyPipelineNodeMedianBlur(name);
}
/**
* Image Convolution
* @param {string} [name]
* @returns {SpeedyPipelineNodeConvolution}
*/
static Convolution(name = undefined)
{
return new _nodes_filters_convolution__WEBPACK_IMPORTED_MODULE_5__.SpeedyPipelineNodeConvolution(name);
}
/**
* Nightvision
* @param {string} [name]
* @returns {SpeedyPipelineNodeNightvision}
*/
static Nightvision(name = undefined)
{
return new _nodes_filters_nightvision__WEBPACK_IMPORTED_MODULE_6__.SpeedyPipelineNodeNightvision(name);
}
/**
* Normalize image
* @param {string} [name]
* @returns {SpeedyPipelineNodeNormalize}
*/
static Normalize(name = undefined)
{
return new _nodes_filters_normalize__WEBPACK_IMPORTED_MODULE_7__.SpeedyPipelineNodeNormalize(name);
}
}
/***/ }),
/***/ "./src/core/pipeline/factories/image-factory.js":
/*!******************************************************!*\
!*** ./src/core/pipeline/factories/image-factory.js ***!
\******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SpeedyPipelineImagePortalFactory": () => (/* binding */ SpeedyPipelineImagePortalFactory),
/* harmony export */ "SpeedyPipelineImageFactory": () => (/* binding */ SpeedyPipelineImageFactory)
/* harmony export */ });
/* harmony import */ var _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../speedy-namespace */ "./src/core/speedy-namespace.js");
/* harmony import */ var _nodes_images_source__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodes/images/source */ "./src/core/pipeline/nodes/images/source.js");
/* harmony import */ var _nodes_images_sink__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodes/images/sink */ "./src/core/pipeline/nodes/images/sink.js");
/* harmony import */ var _nodes_images_multiplexer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../nodes/images/multiplexer */ "./src/core/pipeline/nodes/images/multiplexer.js");
/* harmony import */ var _nodes_images_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../nodes/images/buffer */ "./src/core/pipeline/nodes/images/buffer.js");
/* harmony import */ var _nodes_images_pyramid__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../nodes/images/pyramid */ "./src/core/pipeline/nodes/images/pyramid.js");
/* harmony import */ var _nodes_images_mixer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../nodes/images/mixer */ "./src/core/pipeline/nodes/images/mixer.js");
/* harmony import */ var _nodes_images_portal__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../nodes/images/portal */ "./src/core/pipeline/nodes/images/portal.js");
/*
* speedy-vision.js
* GPU-accelerated Computer Vision for JavaScript
* Copyright 2020-2022 Alexandre Martins <alemartf(at)gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* image-factory.js
* Image-related nodes
*/
/**
* Portal nodes
*/
class SpeedyPipelineImagePortalFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* Create an image portal source
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeImagePortalSource}
*/
static Source(name = undefined)
{
return new _nodes_images_portal__WEBPACK_IMPORTED_MODULE_7__.SpeedyPipelineNodeImagePortalSource(name);
}
/**
* Create an image portal sink
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeImagePortalSink}
*/
static Sink(name = undefined)
{
return new _nodes_images_portal__WEBPACK_IMPORTED_MODULE_7__.SpeedyPipelineNodeImagePortalSink(name);
}
}
/**
* Image nodes
*/
class SpeedyPipelineImageFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* Create an image source
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeImageSource}
*/
static Source(name = undefined)
{
return new _nodes_images_source__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineNodeImageSource(name);
}
/**
* Create an image sink
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeImageSink}
*/
static Sink(name = undefined)
{
return new _nodes_images_sink__WEBPACK_IMPORTED_MODULE_2__.SpeedyPipelineNodeImageSink(name);
}
/**
* Create an image multiplexer
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeImageMultiplexer}
*/
static Multiplexer(name = undefined)
{
return new _nodes_images_multiplexer__WEBPACK_IMPORTED_MODULE_3__.SpeedyPipelineNodeImageMultiplexer(name);
}
/**
* Create an image buffer
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeImageBuffer}
*/
static Buffer(name = undefined)
{
return new _nodes_images_buffer__WEBPACK_IMPORTED_MODULE_4__.SpeedyPipelineNodeImageBuffer(name);
}
/**
* Image Pyramid
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeImagePyramid}
*/
static Pyramid(name = undefined)
{
return new _nodes_images_pyramid__WEBPACK_IMPORTED_MODULE_5__.SpeedyPipelineNodeImagePyramid(name);
}
/**
* Image Mixer (blending)
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeImageMixer}
*/
static Mixer(name = undefined)
{
return new _nodes_images_mixer__WEBPACK_IMPORTED_MODULE_6__.SpeedyPipelineNodeImageMixer(name);
}
/**
* Image Portals
* @returns {typeof SpeedyPipelineImagePortalFactory}
*/
static get Portal()
{
return SpeedyPipelineImagePortalFactory;
}
}
/***/ }),
/***/ "./src/core/pipeline/factories/keypoint-factory.js":
/*!*********************************************************!*\
!*** ./src/core/pipeline/factories/keypoint-factory.js ***!
\*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SpeedyPipelineKeypointPortalFactory": () => (/* binding */ SpeedyPipelineKeypointPortalFactory),
/* harmony export */ "SpeedyPipelineKeypointFactory": () => (/* binding */ SpeedyPipelineKeypointFactory)
/* harmony export */ });
/* harmony import */ var _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../speedy-namespace */ "./src/core/speedy-namespace.js");
/* harmony import */ var _nodes_keypoints_source__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodes/keypoints/source */ "./src/core/pipeline/nodes/keypoints/source.js");
/* harmony import */ var _nodes_keypoints_sink__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodes/keypoints/sink */ "./src/core/pipeline/nodes/keypoints/sink.js");
/* harmony import */ var _nodes_keypoints_clipper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../nodes/keypoints/clipper */ "./src/core/pipeline/nodes/keypoints/clipper.js");
/* harmony import */ var _nodes_keypoints_border_clipper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../nodes/keypoints/border-clipper */ "./src/core/pipeline/nodes/keypoints/border-clipper.js");
/* harmony import */ var _nodes_keypoints_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../nodes/keypoints/buffer */ "./src/core/pipeline/nodes/keypoints/buffer.js");
/* harmony import */ var _nodes_keypoints_mixer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../nodes/keypoints/mixer */ "./src/core/pipeline/nodes/keypoints/mixer.js");
/* harmony import */ var _nodes_keypoints_shuffler__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../nodes/keypoints/shuffler */ "./src/core/pipeline/nodes/keypoints/shuffler.js");
/* harmony import */ var _nodes_keypoints_multiplexer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../nodes/keypoints/multiplexer */ "./src/core/pipeline/nodes/keypoints/multiplexer.js");
/* harmony import */ var _nodes_keypoints_transformer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../nodes/keypoints/transformer */ "./src/core/pipeline/nodes/keypoints/transformer.js");
/* harmony import */ var _nodes_keypoints_subpixel__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../nodes/keypoints/subpixel */ "./src/core/pipeline/nodes/keypoints/subpixel.js");
/* harmony import */ var _nodes_keypoints_detectors_fast__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../nodes/keypoints/detectors/fast */ "./src/core/pipeline/nodes/keypoints/detectors/fast.js");
/* harmony import */ var _nodes_keypoints_detectors_harris__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../nodes/keypoints/detectors/harris */ "./src/core/pipeline/nodes/keypoints/detectors/harris.js");
/* harmony import */ var _nodes_keypoints_descriptors_orb__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../nodes/keypoints/descriptors/orb */ "./src/core/pipeline/nodes/keypoints/descriptors/orb.js");
/* harmony import */ var _nodes_keypoints_trackers_lk__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../nodes/keypoints/trackers/lk */ "./src/core/pipeline/nodes/keypoints/trackers/lk.js");
/* harmony import */ var _nodes_keypoints_matchers_lsh_static_tables__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../nodes/keypoints/matchers/lsh-static-tables */ "./src/core/pipeline/nodes/keypoints/matchers/lsh-static-tables.js");
/* harmony import */ var _nodes_keypoints_matchers_lsh_knn__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../nodes/keypoints/matchers/lsh-knn */ "./src/core/pipeline/nodes/keypoints/matchers/lsh-knn.js");
/* harmony import */ var _nodes_keypoints_matchers_bf_knn__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../nodes/keypoints/matchers/bf-knn */ "./src/core/pipeline/nodes/keypoints/matchers/bf-knn.js");
/* harmony import */ var _nodes_keypoints_distance_filter__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../nodes/keypoints/distance-filter */ "./src/core/pipeline/nodes/keypoints/distance-filter.js");
/* harmony import */ var _nodes_keypoints_hamming_distance_filter__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../nodes/keypoints/hamming-distance-filter */ "./src/core/pipeline/nodes/keypoints/hamming-distance-filter.js");
/* harmony import */ var _nodes_keypoints_portal__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../nodes/keypoints/portal */ "./src/core/pipeline/nodes/keypoints/portal.js");
/*
* speedy-vision.js
* GPU-accelerated Computer Vision for JavaScript
* Copyright 2020-2022 Alexandre Martins <alemartf(at)gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* keypoint-factory.js
* Keypoint-related nodes
*/
/**
* Keypoint detectors
*/
class SpeedyPipelineKeypointDetectorFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* FAST corner detector
* @param {string} [name]
* @returns {SpeedyPipelineNodeFASTKeypointDetector}
*/
static FAST(name = undefined)
{
return new _nodes_keypoints_detectors_fast__WEBPACK_IMPORTED_MODULE_11__.SpeedyPipelineNodeFASTKeypointDetector(name);
}
/**
* Harris corner detector
* @param {string} [name]
* @returns {SpeedyPipelineNodeHarrisKeypointDetector}
*/
static Harris(name = undefined)
{
return new _nodes_keypoints_detectors_harris__WEBPACK_IMPORTED_MODULE_12__.SpeedyPipelineNodeHarrisKeypointDetector(name);
}
}
/**
* Keypoint descriptors
*/
class SpeedyPipelineKeypointDescriptorFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* ORB descriptors
* @param {string} [name]
* @returns {SpeedyPipelineNodeORBKeypointDescriptor}
*/
static ORB(name = undefined)
{
return new _nodes_keypoints_descriptors_orb__WEBPACK_IMPORTED_MODULE_13__.SpeedyPipelineNodeORBKeypointDescriptor(name);
}
}
/**
* Keypoint trackers
*/
class SpeedyPipelineKeypointTrackerFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* LK optical-flow
* @param {string} [name]
* @returns {SpeedyPipelineNodeLKKeypointTracker}
*/
static LK(name = undefined)
{
return new _nodes_keypoints_trackers_lk__WEBPACK_IMPORTED_MODULE_14__.SpeedyPipelineNodeLKKeypointTracker(name);
}
}
/**
* Keypoint matchers
*/
class SpeedyPipelineKeypointMatcherFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* Static LSH tables
* @param {string} [name]
* @returns {SpeedyPipelineNodeStaticLSHTables}
*/
static StaticLSHTables(name = undefined)
{
return new _nodes_keypoints_matchers_lsh_static_tables__WEBPACK_IMPORTED_MODULE_15__.SpeedyPipelineNodeStaticLSHTables(name);
}
/**
* LSH-based K-approximate nearest neighbors
* @param {string} [name]
* @returns {SpeedyPipelineNodeLSHKNNMatcher}
*/
static LSHKNN(name = undefined)
{
return new _nodes_keypoints_matchers_lsh_knn__WEBPACK_IMPORTED_MODULE_16__.SpeedyPipelineNodeLSHKNNMatcher(name);
}
/**
* Brute-force K-nearest neighbors keypoint matcher
* @param {string} [name]
* @returns {SpeedyPipelineNodeBruteForceKNNKeypointMatcher}
*/
static BFKNN(name = undefined)
{
return new _nodes_keypoints_matchers_bf_knn__WEBPACK_IMPORTED_MODULE_17__.SpeedyPipelineNodeBruteForceKNNKeypointMatcher(name);
}
}
/**
* Portal nodes
*/
class SpeedyPipelineKeypointPortalFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* Create an image portal source
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeKeypointPortalSource}
*/
static Source(name = undefined)
{
return new _nodes_keypoints_portal__WEBPACK_IMPORTED_MODULE_20__.SpeedyPipelineNodeKeypointPortalSource(name);
}
/**
* Create an image portal sink
* @param {string} [name] name of the node
* @returns {SpeedyPipelineNodeKeypointPortalSink}
*/
static Sink(name = undefined)
{
return new _nodes_keypoints_portal__WEBPACK_IMPORTED_MODULE_20__.SpeedyPipelineNodeKeypointPortalSink(name);
}
}
/**
* Keypoint-related nodes
*/
class SpeedyPipelineKeypointFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* Keypoint detectors
* @returns {typeof SpeedyPipelineKeypointDetectorFactory}
*/
static get Detector()
{
return SpeedyPipelineKeypointDetectorFactory;
}
/**
* Keypoint descriptors
* @returns {typeof SpeedyPipelineKeypointDescriptorFactory}
*/
static get Descriptor()
{
return SpeedyPipelineKeypointDescriptorFactory;
}
/**
* Keypoint trackers
* @returns {typeof SpeedyPipelineKeypointTrackerFactory}
*/
static get Tracker()
{
return SpeedyPipelineKeypointTrackerFactory;
}
/**
* Keypoint matchers
* @returns {typeof SpeedyPipelineKeypointMatcherFactory}
*/
static get Matcher()
{
return SpeedyPipelineKeypointMatcherFactory;
}
/**
* Keypoint Portals
* @returns {typeof SpeedyPipelineKeypointPortalFactory}
*/
static get Portal()
{
return SpeedyPipelineKeypointPortalFactory;
}
/**
* Create a keypoint source
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointSource}
*/
static Source(name = undefined)
{
return new _nodes_keypoints_source__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineNodeKeypointSource(name);
}
/**
* Create a keypoint sink
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointSink}
*/
static Sink(name = undefined)
{
return new _nodes_keypoints_sink__WEBPACK_IMPORTED_MODULE_2__.SpeedyPipelineNodeKeypointSink(name);
}
/**
* Create a sink of tracked keypoints
* @param {string} [name]
* @returns {SpeedyPipelineNodeTrackedKeypointSink}
*/
static SinkOfTrackedKeypoints(name = undefined)
{
return new _nodes_keypoints_sink__WEBPACK_IMPORTED_MODULE_2__.SpeedyPipelineNodeTrackedKeypointSink(name);
}
/**
* Create a sink of matched keypoints
* @param {string} [name]
* @returns {SpeedyPipelineNodeMatchedKeypointSink}
*/
static SinkOfMatchedKeypoints(name = undefined)
{
return new _nodes_keypoints_sink__WEBPACK_IMPORTED_MODULE_2__.SpeedyPipelineNodeMatchedKeypointSink(name);
}
/**
* Keypoint clipper
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointClipper}
*/
static Clipper(name = undefined)
{
return new _nodes_keypoints_clipper__WEBPACK_IMPORTED_MODULE_3__.SpeedyPipelineNodeKeypointClipper(name);
}
/**
* Border Clipper
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointBorderClipper}
*/
static BorderClipper(name = undefined)
{
return new _nodes_keypoints_border_clipper__WEBPACK_IMPORTED_MODULE_4__.SpeedyPipelineNodeKeypointBorderClipper(name);
}
/**
* Create a keypoint buffer
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointBuffer}
*/
static Buffer(name = undefined)
{
return new _nodes_keypoints_buffer__WEBPACK_IMPORTED_MODULE_5__.SpeedyPipelineNodeKeypointBuffer(name);
}
/**
* Create a keypoint mixer
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointMixer}
*/
static Mixer(name = undefined)
{
return new _nodes_keypoints_mixer__WEBPACK_IMPORTED_MODULE_6__.SpeedyPipelineNodeKeypointMixer(name);
}
/**
* Create a keypoint shuffler
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointShuffler}
*/
static Shuffler(name = undefined)
{
return new _nodes_keypoints_shuffler__WEBPACK_IMPORTED_MODULE_7__.SpeedyPipelineNodeKeypointShuffler(name);
}
/**
* Create a keypoint multiplexer
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointMultiplexer}
*/
static Multiplexer(name = undefined)
{
return new _nodes_keypoints_multiplexer__WEBPACK_IMPORTED_MODULE_8__.SpeedyPipelineNodeKeypointMultiplexer(name);
}
/**
* Create a keypoint transformer
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointTransformer}
*/
static Transformer(name = undefined)
{
return new _nodes_keypoints_transformer__WEBPACK_IMPORTED_MODULE_9__.SpeedyPipelineNodeKeypointTransformer(name);
}
/**
* Create a subpixel refiner of keypoint locations
* @param {string} [name]
* @returns {SpeedyPipelineNodeKeypointSubpixelRefiner}
*/
static SubpixelRefiner(name = undefined)
{
return new _nodes_keypoints_subpixel__WEBPACK_IMPORTED_MODULE_10__.SpeedyPipelineNodeKeypointSubpixelRefiner(name);
}
/**
* Distance filter
* @param {string} [name]
* @returns {SpeedyPipelineNodeDistanceFilter}
*/
static DistanceFilter(name = undefined)
{
return new _nodes_keypoints_distance_filter__WEBPACK_IMPORTED_MODULE_18__.SpeedyPipelineNodeKeypointDistanceFilter(name);
}
/**
* Hamming distance filter
* @param {string} [name]
* @returns {SpeedyPipelineNodeHammingDistanceFilter}
*/
static HammingDistanceFilter(name = undefined)
{
return new _nodes_keypoints_hamming_distance_filter__WEBPACK_IMPORTED_MODULE_19__.SpeedyPipelineNodeKeypointHammingDistanceFilter(name);
}
}
/***/ }),
/***/ "./src/core/pipeline/factories/transform-factory.js":
/*!**********************************************************!*\
!*** ./src/core/pipeline/factories/transform-factory.js ***!
\**********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SpeedyPipelineTransformFactory": () => (/* binding */ SpeedyPipelineTransformFactory)
/* harmony export */ });
/* harmony import */ var _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../speedy-namespace */ "./src/core/speedy-namespace.js");
/* harmony import */ var _nodes_transforms_perspective_warp__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodes/transforms/perspective-warp */ "./src/core/pipeline/nodes/transforms/perspective-warp.js");
/* harmony import */ var _nodes_transforms_resize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../nodes/transforms/resize */ "./src/core/pipeline/nodes/transforms/resize.js");
/*
* speedy-vision.js
* GPU-accelerated Computer Vision for JavaScript
* Copyright 2020-2022 Alexandre Martins <alemartf(at)gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* transform-factory.js
* Image transforms
*/
/**
* Image transforms
*/
class SpeedyPipelineTransformFactory extends _speedy_namespace__WEBPACK_IMPORTED_MODULE_0__.SpeedyNamespace
{
/**
* Resize image
* @param {string} [name]
* @returns {SpeedyPipelineNodeResize}
*/
static Resize(name = undefined)
{
return new _nodes_transforms_resize__WEBPACK_IMPORTED_MODULE_2__.SpeedyPipelineNodeResize(name);
}
/**
* Warp an image using a perspective transformation
* @param {string} [name]
* @returns {SpeedyPipelineNodePerspectiveWarp}
*/
static PerspectiveWarp(name = undefined)
{
return new _nodes_transforms_perspective_warp__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineNodePerspectiveWarp(name);
}
}
/***/ }),
/***/ "./src/core/pipeline/factories/vector2-factory.js":
/*!********************************************************!*\
!*** ./src/core/pipeline/factories/vector2-factory.js ***!
\********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SpeedyPipelineVector2Factory": () => (/* binding */ SpeedyPipelineVector2Factory)
/* harmony export */ });
/* harmony import */ var _speedy_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../speedy-vector */ "./src/core/speedy-vector.js");
/* harmony import */ var _nodes_vector2_sink__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../nodes/vector2/sink */ "./src/core/pipeline/nodes/vector2/sink.js");
/*
* speedy-vision.js
* GPU-accelerated Computer Vision for JavaScript
* Copyright 2020-2022 Alexandre Martins <alemartf(at)gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* vector2-factory.js
* 2D vectors
*/
/**
* 2D vectors
*/
class SpeedyPipelineVector2Factory extends Function
{
/**
* Constructor
*/
constructor()
{
// This factory can be invoked as a function
super('...args', 'return this._create(...args)');
return this.bind(this);
}
/**
* @private
*
* Create a 2D vector
* @param {number} x x-coordinate
* @param {number} y y-coordinate
* @returns {SpeedyVector2}
*/
_create(x, y)
{
return new _speedy_vector__WEBPACK_IMPORTED_MODULE_0__.SpeedyVector2(x, y);
}
/**
* Create a Vector2 sink
* @param {string} [name]
* @returns {SpeedyPipelineNodeVector2Sink}
*/
Sink(name = undefined)
{
return new _nodes_vector2_sink__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineNodeVector2Sink(name);
}
}
/***/ }),
/***/ "./src/core/pipeline/nodes/filters/convolution.js":
/*!********************************************************!*\
!*** ./src/core/pipeline/nodes/filters/convolution.js ***!
\********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SpeedyPipelineNodeConvolution": () => (/* binding */ SpeedyPipelineNodeConvolution)
/* harmony export */ });
/* harmony import */ var _pipeline_node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../pipeline-node */ "./src/core/pipeline/pipeline-node.js");
/* harmony import */ var _pipeline_message__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../pipeline-message */ "./src/core/pipeline/pipeline-message.js");
/* harmony import */ var _pipeline_portbuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../pipeline-portbuilder */ "./src/core/pipeline/pipeline-portbuilder.js");
/* harmony import */ var _gpu_speedy_gpu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../../gpu/speedy-gpu */ "./src/gpu/speedy-gpu.js");
/* harmony import */ var _gpu_speedy_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../gpu/speedy-texture */ "./src/gpu/speedy-texture.js");
/* harmony import */ var _speedy_size__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../speedy-size */ "./src/core/speedy-size.js");
/* harmony import */ var _utils_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../../utils/utils */ "./src/utils/utils.js");
/* harmony import */ var _utils_types__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../../utils/types */ "./src/utils/types.js");
/* harmony import */ var _utils_errors__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../../utils/errors */ "./src/utils/errors.js");
/* harmony import */ var _speedy_promise__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../speedy-promise */ "./src/core/speedy-promise.js");
/* harmony import */ var _speedy_matrix__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../speedy-matrix */ "./src/core/speedy-matrix.js");
/*
* speedy-vision.js
* GPU-accelerated Computer Vision for JavaScript
* Copyright 2020-2022 Alexandre Martins <alemartf(at)gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* convolution.js
* Image convolution
*/
// 2D convolution programs
const CONVOLUTION = {
3: 'convolution3',
5: 'convolution5',
7: 'convolution7',
};
/**
* Image convolution
*/
class SpeedyPipelineNodeConvolution extends _pipeline_node__WEBPACK_IMPORTED_MODULE_0__.SpeedyPipelineNode
{
/**
* Constructor
* @param {string} [name] name of the node
*/
constructor(name = undefined)
{
super(name, 1, [
(0,_pipeline_portbuilder__WEBPACK_IMPORTED_MODULE_2__.InputPort)().expects(_pipeline_message__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineMessageType.Image),
(0,_pipeline_portbuilder__WEBPACK_IMPORTED_MODULE_2__.OutputPort)().expects(_pipeline_message__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineMessageType.Image),
]);
/** @type {SpeedyMatrix} convolution kernel (square matrix) */
this._kernel = _speedy_matrix__WEBPACK_IMPORTED_MODULE_10__.SpeedyMatrix.Create(3, 3, [0, 0, 0, 0, 1, 0, 0, 0, 0]); // identity transform
}
/**
* Convolution kernel
* @returns {SpeedyMatrix}
*/
get kernel()
{
return this._kernel;
}
/**
* Convolution kernel
* @param {SpeedyMatrix} kernel
*/
set kernel(kernel)
{
if(kernel.rows != kernel.columns)
throw new _utils_errors__WEBPACK_IMPORTED_MODULE_8__.NotSupportedError(`Use a square kernel`);
else if(!(kernel.rows == 3 || kernel.rows == 5 || kernel.rows == 7))
throw new _utils_errors__WEBPACK_IMPORTED_MODULE_8__.NotSupportedError(`Invalid kernel size. Supported sizes: 3x3, 5x5, 7x7`);
this._kernel = kernel;
}
/**
* Run the specific task of this node
* @param {SpeedyGPU} gpu
* @returns {void|SpeedyPromise<void>}
*/
_run(gpu)
{
const { image, format } = /** @type {SpeedyPipelineMessageWithImage} */ ( this.input().read() );
const width = image.width, height = image.height;
const outputTexture = this._tex[0];
const ksize = this._kernel.rows;
const conv = CONVOLUTION[ksize];
const kernel = this._kernel.read();
(gpu.programs.filters[conv]
.outputs(width, height, outputTexture)
)(image, kernel);
this.output().swrite(outputTexture, format);
}
}
/***/ }),
/***/ "./src/core/pipeline/nodes/filters/gaussian-blur.js":
/*!**********************************************************!*\
!*** ./src/core/pipeline/nodes/filters/gaussian-blur.js ***!
\**********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SpeedyPipelineNodeGaussianBlur": () => (/* binding */ SpeedyPipelineNodeGaussianBlur)
/* harmony export */ });
/* harmony import */ var _pipeline_node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../pipeline-node */ "./src/core/pipeline/pipeline-node.js");
/* harmony import */ var _pipeline_message__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../pipeline-message */ "./src/core/pipeline/pipeline-message.js");
/* harmony import */ var _pipeline_portbuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../pipeline-portbuilder */ "./src/core/pipeline/pipeline-portbuilder.js");
/* harmony import */ var _gpu_speedy_gpu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../../gpu/speedy-gpu */ "./src/gpu/speedy-gpu.js");
/* harmony import */ var _speedy_size__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../speedy-size */ "./src/core/speedy-size.js");
/* harmony import */ var _speedy_vector__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../speedy-vector */ "./src/core/speedy-vector.js");
/* harmony import */ var _utils_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../../utils/utils */ "./src/utils/utils.js");
/* harmony import */ var _utils_errors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../../utils/errors */ "./src/utils/errors.js");
/* harmony import */ var _speedy_promise__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../speedy-promise */ "./src/core/speedy-promise.js");
/*
* speedy-vision.js
* GPU-accelerated Computer Vision for JavaScript
* Copyright 2020-2022 Alexandre Martins <alemartf(at)gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* gaussian-blur.js
* Gaussian Blur
*/
/**
* Default kernels for different sizes: 3x3, 5x5, 7x7... (use sigma_x = sigma_y)
* Heuristics: in order to pick a sigma, we set radius = 2 * sigma. Since
* ksize = 1 + 2 * radius, it follows that sigma = (ksize - 1) / 4. When
* ksize is 3, we set sigma = 1. Therefore, sigma = max(1, (ksize - 1) / 4).
*/
const DEFAULT_KERNEL = Object.freeze({
3: [ 0.27901008925473514, 0.44197982149052983, 0.27901008925473514 ], // 1D convolution (sigma = 1)
5: [ 0.06135959781344021, 0.2447701955296099, 0.3877404133138998, 0.2447701955296099, 0.06135959781344021 ], // 1D convolution (separable kernel)
7: [ 0.03873542500847274, 0.11308485700794121, 0.2150068609928349, 0.26634571398150225, 0.2150068609928349, 0.11308485700794121, 0.03873542500847274 ],
9: [ 0.028532262603370988, 0.067234535494912, 0.12400932997922749, 0.17904386461741617, 0.20236001461014655, 0.17904386461741617, 0.12400932997922749, 0.067234535494912, 0.028532262603370988 ],
11:[ 0.022656882730580346, 0.04610857898527292, 0.08012661469398517, 0.11890414969751599, 0.15067709325491124, 0.16305336127546846, 0.15067709325491124, 0.11890414969751599, 0.08012661469398517, 0.04610857898527292, 0.022656882730580346 ],
13:[ 0.018815730430644363, 0.03447396964662016, 0.05657737457255748, 0.08317258170844948, 0.10952340502389682, 0.12918787500405662, 0.13649812722755, 0.12918787500405662, 0.10952340502389682, 0.08317258170844948, 0.05657737457255748, 0.03447396964662016, 0.018815730430644363 ],
15:[ 0.016100340991695383, 0.027272329212157102, 0.042598338587449644, 0.06135478775568558, 0.08148767614129326, 0.09979838342934616, 0.11270444144735056, 0.11736740487004466, 0.11270444144735056, 0.09979838342934616, 0.08148767614129326, 0.06135478775568558, 0.042598338587449644, 0.027272329212157102, 0.016100340991695383 ],
//3: [ 0.25, 0.5, 0.25 ],
//5: [ 0.05, 0.25, 0.4, 0.25, 0.05 ],
});
/** Zero vector. When we set sigma_x = sigma_y = 0, we use the default rule to compute the actual sigma */
const DEFAULT_SIGMA = new _speedy_vector__WEBPACK_IMPORTED_MODULE_5__.SpeedyVector2(0,0);
/** convolution programs (x-axis) */
const CONVOLUTION_X = Object.freeze({
3: 'convolution3x',
5: 'convolution5x',
7: 'convolution7x',
9: 'convolution9x',
11: 'convolution11x',
13: 'convolution13x',
15: 'convolution15x',
});
/** convolution programs (y-axis) */
const CONVOLUTION_Y = Object.freeze({
3: 'convolution3y',
5: 'convolution5y',
7: 'convolution7y',
9: 'convolution9y',
11: 'convolution11y',
13: 'convolution13y',
15: 'convolution15y',
});
/**
* @typedef {object} SeparableConvolutionKernel
* @property {number[]} x
* @property {number[]} y
*/
/**
* Gaussian Blur
*/
class SpeedyPipelineNodeGaussianBlur extends _pipeline_node__WEBPACK_IMPORTED_MODULE_0__.SpeedyPipelineNode
{
/**
* Constructor
* @param {string} [name] name of the node
*/
constructor(name = undefined)
{
super(name, 2, [
(0,_pipeline_portbuilder__WEBPACK_IMPORTED_MODULE_2__.InputPort)().expects(_pipeline_message__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineMessageType.Image),
(0,_pipeline_portbuilder__WEBPACK_IMPORTED_MODULE_2__.OutputPort)().expects(_pipeline_message__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineMessageType.Image),
]);
/** @type {SpeedySize} size of the kernel */
this._kernelSize = new _speedy_size__WEBPACK_IMPORTED_MODULE_4__.SpeedySize(5,5);
/** @type {SpeedyVector2} sigma of the Gaussian kernel (0 means: use default settings) */
this._sigma = DEFAULT_SIGMA;
/** @type {SeparableConvolutionKernel} convolution kernel */
this._kernel = {
x: DEFAULT_KERNEL[this._kernelSize.width],
y: DEFAULT_KERNEL[this._kernelSize.height]
};
}
/**
* Size of the kernel
* @returns {SpeedySize}
*/
get kernelSize()
{
return this._kernelSize;
}
/**
* Size of the kernel
* @param {SpeedySize} kernelSize
*/
set kernelSize(kernelSize)
{
_utils_utils__WEBPACK_IMPORTED_MODULE_6__.Utils.assert(kernelSize instanceof _speedy_size__WEBPACK_IMPORTED_MODULE_4__.SpeedySize);
const kw = kernelSize.width, kh = kernelSize.height;
if(kw < 3 || kh < 3 || kw > 15 || kh > 15 || kw % 2 == 0 || kh % 2 == 0)
throw new _utils_errors__WEBPACK_IMPORTED_MODULE_7__.NotSupportedError(`Unsupported kernel size: ${kw}x${kh}`);
this._kernelSize = kernelSize;
this._updateKernel();
}
/**
* Sigma of the Gaussian kernel
* @returns {SpeedyVector2}
*/
get sigma()
{
return this._sigma;
}
/**
* Sigma of the Gaussian kernel
* @param {SpeedyVector2} sigma
*/
set sigma(sigma)
{
_utils_utils__WEBPACK_IMPORTED_MODULE_6__.Utils.assert(sigma instanceof _speedy_vector__WEBPACK_IMPORTED_MODULE_5__.SpeedyVector2, `Sigma must be a SpeedyVector2`);
_utils_utils__WEBPACK_IMPORTED_MODULE_6__.Utils.assert(sigma.x >= 0 && sigma.y >= 0);
this._sigma = sigma;
this._updateKernel();
}
/**
* Run the specific task of this node
* @param {SpeedyGPU} gpu
* @returns {void|SpeedyPromise<void>}
*/
_run(gpu)
{
const { image, format } = /** @type {SpeedyPipelineMessageWithImage} */ ( this.input().read() );
const width = image.width, height = image.height;
const kernX = this._kernel.x;
const kernY = this._kernel.y;
const convX = CONVOLUTION_X[this._kernelSize.width];
const convY = CONVOLUTION_Y[this._kernelSize.height];
const tex = this._tex[0];
const outputTexture = this._tex[1];
(gpu.programs.filters[convX]
.outputs(width, height, tex)
)(image, kernX);
(gpu.programs.filters[convY]
.outputs(width, height, outputTexture)
)(tex, kernY);
this.output().swrite(outputTexture, format);
}
/**
* Update the internal kernel to match
* sigma and kernelSize
*/
_updateKernel()
{
if(this._sigma.x == DEFAULT_SIGMA.x)
this._kernel.x = DEFAULT_KERNEL[this._kernelSize.width];
else
this._kernel.x = _utils_utils__WEBPACK_IMPORTED_MODULE_6__.Utils.gaussianKernel(this._sigma.x, this._kernelSize.width, true);
if(this._sigma.y == DEFAULT_SIGMA.y)
this._kernel.y = DEFAULT_KERNEL[this._kernelSize.height];
else
this._kernel.y = _utils_utils__WEBPACK_IMPORTED_MODULE_6__.Utils.gaussianKernel(this._sigma.y, this._kernelSize.height, true);
}
}
/***/ }),
/***/ "./src/core/pipeline/nodes/filters/greyscale.js":
/*!******************************************************!*\
!*** ./src/core/pipeline/nodes/filters/greyscale.js ***!
\******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "SpeedyPipelineNodeGreyscale": () => (/* binding */ SpeedyPipelineNodeGreyscale)
/* harmony export */ });
/* harmony import */ var _pipeline_node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../pipeline-node */ "./src/core/pipeline/pipeline-node.js");
/* harmony import */ var _pipeline_message__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../pipeline-message */ "./src/core/pipeline/pipeline-message.js");
/* harmony import */ var _pipeline_portbuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../pipeline-portbuilder */ "./src/core/pipeline/pipeline-portbuilder.js");
/* harmony import */ var _gpu_speedy_gpu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../../gpu/speedy-gpu */ "./src/gpu/speedy-gpu.js");
/* harmony import */ var _gpu_speedy_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../gpu/speedy-texture */ "./src/gpu/speedy-texture.js");
/* harmony import */ var _utils_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../../utils/utils */ "./src/utils/utils.js");
/* harmony import */ var _utils_types__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../../utils/types */ "./src/utils/types.js");
/* harmony import */ var _speedy_promise__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../speedy-promise */ "./src/core/speedy-promise.js");
/*
* speedy-vision.js
* GPU-accelerated Computer Vision for JavaScript
* Copyright 2020-2022 Alexandre Martins <alemartf(at)gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* greyscale.js
* Convert an image to greyscale
*/
/**
* Convert an image to greyscale
*/
class SpeedyPipelineNodeGreyscale extends _pipeline_node__WEBPACK_IMPORTED_MODULE_0__.SpeedyPipelineNode
{
/**
* Constructor
* @param {string} [name] name of the node
*/
constructor(name = undefined)
{
super(name, 1, [
(0,_pipeline_portbuilder__WEBPACK_IMPORTED_MODULE_2__.InputPort)().expects(_pipeline_message__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineMessageType.Image),
(0,_pipeline_portbuilder__WEBPACK_IMPORTED_MODULE_2__.OutputPort)().expects(_pipeline_message__WEBPACK_IMPORTED_MODULE_1__.SpeedyPipelineMessageType.Image),
]);
}
/**
* Run the specific task of this node
* @param {SpeedyGPU} gpu
* @returns {void|SpeedyPromise<void>}
*/
_run(gpu)
{
const { image, format } = /** @type {SpeedyPipelineMessageWithImage} */ ( this.input().read() );
const width = image.width, height = image.height;
const outputTexture = this._tex[0];
const filters = gpu.programs.filters;
filters.rgb2grey.outputs(width, height, outputTexture);
filters.rgb2grey(image);
this.output().swrite(outputTexture, _utils_types__WEBPACK_IMPORTED_MODULE_6__.ImageFormat.GREY);
}
}
/***/ }),
/***/ "./src/core/pipeline/nodes/filters/median-blur.js":
/*!****************************************