ojos
Version:
High level API on top of Mirada (opencv.js) supporting bth browser and node.
60 lines • 2.75 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var abstractOperation_1 = require("./abstractOperation");
var Edge = /** @class */ (function (_super) {
__extends(Edge, _super);
function Edge() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.name = "Edge";
_this.description = "facade around cv.Sobel, cv.Laplacian and cv.Scharr";
_this.sameSizeAndType = true;
return _this;
}
Edge.prototype.checkInputImage = function (o) {
if (!o.channels && o.src.channels() > 1) {
cv.cvtColor(o.src, o.src, cv.COLOR_RGB2GRAY, 0);
}
};
Edge.prototype.validate = function (o) {
if (['scharr', 'sobel'].includes(o.type) && !(typeof o.dx === 'number' && typeof o.dy === 'number' && o.dx < 3 && o.dy < 3)) {
return 'dx and dy are mandatory and must be less than 3';
}
if (['sobel'].includes(o.type) && ![1, 3, 5, 7].includes(o.ksize || 1)) {
return 'If ksize is given then it must be 1, 3, 5, or 7';
}
if (['laplacian'].includes(o.type) && !(typeof o.ksize === 'undefined' || o.ksize > 0 && o.ksize % 2 === 1)) {
return 'If ksize is given then it must be positive and odd';
}
};
Edge.prototype._exec = function (o) {
var _this = this;
this.allChannels(o, function (o) { return _this._execOne(o); });
};
Edge.prototype._execOne = function (o) {
if (o.type === 'sobel') {
cv.Sobel(o.src, o.dst, o.ddepth || -1, o.dx, o.dy, o.ksize = 3, o.scale || 1, o.delta || 0, o.borderType || cv.BORDER_DEFAULT);
}
else if (o.type === 'scharr') {
cv.Scharr(o.src, o.dst, o.ddepth || -1, o.dx, o.dy, o.scale || 1, o.delta || 0, o.borderType || cv.BORDER_DEFAULT);
}
else if (o.type === 'laplacian') {
cv.Laplacian(o.src, o.dst, o.ddepth || -1, o.ksize || 1, o.scale || 1, o.delta || 0, o.borderType || cv.BORDER_DEFAULT);
}
};
return Edge;
}(abstractOperation_1.AbstractOperation));
exports.Edge = Edge;
//# sourceMappingURL=edge.js.map
;