Open 3D-Lasers-Lab opened 6 months ago
Can you share your octoprint.log please? Need to gleam a little more details from it, as I am seeing the same thing in a newer octopi bookworm image running python 3.11.2. The response coming back from the test reference button in the developer tools network tab is `No module named 'cv2' and I bet it is an opencv/python version compatibility problem. Not sure why the popup is not popping up the error message, but that is a separate issue I'll have to fix too.
Tested on an older instance that I had this already installed on running python 3.7.3 and was getting same error when image resolution was different. So the set reference image was from a different camera/setup, and when pressing test reference the two images weren't the same resolution, which caused a size mismatch. That looks like this in browser's developer tools.
Just in case it's a process issue, try this. Use the take snapshot button to generate a base image, click the set as reference button next to image and click save. open settings back up and try the test reference button again and let's see what happens in developer tools (F12) > network tab (make sure it's open when pressing the button).
I did the exact order you requested for setting the reference image, I doubt the two files were different resolutions as I have only ever used the same webcam on each install (I have one install that uses a rapi cam and one that uses a usb camera, two seperate rpis).
Those logs and pictures are from a fresh install raspberry pi 4, octoprint 1.9.3 with the only added plugin being bed ready.
Really appreciate your help on this. This plugin is exactly what I have been looking for, all local. I went ahead and sent a small donation to your paypal :)
And the octoprint log is at the top of that last comment, its kind of hidden lol.
Also noticed this in the preview section of the network
Just SSH into the pi and checked, numpy version 1.19.5 is installed to /usr/lib/python3/dist-packages
when you are running those commands to install previously, you were probably doing it in the OS python and not in OctoPrint's venv? Try this process to clean things up. Start SSH session and run these commands.
pip uninstall opencv-python-headless
source /home/pi/oprint/bin/activate
pip install --upgrade pip
pip install opencv-python-headless==4.6.0.66
deactivate
report any errors during pip install process
seems to be a dependency tree issue now for me. when attempting pip install opencv-python-headless==4.6.0.66
I get an error
ERROR: No matching distribution found for numpy==1.21.2
Looking at piwheels it seems it wasn't until version 1.22.0 of numpy that it was building for python 3.11. That shouldn't effect you hopefully.
Ok, I have spent a whole bunch of time on this and finally might have some answers. It seems like the 32 bit version of octoprint I was never able to get numpy to install correctly. I ran the 1.8.6 version of octoprint with 64 bit and was able to get it working great. I also tried it on the most recent 64 bit nightly and that installed numpy and worked perfectly as well (although I was not able to use a raspi cam and had to use a webcam, but that is a separate thing). I am probably going to stick to the 1.8.6 version as I am saw some other issue with 1.9.x and the pausing not working correctly (I didn't personally test it but it is another issue on the issue tracker). Also I am going to add masking to this plugin and maybe some sort of lighting standardization algorithm to help with different lighting levels (I'm going to have to investigate how the rpi determines shutter time for the camera, it might not be necessary). I really hate the server approach that other bed checking and failure detection algorithms use so hopefully I can improve the plugin to make it a bit more useful. Also in my personal opinion the level of computer vision and AI techniques that are needed to determine print failures are entirely processable on a raspberry pi just running a model (not for training though). I wrote some software in around 2018 that could detect print failures from pictures and it was very accurate, but limited compared to modern approaches and used proprietary computer vision software. Anyways I will quit yapping lol.
Any improvements that can be made to the detection are definitely appreciated. It's weird you were having so many issues getting it installed, but I suspect that has to do with the upstream dependencies of opencv-python-headless and not having pre-compiled wheels available from piwheels for the needed versions. I've run into that issue a few times with various modules, specifically numpy. I'm going to keep this ticket open to handle the error message though, as it shouldn't be showing a success popup with the error, but an actual error popup with the error messages we were catching in the developer tools console tab.
I did also try and install from the source and not use wheels but I wasn't able to get that working on the 32 bit version at all. Also I tried to modify the setup.py to install the latest opencv version and that also failed, I tried to pip install multiple different versions into the virtual enviorment, also failed. Nothing I tried worked, but switching to the 64 bit version and literally everything works perfectly. I wish I could find the forum post but I did see somebody else saying they were having issues with numpy on 32 bit which is what pointed me in that direction, but they had a bunch of other useful information in the thread.
Adding to this, I see the issue error: "Error importing numpy: you should not try to import numpy from\n its source directory; please exit the numpy source tree, and relaunch\n your python interpreter from there."
in the dev console. Fresh install of octopi with the new camera stack running 32 bit. Not sure how to fix it just yet, other than wiping the os and running 64 bit? Haven't done that yet, but looks like it helped someone else above?
Are you running from the masking branch? That incorporated numpy, but it wasn't added to the dependencies in setup.py. I'm going to go ahead and add it now and you can attempt a reinstall of the masking branch and see if that fixes it. Otherwise, just installing numpy in OctoPrint's venv via SSH should fix that error too.
sudo apt install libgfortran5 libopenblas0-pthread
source ~/oprint/bin/activate
pip install numpy
deactivate
sudo service octoprint restart
I'll have to dig in deeper on this one. Seems there isn't a version of numpy that I can find that doesn't throw some random error in python 3.9. All my testing so far with masking was from python 3.7 in octopi 0.18.
I simply installed it on a new instance of OctoPi through the plugin manager. Not actually sure how to pick branches to install from...
so, the error you describe indicates a missing dependency. if you follow those steps I mentioned in the last post do you get any errors during install of numpy?
Small correction made to the steps above. I think the issue boils down to missing system dependency instead of python dependency.
When trying to do a comparison it says "Match percentage calculated as NAN%" and the images are not displayed in the dialogue box.
Couple things I have tried: Downgraded to 1.8.2 pip install opencv-python-headless==4.6.0.66 Set the log to debug for Bedready (the logs still look ok but IDK what they should normally look like)
Any help would be appreciated, thanks. And thanks for making this extension, idk why every other extension requires an internet connection and machine vision to do a simple similarity comparison.