Open tanthua opened 7 years ago
Well I guess you have 2 options here:
But to help you further I would need to know what your script shall do and how everything works together.
Thanks so much for the response Salandora!
I found the idea of wiring button to python script is not feasible due to my knowledge, so I decided to send the command line from octoprint to trigger it.
My first command line is very simple:
sudo wget http://localhost:8080/?action=snapshot -O /home/pi/webcam/output.jpg
to obtain the picture.
Then my second command line would be:
sudo python test.py
where test.py will include the hardcoded path "/home/pi/webcam/output.jpg" to apply its OpenCV functions to display the dimensions of the image, etc.
It seems working fine for me. But I'd still like to make the GUI of my tab looks friendlier by:
<p>img src = "path"<\p>
but it does not seem like working because I know it has to somehow bind data from Knockout.js, which I don't know how.Hope you can have time and give me some hints and example. Thanks so much!
Hi Salandora,
I'm working on a plugin that has the similar idea that you have here. What my plugin does is to have two buttons on Octoprint's tab using jinja2. First button is used to capture the image from mjpg-streamer. Second button is used to run a python script that process the image just captured and output it to the front-end on Octoprint's tab. However, I haven't been able to do that because of the lack knowledge of flask and tornado.
When I run a python script, say test.py, that has flask imported, it always outputs error "Address already in use." And I know the address is in use by OctoPrint. So is there any solution to have flask running on the same port with OctoPrint so that I can trigger it by a button on Jinja2?