olivierlando / path-from-image Goto Github PK
View Code? Open in Web Editor NEWTry to find the shortest path between two points of an image, following pixels matching a given colors pattern.
License: MIT License
Try to find the shortest path between two points of an image, following pixels matching a given colors pattern.
License: MIT License
I keep getting this error on a basic project build : Uncaught TypeError: Invalid attempt to destructure non-iterable instance
On closer inspection, this error is being generated from:
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
in the PathFromImage.js
file.
It seems like:
value: function path(_ref, _ref2, tolerance) {
var _ref4 = _slicedToArray(_ref, 2),
x1 = _ref4[0],
y1 = _ref4[1];
is the root cause, specifically line 2.
Any ideas on how can this be resolved? Thanks
Hi @olivierlando, I have installed this excellent package for my test application, however when I am testing the code functionality with the example you proved (and with the same image) I am getting different co-ordinates from the ones you are expecting to get.
Instead of these co-ordinates [62, 413], [63, 406], [69, 390], I am getting:
[63, 294], [69, 288], [95, 292], [121, 304]...
I am using the exact same test code you provided:
`const fs = require('fs');
const jpeg = require('jpeg-js');
const PathFromImage = require('path-from-image');
const bluePointCoords = [62, 413];
const redPointCoords = [514, 39];
const image = jpeg.decode(fs.readFileSync('road.jpg'), true);
const pathFromImage = new PathFromImage({
width: image.width,
height: image.height,
imageData: image.data,
colorPatterns: [{ r: [60, 255], g: [0, 70], b: [60, 255] }], // description of the mauve / ping color
});
const path = pathFromImage.path(bluePointCoords, redPointCoords);
Any reason for such a discrepancy? Thanks
I am using your excellent package 'Path-from Image for a small project I am doing. It does the job quite well! I have been trying to modify it slightly to my needs for the last few weeks, however to no avail.
I am a relative beginner and struggling to understand all the code. I would like to know, if possible, how to increase the step size for the co-ordinates returned.
I have attached an image which shows from the 3rd to 4th co-ordinates, only a -8 change in the x direction. I would like to increase this such that, only changes >10 or >20 only show up. Is this possible?
I would be extremely grateful if you could point me in the right direction to perform this task.
Thanks and Regards,
Ryan
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.