r/computervision • u/SalemIII • Sep 03 '26
Showcase I built a classical image processing algorithm that counts textile threads with high accuracy, source in body!
Hello everyone!
I'm an engineering student, during my last internship at a medical device company, i was FORCED to count threads by hand, hated it so much that I wrote code that automated it, tried to turn it into a startup, not going all that great, so I thought I'll just document and release it, works on an Orange Pi and camera module, tested on a real production line, let me know if you have any remarks or questions, check it out!
3
u/Abinash07 Sep 04 '26
Yess FFTs. We did something similar in our course assignment. We had to remove diagonal lines ie noise from images
2
u/SalemIII Sep 05 '26
i think something like that could work great here, directional frequency destruction, i'll try it later and see if i get better accuracy
2
u/EffectiveAgitated137 Sep 04 '26
How did u test for the ground truth ?
2
u/SalemIII Sep 04 '26
I took 12 sample images which i ran the algorithm on, they were also manually counted by a technician, the manual count was the ground truth, i compared the program against that, this was during my last internship day otherwise i would have tested on more samples.
I cannot post this validation data for obvious reasons.
More details in the repo README.
2
u/BeverlyGodoy Sep 05 '26
Any specific reason you choose c++?
2
u/SalemIII Sep 05 '26
i wanted to use opencv, and also wanted to get maximum frame rates, so c++ was the only option, but this should work with python opencv too
2
u/herocoding Sep 05 '26
Really interesting, thank you very much for sharing.
Would you mind adding one, two, a few reference images (here, and/or in your repo) ("8-bit 1024-by-1024 monochrome raw frame"), please?
2
u/SalemIII Sep 05 '26
i'm sorry i didn't realize i posted the jpeg images, should be good now
1
u/herocoding Sep 05 '26
Thank you for the update.
There is now ONE raw frame, "sim_roll_01.raw", right?
Could you provide a few more raw frames, reference images, please?
"generated in debug mode from validation sample 12" - could you share more from those validation samples, please?
1
u/SalemIII Sep 05 '26
you can easily get images tho, get some gauze pads, cut a 10x10cm black non reflective square (i just used black cloth), take an image against a white background, like a table, and you would have your samples
1
u/herocoding Sep 06 '26
That's understood how to take such photos with contrast and indirect lightning, however, I don't have such gauze pads or similar. But e.g. pants or shirts woven from linen fabric is too tight.
2
u/bergdev1 Sep 05 '26
Curious what it would take to count tree rings
1
u/SalemIII Sep 06 '26
counting tree ring is be pretty easy, the real problem is finding where the tree rings are, that's where classical methods on cheap hardware hit a capability wall
3
u/RoboMind Sep 04 '26
If you know the thickness of a single thread in pixels, you can simply use the ratio of white and black pixels, right?
3
u/SalemIII Sep 04 '26
yes but it would not be more accurate then directly counting the threads, the ratio of white to black (or just grayscale amplitude) would be more useful for another inspection, area density estimation



64
u/BlobbyMcBlobber Sep 03 '26
Classic CV is so much fun