GithubHelp home page GithubHelp logo

QR code generation about spoolman HOT 36 CLOSED

solo2424 avatar solo2424 commented on August 29, 2024
QR code generation

from spoolman.

Comments (36)

Donkie avatar Donkie commented on August 29, 2024 2

Integrating it with the existing printer webcam is a brilliant idea! How the frontends decide to scan and register the spool ID from the picture is up to them. But from my end in Spoolman I will still definitely add a way to create QR codes for the spools.

And yes, QR codes have a lot better error correction than regular old barcodes.

from spoolman.

Donkie avatar Donkie commented on August 29, 2024 1

For your full spool management ideas, I think we'd need a more fleshed out investigation on what exact usecases the majority of users want etc. This could be discussed in a new issue. I only have a single printer, with a single extruder, myself, so it's a bit harder for me to understand where the pain points are.

Lot nr is a general term when dealing with manufactured materials. It is generally printed on the spool, could also be called batch nr. When making a big project that would require several spools of the same color, you'd want all spools to have the same lot nr, otherwise they could have variations in color.

Front ends will have to be manually updated in their own rate. I have created a feature request in Mainsail for added support. Not yet notified the Fluidd community though.

Notification if there isn't enough filament is something that would be done in the front ends I believe.

I could add a feature to the built-in client to generate a QR code for a spool. But let's first try to get some basic functionality into the front ends before diving into qr code scanning!

Glad you find my work useful!

from spoolman.

Donkie avatar Donkie commented on August 29, 2024 1

@locki-cz please create new issues, one for each feature request

from spoolman.

NonaSuomy avatar NonaSuomy commented on August 29, 2024 1

I fixed the PoC code above to set the spool_id with curl which works like this now

Install ZBar

mkdir code
cd code
sudo apt install autopoint build-essential libv4l-dev libtool
git clone https://github.com/mchehab/zbar.git
cd zbar
autoreconf -vfi
./configure
sudo make install

Install qrencode
sudo apt install qrencode

Generate a QRCode

qrencode -s 6 -l H -o "qrcodespool1.png" "web+spoolman:s-1"

On your 2D printer, print this on a sticker for your spool.

CLI

cd /home/pi/klipper/klippy/extras/
wget https://raw.githubusercontent.com/th33xitus/kiauh/master/resources/gcode_shell_command.py

Change <PrinterIP> to the IP of your 3D printer below.

mainsail.cfg

[gcode_shell_command qrcode_qrscanner]
command: sh /home/pi/klipper_config/qrcodespoolman.sh
verbose: True
timeout: 2.
[gcode_macro QRCode_Scan]
gcode:
    RUN_SHELL_COMMAND CMD=qrcode_qrscanner

/home/pi/klipper_config/qrcodespoolman.sh

#!/bin/sh
# NonaSuomy PoC scan QRCodes via 3D printer camera
wget http://<PrinterIP>/webcam/?action=snapshot -O /home/pi/printer_data/gcodes/qrcode.jpg
SPOOLID=$(zbarimg -S*.enable /home/pi/printer_data/gcodes/qrcode.png | sed 's/[^0-9]*\([0-9]\+\).*/\1/')
echo $SPOOLID
curl -X POST -H "Content-Type: application/json" -d "{\"spool_id\": \"$SPOOLID\"}" http://<PrinterIP>:7125/server/spoolman/spool_id

Put your spool qrcode upto the chamber camera and hit "QRCode Scan" on the dashboard of MainsailOS.

image

http://<PrinterIP:7125/server/spoolman/spool_id

{"result": {"spool_id": 1}}

Enjoy!

from spoolman.

zellneralex avatar zellneralex commented on August 29, 2024 1

Sorry to say but we will never add a macro to the mainsail.cfg that needs a not default Klipper module.

wht you do at your own install is up to you but that method will never be part of the package we deliver with MainsailOS

from spoolman.

Donkie avatar Donkie commented on August 29, 2024 1

This is now available in release 0.10.0. Please try it out! If you have any suggestions or find any bugs, please make new issues :)

from spoolman.

Donkie avatar Donkie commented on August 29, 2024

If you want it to also integrate with barcodes on a printer, it sounds like you want to add printers as a concept to Spoolman as well. Currently, Spoolman only cares about filaments and spools, not machines. But it's something I've had in mind.

from spoolman.

solo2424 avatar solo2424 commented on August 29, 2024

from spoolman.

Donkie avatar Donkie commented on August 29, 2024

It sounds like that is something that could be entirely done in a frontend like Mainsail, yes.

I believe it's time to take this suggestion to them. They could likely integrate a QR code scanner directly in their frontend, since browsers nowadays support giving direct access to the camera.

from spoolman.

solo2424 avatar solo2424 commented on August 29, 2024

from spoolman.

Donkie avatar Donkie commented on August 29, 2024

I think the QR code could be created in many different ways. It doesn't need any complicated setup, could just be a free-text encoding of like "spool:1" where 1 is the spool ID. Then you could generate and print the QR code in any way you like.

The above idea then only works for a setup where you first open mainsail for the printer you want to assign the spool to, and then scan the spool.

