OctoPrint plugin that works with The Spaghetti Detective

Agreed! @FormerLurker has already helped us a lot. Our current hypothesis (still needs to be validated) is the algorithm will perform better on a stable pic, so I can totally see these 2 plugins integrate in a more seamless way.

1 Like

What about a hook when a new snapshot is generated? Since Octolapse supports multiple cameras, and some of them might not actually supply an image (DSLR saving image on the local SD, for example) there are some design challenges. I'm sure they could be surmounted.

Maybe something like: on_snapshot_available(snapshot_file_path, *args, **kwargs)

I'd probably have to copy the image somewhere, call all of the subscribers, then delete the image once all the callers return. Since snapshot post processing is already done in a worker thread in the development version, this would integrate well into the current program.

if that type of communication between plugins is possible that would be cool, then a plugin could "subscribe" for snapshot to octolapse ...

as for dslr, I'm these days planning to setup my old dslr to take timelapse images and with gphoto2 you can take a picture and download the picture locally so then that image could be sent to TSD .. to me it looks like a good addon directly for octolapse to be sending image to TSD but I guess a second plugin that would talk to octolapse and tsd makes sense (not that I know how to write it :smiley: )

Already got you covered! Regarding the hook, not only is is possible, but Gina made it easy! I'll add it to my todo list.

cool, I already have gphoto2 working there making test timelapses (using simple bash script to take snapshot, store etc.etc.. was not linking it to octoprint, just running on same opi), was thinking of making small "Service" that would behave like snapshot url but since you already made it into octolapse no need to waste time with it :smiley: .. finally this old 350D will get some real work done :smiley: (I actually wanted to use 1ds mark2 that I have, but darn thing don't support taking images from usb and don't even have IR remote sensor as I wanted to trigger it then from RPI gpio using IR diode simulating canon remote but... so 350D will have to do the job) ..

anyhow back to the original question, great, Gina did think of everything when she designed the plugin system :smiley: .. so this will be cool to get TSD to have option to either fetch data from snapshot url every x seconds or to fetch image from octolapse every time one was made :slight_smile:

The design to hook TSD into Octolapse sounds good to me.

The only tricky thing I can see so far is currently the detection actually depends on the fact that the intervals between snapshots is roughly 10s. The reason for that, at the very high level, is that the current detection value will be compared to a rolling mean, in order to minimize the false positives.

When we improve the neural net itself to be good enough so we don't have to depend on the rolling mean, I can totally see how it'll be to use snapshot taking by Octolase.

1 Like

@Kenneth_Jiang ... seeing some weird behavior on OctoPrint 1.3.11rc1 ?!
Before print is started, the images are sent trough and on the :3334/printers/ I see what's going on... but in the log file, even when I setup octoprint to log everything in debug level I don't see anything... even if I add to capture_jpeg() something like

_logger.debug("JPG XXXXXXX");

nothing in the log ?!

anyhow, that's not important weird part, ok logging is broken but.. when the print actually start (state goes to "printing") the images stop going to server ?!

the only thing in log that I see is

...
2019-03-29 23:30:27,547 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:32:30,556 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:32:30,623 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:32:30,661 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:32:30,741 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:34:08,523 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:34:08,604 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:34:08,642 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:34:08,682 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:36:10,758 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:36:10,835 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:36:10,930 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:36:10,989 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:37:56,953 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:37:56,977 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:37:57,066 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:37:57,111 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:39:06,403 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:40:04,297 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:40:04,366 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:40:04,472 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:40:04,581 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:41:56,123 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:41:56,185 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:41:56,268 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
2019-03-29 23:41:56,333 - octoprint.plugin - DEBUG - Calling on_event on thespaghettidetective_beta
...

and this goes on while printer is printing but no images on the :3334/printers/

It's odd. The only thing I can think of is that the plugin shortens the interval between sending image while printer starts to print. https://github.com/TheSpaghettiDetective/OctoPrint-TheSpaghettiDetective/blob/74c12ff353cbbe9bcfe334021210037ffb775861/octoprint_thespaghettidetective_beta/init.py#L175

