PressureAdvanceCamera icon indicating copy to clipboard operation
PressureAdvanceCamera copied to clipboard

Segmentation by using image difference

Open vradomir opened this issue 1 year ago • 5 comments

I'd like to explore the idea of taking a photo of the print bed before printing the test pattern to help with the segmentation.

As I'm aware from the youtube comments, you did experiments with that, but did not align the photos beforehand. Textured print surfaces have plenty of features that can be used for alignment. On the other hand, uniform print surfaces have almost none, but suffer much less from slight misalignment.

Since I (currently) don't have an endoscope camera available to attach to the printer, it would be most helpful if you could provide me with some sample photos from your setup before and after printing the test patterns.

I'm looking forward to contributing to this great project, many thanks!

vradomir avatar Mar 23 '25 15:03 vradomir

Thank you very much for offering to help :).

As context for people not having read the youtube comments: Taking a photo before and after the test pattern was the first thing I tried when implementing this project unfortunately it did not seem to help but I only called cv2.absdiff() - I did not try aligning or any other things. I decided against taking two pictures and just using one. The textured PIE looks quite different between the photos (and in general is a pain for edge detection and so on - I guess smooth sheet would be easier but did not try)

I created a new branch https://github.com/undingen/PressureAdvanceCamera/tree/before_after which takes a set of photos before and after the test pattern is drawn. They should be the exact same position. Each set contains a auto exposure photo and 25 others with exposure set manually to different values (in case that auto exposure is not working in this diff mode).

Attached you can find two sets of this images one taken on the "golden" build plate and one on the "black". Unfortunately its already quite late so there was no sunlight at the lighting situation is quite bad. I will take tomorrow more pictures with sunlight.

Here is a call to cv2.absdiff() without taking into account any maybe slightly movement between the images:

Black auto: Image

Gold e700: Image

before_after_gold.tar.gz

I honestly think it works now better than when I tried I don't know if this is a fluke, because I sat the manual exposure wrong when I tried?!? or because its artificial light. Unfortunately the old images all died when the microSD card stopped working completely...

Here are the images (github is not allowing me to attach big files): https://drive.google.com/file/d/1Nh7JrGWcswJDiSwCWDFSLW5gHXKcq9fG/view?usp=sharing

undingen avatar Mar 24 '25 21:03 undingen

Here are the images for a test pattern printed natural light (cloudy evening) https://drive.google.com/file/d/1AHBT7B599OGV1vSds2n2alhpM9uWYJKG/view?usp=sharing

1742921153_before_e1268.jpg: Image

undingen avatar Mar 25 '25 16:03 undingen

Thank you. I have not yet had the time to load the photos into python, but I took a brief look.

I see a consistent misalignment that could indicate backlash in your movement system, such as loose belts or something similar. It could even be that the camera rotated slightly as a result of the print head movement.

Additionally, automatic exposure seems to be very inconsistent, but that's a problem I'd like to focus on later.

In any case, I expect the alignment to be successful. Hopefully I'll have some photos to back it up next time :)

vradomir avatar Mar 26 '25 06:03 vradomir

Thanks this sounds great. I'm planning as next step to modify my other 3d printer too and for that one I will add fixed led light strips so that I have better more consistent lighting. In case it turns out that dual approach is good: if lighting is good and consistent do it on the device and if it fails send it to the cloud AI inference...

undingen avatar Mar 26 '25 08:03 undingen

Please excuse any naivety here, but how feasible and helpful would it be if the bed surface had some etched patterns to help with alignment?

EDIT: or even patterns that are printed before taking captures and printing the grid?

yebo29 avatar Mar 30 '25 14:03 yebo29