If you want a more fancy integration where you can first scan the QR code for a printer, and then the QR code for the spool you want to assign, it will be a bit more messy. Mainsail only operates with a single printer, so it wouldn't know what to do with you scanning a printer QR code inside mainsail. If this variant is desired, it would be something that needs to be more integrated with Spoolman itself.

from spoolman.

solo2424 avatar solo2424 commented on August 29, 2024

from spoolman.

solo2424 avatar solo2424 commented on August 29, 2024

I was able to get this working using the macros like Arksine explained in his last post on your thread. I have to say I am stoked that this happened so fast. I appreciate your efforts. More donation will be coming down the road. I remember going down this path about 6 months ago and being very frustrated that there were no solutions. I did not want to go back to Octoprint. Someone needed to take this project on, I am glad you decided to. And to get Arksine attention and have him make it work well with moonraker, That is just so awesome! Thanks!

To piggy back on one of the other request, a notification if there isn't enough filament would be nice. And I still would like for a QR code to be automatically created when the spool is created. I am sure I will think of other cool things that could be added in the future. Let's make this the standard for Klipper Spool Management!

from spoolman.

locki-cz avatar locki-cz commented on August 29, 2024

Please add some box with spool colour to list to easy find, maybe link to vendor page and other info? :) PA settings?

from spoolman.

NonaSuomy avatar NonaSuomy commented on August 29, 2024

I did a proof of concept using the chamber camera worked for QR codes just not barcodes.

I tested this with

pi@mainsailos:~ $ wget http://IP/webcam/?action=snapshot -O qrcode.jpg | zbarimg qrcode.jpg
--2023-02-18 07:36:48--  http://IP/webcam/?action=snapshot
Connecting to IP:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [image/jpeg]
Saving to: ‘qrcode.jpg’

qrcode.jpg                        [ <=>                                            ]  28.89K  --.-KB/s    in 0.001s

2023-02-18 07:36:48 (24.7 MB/s) - ‘qrcode.jpg’ saved [29579]

QR-Code:
serial: 007
model: white
material: PLA
vendor: Prusa
density:  1.24
diameter: 1.75
total_weight: 970
spool_weight: 832
cost: 24.99
scanned 1 barcode symbols from 1 images in 0.18 seconds

You could poke Spoolman's code somehow?

image

sudo apt install zbar-tools
cd /home/pi/klipper/klippy/extras/
wget https://raw.githubusercontent.com/th33xitus/kiauh/master/resources/gcode_shell_command.py
[gcode_shell_command qrcode_snapshot]
command: wget http://IP/webcam/?action=snapshot -O /home/pi/printer_data/gcodes/qrcode.jpg
verbose: True
timeout: 2.
[gcode_shell_command qrcode_scanner]
command: zbarimg /home/pi/printer_data/gcodes/qrcode.jpg
verbose: True
timeout: 2.
[gcode_macro QRCode_Scan]
gcode:
    RUN_SHELL_COMMAND CMD=qrcode_snapshot
    RUN_SHELL_COMMAND CMD=qrcode_scanner

I tested regular barcodes on most spools with this code above and enabled all barcodes in the app's arguments but for whatever reason maybe my camera isn’t clear enough for the library. It just says it can’t detect any code. QR codes almost always work no matter the weirdness of what it’s having with what it sees.

To generate QR codes on the printer just use

qrencode -s 6 -l H -o "qrcodespool007.png" "spool:007"

from spoolman.

NonaSuomy avatar NonaSuomy commented on August 29, 2024

Hence the PoC! Most people have the CMD module made by Arksine the creator of Moonraker from the kiauh installer. Until that day though people can still have fun with something that works. Anyone besides me (Not a developer) could make a module without the CMD module and have something running just the same. Ideally, this could just as easily be added to the Spoolman docker. It would just have to have a setting to be pointed at the printer's webcam feed, decode, then post to moonrakers spool_id :D

from spoolman.

zellneralex avatar zellneralex commented on August 29, 2024

In my opinion moonraker would be the best fit for that. Then you could use the remote method to to the same as you do know with your gcode shell command.

moonraker-timelapse is a good example for stuff like that.

from spoolman.

NonaSuomy avatar NonaSuomy commented on August 29, 2024

Not sure how that would work or how moonraker-timelapse is a comparison of how it would work. Maybe you could explain further. The nicest way would be to just toss the spool in the chamber for a second and have a scan button on KlipperScreen so you don't have to touch a computer to load the new spool. However it gets to that point and what works in the background is beyond my ability.

from spoolman.

zellneralex avatar zellneralex commented on August 29, 2024

Timelapse use a moonraker module that takes a picture in the background triggered by a Klipper macro.
For your Scanner that stuff could be done the same way but instead of storing the picture you would post process it with your QR scanner. If you get that far we could get that macro in the mainsail.cfg and also in the mainsail integration of Mainsail.
KS as any UI can execute macros. So you could execute in on the macro page.

from spoolman.

zellneralex avatar zellneralex commented on August 29, 2024

See here that is how we take the picture thru Klipper https://github.com/mainsail-crew/moonraker-timelapse/blob/main/klipper_macro/timelapse.cfg#L297