Does this issue only happens in 1.3.11rc1 ? I may need to install 1.3.11rc1 to test it out myself.

The reason why your debug info didn't get written to log file was probably that the log level for plugins was set to higher than debug level. Try _logger.warn to see if you start to see the logs.

I'm working on a plugin to do just that (create a snapshot URL) for some gopros. A friend was generous and let me borrow his for development. I might just add a gphoto2 integration. Honestly it's very hard to support bash scripting, and it's understandably difficult for lots of users. Should be fun!

this is when I noticed it .. but can't be 100% sure .. will look at the L175

it's weird, never seen this, I did actually do

_logger.debug("JPG XXXXXXX");
_logger.info("JPG XXXXXXX");

and none shown in log, I'll add few more (warn too) :slight_smile: .. and I'll add it to init.py too .. I'm not a python dev so I'm probbly doing something stupid there :smiley:

weird ... WARNING, CRITICAL and ERROR go trough while DEBUG don't ... irrelevant to me setting DEBUG log level :smiley: :smiley: :smiley: ...

octoprint.log:2019-03-30 12:01:02,212 - octoprint_thespaghettidetective_beta - WARNING - JPG XXXWARNINGXXXX
octoprint.log:2019-03-30 12:01:02,213 - octoprint_thespaghettidetective_beta - ERROR - JPG XXXERRORXXXX
octoprint.log:2019-03-30 12:01:02,286 - octoprint_thespaghettidetective_beta - CRITICAL - JPG XXXCRITICALXXXX
octoprint.log:2019-03-30 12:01:02,325 - octoprint_thespaghettidetective_beta - ERROR - JPG XXXEXCEPTIONXXXX
octoprint.log:2019-03-30 12:01:02,682 - octoprint_thespaghettidetective_beta.webcam_capture - WARNING - CAPTURE XXXWARNINGXXXX
octoprint.log:2019-03-30 12:01:02,685 - octoprint_thespaghettidetective_beta.webcam_capture - ERROR - CAPTURE XXXERRORXXXX
octoprint.log:2019-03-30 12:01:02,739 - octoprint_thespaghettidetective_beta.webcam_capture - CRITICAL - CAPTURE XXXCRITICALXXXX
octoprint.log:2019-03-30 12:01:02,776 - octoprint_thespaghettidetective_beta.webcam_capture - ERROR - CAPTURE XXXEXCEPTIONXXXX
octoprint.log:2019-03-30 12:01:52,693 - octoprint_thespaghettidetective_beta - WARNING - JPG XXXWARNINGXXXX
octoprint.log:2019-03-30 12:01:52,696 - octoprint_thespaghettidetective_beta - ERROR - JPG XXXERRORXXXX
octoprint.log:2019-03-30 12:01:52,790 - octoprint_thespaghettidetective_beta - CRITICAL - JPG XXXCRITICALXXXX
octoprint.log:2019-03-30 12:01:52,857 - octoprint_thespaghettidetective_beta - ERROR - JPG XXXEXCEPTIONXXXX
octoprint.log:2019-03-30 12:01:52,925 - octoprint_thespaghettidetective_beta.webcam_capture - WARNING - CAPTURE XXXWARNINGXXXX
octoprint.log:2019-03-30 12:01:52,929 - octoprint_thespaghettidetective_beta.webcam_capture - ERROR - CAPTURE XXXERRORXXXX
octoprint.log:2019-03-30 12:01:52,969 - octoprint_thespaghettidetective_beta.webcam_capture - CRITICAL - CAPTURE XXXCRITICALXXXX
octoprint.log:2019-03-30 12:01:53,013 - octoprint_thespaghettidetective_beta.webcam_capture - ERROR - CAPTURE XXXEXCEPTIONXXXX

@Kenneth_Jiang
I see now there's also octoprint_thespa.. additional to octoprint.plugins.thespa.. so I added that one too to debug .. I think that might be a bug? that logger was init with wrong name?

anyhow now with these two new set to DEBUG it works as expected

