GithubHelp home page GithubHelp logo

olivierlando / path-from-image Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 0.0 341 KB

Try to find the shortest path between two points of an image, following pixels matching a given colors pattern.

License: MIT License

JavaScript 100.00%
dijsktra-shortest-path douglas-peucker

path-from-image's People

Contributors

olivierlando avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

path-from-image's Issues

Invalid attempt to destructure non-iterable instance

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

Different path co-ordinates

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

Increasing step size for co-ordinates returned

Hi @olivierlando

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?

console log

I would be extremely grateful if you could point me in the right direction to perform this task.

Thanks and Regards,

Ryan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.