and that is called in moonraker < https://github.com/mainsail-crew/moonraker-timelapse/blob/main/component/timelapse.py#L378> when the gcode is executed

Best would be to integrate that in the spoolman module that is already part of moonraker. The moonraker DB also contains the webcam setup so that it could use the cam specified in there.

from spoolman.

bazis avatar bazis commented on August 29, 2024

QR code may contain URL to spool info on spoolman web page ( https://my_domain/spool/show/555 )
That's how it works in the service simplyprint.io

from spoolman.

samwiseg0 avatar samwiseg0 commented on August 29, 2024

@Donkie I am sure I am missing it somehow but how would you go about generating and printing the QR code from the UI?

from spoolman.

Donkie avatar Donkie commented on August 29, 2024

Remember to do Ctrl+F5 after every update.
After that's done, you should see a "Print QR Codes" button on the spools page

from spoolman.

samwiseg0 avatar samwiseg0 commented on August 29, 2024

Interesting I am not. I have tried incognito and force updated the docker instance. Let me try something else.

As a side note. I did not see a way to verify the version that is currently running? I checked the logs but there does not seem to be a version number outputted when it starts or in the UI somewhere?

from spoolman.

samwiseg0 avatar samwiseg0 commented on August 29, 2024

I specifically pulled the 0.10 tag and I still do not see it?

2023-08-12_17-42_1

2023-08-12_17-42

from spoolman.

Donkie avatar Donkie commented on August 29, 2024

Looks like you don't even have the previous version. How are you updating Spoolman?

from spoolman.

samwiseg0 avatar samwiseg0 commented on August 29, 2024

Watchtower usually handles that but in this case I recreated the container though portainer. I will try deleting the whole container and re deploying it.

from spoolman.

samwiseg0 avatar samwiseg0 commented on August 29, 2024

That did it. Something must have broken along the way and it was stuck. Blowing it away and starting from scratch seems to have done the trick. Thanks

from spoolman.

NonaSuomy avatar NonaSuomy commented on August 29, 2024

Tested and everything worked!

from spoolman.

NonaSuomy avatar NonaSuomy commented on August 29, 2024

Tip if you can't get the cam scanner working because of https.

Make the browser device camera work with non https local sources.

chrome://flags/#unsafely-treat-insecure-origin-as-secure

Enable the Insecure origins treated as secure

Add the address for your Spoolman server IP:Port that you want to ignore the secure origin policy for. Remember to include the port number too.

Ignore the port used in this image I made it for another docker with a similar issue.
image

Save and restart Chrome.

Click enable on camera request when pops up.

from spoolman.

solo2424 avatar solo2424 commented on August 29, 2024

from spoolman.

NonaSuomy avatar NonaSuomy commented on August 29, 2024

What do you want working and how do you want it to work? As mainsail really has no support for this unless you want to use my PoC above. You would have to use fluidd which seems to have knocked it out of the park with support for it with matmen's pr fluidd-core/fluidd#1119

from spoolman.

solo2424 avatar solo2424 commented on August 29, 2024

from spoolman.

samwiseg0 avatar samwiseg0 commented on August 29, 2024

@solo2424 a bit off topic but just so you are aware. You can use mainsail and fluidd simultaneously and interchangeably. There is no need to "switch" to one or the other.

from spoolman.

NonaSuomy avatar NonaSuomy commented on August 29, 2024

But I like the idea of being able to use the WebCam to scan the spool and
automatically set it to active.

My PoC above does only this but I haven't tested it yet with the current release of QR codes.

But I would also like the same thing to happen if I use my phones, camera.

This feature request would have enabled that ability #72

Maybe donkie will eventually add a plugin system for stuff they don't directly agree with but makes sense to others.

Ideally, there is nothing stopping you from modifying donkeys spoolman code and adding an action button next to the spools or automatically post via the qr code scanning page as well. Then you can bring that webpage up on your phone then scan and set the spool maybe with a drop-down list of your printers. Basically set the spool id via a similar command to how I did above but use whatever web-related methods to POST -H "Content-Type: application/json" -d "{\"spool_id\": \"$SPOOLID\"}" http://<PrinterIP>:7125/server/spoolman/spool_id etc.

I'm not sure if the phone has the same https limitation but probably does. So this may toss a wrench in the gears.

Looking at your code above, I try to manipulate using my settings as much as possible, but I can’t find a klippy_config folder anywhere. Therefore, I also do not have the qrcodespoolman.sh file.

klippy_config is a standard folder in your home directory when you use the MainsailOS pi image. Maybe yours is called RedRover_config? Maybe search what files are stored in klippy_config and then find that same directory of files on your setup. It can probably be put in any place you want that the printer has access to. Then edit the scripts above to show those location changes you made.

You have to make this file qrcodespoolman.sh and edit it as was said above.

Let me know if you need more information.

from spoolman.

NonaSuomy avatar NonaSuomy commented on August 29, 2024

Looks like the current QR code shows up like this web+spoolman:s-1
Not sure why it was formed like this but seems the regex above still matches it fine. So the code above "should" just work once you get your directories figured out.

image

from spoolman.

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.