2019-03-30 12:07:17,768 - octoprint_thespaghettidetective_beta - DEBUG - JPG XXXDEBUGXXXX
2019-03-30 12:07:17,771 - octoprint_thespaghettidetective_beta - INFO - JPG XXXINFOXXXX
2019-03-30 12:07:17,771 - octoprint_thespaghettidetective_beta - WARNING - JPG XXXWARNINGXXXX
2019-03-30 12:07:17,772 - octoprint_thespaghettidetective_beta - ERROR - JPG XXXERRORXXXX
2019-03-30 12:07:17,824 - octoprint_thespaghettidetective_beta - CRITICAL - JPG XXXCRITICALXXXX
2019-03-30 12:07:17,884 - octoprint_thespaghettidetective_beta - ERROR - JPG XXXEXCEPTIONXXXX
2019-03-30 12:07:18,062 - octoprint_thespaghettidetective_beta.webcam_capture - DEBUG - CAPTURE XXXDEBUGXXXX
2019-03-30 12:07:18,063 - octoprint_thespaghettidetective_beta.webcam_capture - INFO - CAPTURE XXXINFOXXXX
2019-03-30 12:07:18,078 - octoprint_thespaghettidetective_beta.webcam_capture - WARNING - CAPTURE XXXWARNINGXXXX
2019-03-30 12:07:18,083 - octoprint_thespaghettidetective_beta.webcam_capture - ERROR - CAPTURE XXXERRORXXXX
2019-03-30 12:07:18,129 - octoprint_thespaghettidetective_beta.webcam_capture - CRITICAL - CAPTURE XXXCRITICALXXXX
2019-03-30 12:07:18,170 - octoprint_thespaghettidetective_beta.webcam_capture - ERROR - CAPTURE XXXEXCEPTIONXXXX

you should check if this is how it supposed to work or the octoprint_thespaghettidetective_beta should actually log as octoprint.plugins.the...

back to figuring out why after print start there's no images being sent :slight_smile:

Never knew you can set log level in OctoPrint settings. I'm once again impressed by Gina. :slight_smile:

And thank you for finding this bug for us. Issue opened here: https://github.com/TheSpaghettiDetective/OctoPrint-TheSpaghettiDetective/issues/15. Will get to it when we catch our breath.

1 Like

That was actually contributed by @kantlivelong :+1:

1 Like

:wave::upside_down_face:

3 Likes

I updated TheSpaghettiDetective (not the plugin but server) and deleted web/static_build/media/* and now it works ok :smiley:

Weird. It sounds like a tricky bug. Any hint why it started to work after you deleted web/static_build/media/*? @arhi

dunno if the deleting the static_build was what made it work or pulling the new code and rebuilding everything.. problem is I did too many thins in the same time

  • changed to DEBUG logging for octoprint_the..
  • added logging into 3 places (2 in init and 1 in web..)
  • pulled new code from git and rebuilt the system (old sqlite db)
  • deleted web/static_build/media/*
  • masked with tape bunch of wires on my hotend TSD was detecting as failure :smiley:

and than I started a new print expecting to log how it fetches jpg every 50sec before print and "never" when print started but it continued logging that it fetched the jpg after print started, every 10 seconds, so I believed I need to add logging to (after I find it) into place where you send the jpg to TSD server but when I opened TSD server page I seen it was properly working so could not reproduce the problem any more :frowning: ..

I can't say, before, when it stopped showing img on the server when print starts, if the plugin was not sending jpg (as logging was not working) or server was ignoring it or not showing it or whatever.. and now it all works ok so.. in any way looks like issue is solved, reverted plugin back to original code, works ok, so I'd say def. something wrt server changed that it works now but there was a lot of changes pulled so.. also, since I had originally issues building the TSD server, maybe the new code just made the whole system rebuild itself "properly" ... maybe..

We all have had these moments: when you get everything in place to catch the bug, the bug just disappeared, lol.

This is such a cool plugin to save your bacon on prints even if your just in the next room.

2 Likes

Does anyone know if you can install TheSpaghettiDetective server on a dedicated server already running CentOS or would a VM need to be installed with it's own IP and Ubuntu installed? Any advise would be great. I'd love to setup my own server and already have a server with CentOS.