GithubHelp home page GithubHelp logo

Node.js support? about quaggajs HOT 8 CLOSED

serratus avatar serratus commented on August 25, 2024
Node.js support?

from quaggajs.

Comments (8)

serratus avatar serratus commented on August 25, 2024

Sorry, there are not plans yet. From my understanding, a node.js implementation would be focused around decoding still-images instead of live-video, right? I haven't focused too much on still-image barcode reading, but making it compatible with node.js might be a good incentive.

Do you know how to get around the fact that node.js does not support any DOM APIs like <canvas> and <img> which are needed for quaggaJS to work?

from quaggajs.

s-a avatar s-a commented on August 25, 2024

Hi,
no it would not be limited to static image files. In best case the lib supports streams from where it is also possible to scan webcam inputs. For my needs it is enough to support static images. There are a few libs out there for node providing canvas support. https://github.com/Automattic/node-canvas not tested yet if it is full OS independent. I think the tdd with your testsiute will be more productive if you are willing to support node .
I inspected your code a little bit and think it is well modular coded from where it should be easy to Add node support.
As far as I can see the only missing feature for node is canvas element but have not read all code. I d like to use your library but need server side processing to avoid hacks.

Please let me know if you need any support regarding node.

from quaggajs.

s-a avatar s-a commented on August 25, 2024

just tested node-canvas... It attracts a rat tail of dependencies which are complicated to install and everything else than stable. at the repo are 220 tickets open o.O So canvas is not trivial in node sorry :/.

Any chance to abstact the logic behind? I found https://www.npmjs.com/package/get-pixels to read pixel informations from static image, but not tested yet

from quaggajs.

serratus avatar serratus commented on August 25, 2024

Thanks for the research so far. Abstracting the image reading depending on the system might be best way to go. get-pixels seems like a good start, although I have just scrolled through the dependencies and docs. This could definitely work for server-side environments.

Would you create a separate build for server and client, or simply combine them in one file? I don't have much experience in creating a library which can be run on node (using different features) and the client. What I'm afraid of is, that the library gets bloated when I create a distributed version for the client that also includes the node-js part.

from quaggajs.

s-a avatar s-a commented on August 25, 2024

I suggest to keep it separate and include shared sources from https://github.com/serratus/quaggaJS/tree/master/src with node's requiere. There is no need to bundle and minify for node and the most code should run on both environments? To make the shared code run on client and server should do the trick. I saw some places where you used module.exports which is already native node usage. All you need is a field "main" pointing to your server side index.js.
Personaly I put Server side code in a subfolder called lib and pass this folder to a test coverage process with output to lib-cov.

Here is a very simple setup .
https://github.com/s-a/package.js

from quaggajs.

serratus avatar serratus commented on August 25, 2024

During my research I discovered the presence of another field in the package.json file which can be used to distinguish between browser and main environment. This could be helpful for creating browserify/webpack client applications and node.js server-side implementations. I still have to figure out how to get the requirejs styled code into node's module.exports format.

from quaggajs.

s-a avatar s-a commented on August 25, 2024

Did not know this field. Interesting info.
I used require.js years ago but simplyfied my build processes and renounced amd a long time.
I have noticed that http://browserify.org became very much fame . it provides require Syntax which is identical to node.js.

Do you use require.js to support amd or is it just a part of your build process? In this case you could simply concat all files and publish your library to public scope. For example like jquery which runs also in both environments .

from quaggajs.

serratus avatar serratus commented on August 25, 2024

Basically, I use require.js during development simply for dependency management and modularization. This also helps packaging the library in a single file. Anyways, yesterday I was tinkering on the node.js support and created a new branch (a042422) for that. Decoding static images should basically work, but there is still a lot to do. This is just an experiment.

from quaggajs.

Related Issues (20)

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.