#garfield Logs
Nov 25 2022
#garfield Calendar
12:00 AM rue_mohr: std::vector
12:09 AM rue_mohr: I auto-ditched any contours thats enclosing circle had a radius less than 15 pixels
12:09 AM rue_mohr: cause, no.
12:09 AM rue_mohr: your going to have lots to read in the mornig
12:24 AM rue_mohr: print("The array is:", contours_poly[i])
12:25 AM rue_mohr: so I need to convert that to polar
12:30 AM rue_mohr: cmath.polar() Convert a complex number to polar coordinates
12:30 AM rue_mohr: cmath.rect() Convert polar coordinates to rectangular form
01:02 AM aandrew: woo
01:02 AM aandrew: $ python3 teeth_and.py
01:02 AM aandrew: found 58 contours:
01:02 AM aandrew: original contour had 2324 points, reduced to 156
01:02 AM aandrew: number of intersections: 56
01:02 AM aandrew: gear has 28 teeth
01:03 AM rue_mohr: ok
01:04 AM aandrew: still needs some cleanup but it's much better now: https://pastebin.com/Q4kt7Lvf
01:04 AM rue_mohr: you using numpy?
01:04 AM aandrew: yes, opencv uses it internally
01:05 AM aandrew: it still hates your image though
01:05 AM rue_mohr: you using matrix ops ont eh array?
01:05 AM aandrew: hm?
01:06 AM rue_mohr: just a sec, browser crashed again
01:07 AM rue_mohr: so, the contour
01:07 AM rue_mohr: I want to translate all the points in one of them
01:08 AM aandrew: I was trying to use find_circles but it just wasn't working out
01:09 AM rue_mohr: poly
01:09 AM rue_mohr: find poly
01:23 AM rue_mohr: its not a numpy array
01:35 AM rue_mohr: oh dear god python will break my brain...
01:35 AM rue_mohr: ar = np.array(contours_poly[i])
01:35 AM rue_mohr: ar = ar - [1000,1000]
01:35 AM rue_mohr: that subtracts 1000,1000 from all the points
01:35 AM rue_mohr: whatever, ok
01:35 AM rue_mohr: [[ 4.61138916e+01 -1.73634430e+02]]
01:35 AM rue_mohr: [[ 4.61138916e+01 -1.81634430e+02]]
01:35 AM rue_mohr: [[ 4.41138916e+01 -1.88634430e+02]]
01:35 AM rue_mohr: thanks numpy
01:35 AM rue_mohr: :/
02:57 AM rue_mohr: ok, I converted the contour to polar
02:58 AM rue_mohr: I have the average radius for the teeth
03:00 AM rue_mohr: I'll check it against the min and max, if there isn't more than about 5 pixels of amplitude on the teeth, I'll reject the contour
03:05 AM rue_mohr: average is: [1.86742318e+02 6.14434134e-02] variance is: [41.43725201 3.28972437]
03:05 AM rue_mohr: average is: [16.42117351 0.14083002] variance is: [0.78336006 3.13575424]
03:05 AM rue_mohr: the co-ords are amplitude, angle
03:05 AM rue_mohr: the variance is absolute
03:05 AM rue_mohr: one of these is the gear, the other the middle circle
03:06 AM rue_mohr: the teeth on the gear have the variance of 41
03:06 AM rue_mohr: the middle circle has a variance of 0.8
03:06 AM rue_mohr: 5 seems like a fine ditch-point
03:24 AM rue_mohr: ditching profile 1 becasue teeth are smaller than 10 pixzels!
03:24 AM rue_mohr: ditching profile 2 becasue its smaller than 15 pixzels!
03:30 AM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/image_thres1.jpg
03:30 AM rue_mohr: oooOOoooooo...
03:30 AM rue_mohr: I'm going to use a schmitt trigger on it
04:02 AM rue_mohr: Teeths is: [2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0.
04:02 AM rue_mohr: 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0.
04:02 AM rue_mohr: 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0.
04:02 AM rue_mohr: 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0.
04:02 AM rue_mohr: 2. 0. 2. 0. 2. 0. 2.]
04:02 AM rue_mohr: Toothcount is: 52.0
04:02 AM rue_mohr: its wrong, and I know exactly why
04:03 AM rue_mohr: you not done sleeping yet
04:03 AM rue_mohr: polprog, your awake , cmon
04:03 AM rue_mohr: dont hide
04:06 AM rue_mohr: Teeths is: [2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0.
04:06 AM rue_mohr: 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0.
04:06 AM rue_mohr: 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0.
04:06 AM rue_mohr: 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0. 2. 0.
04:06 AM rue_mohr: 2. 0. 2. 0. 2. 0.]
04:06 AM rue_mohr: Toothcount is: 51.0
04:06 AM rue_mohr: !!!!!!
04:06 AM rue_mohr: you know whats SUPER COOL about the way I did it?
04:07 AM rue_mohr: I *SHOULD* be able to drop on multiple gears
04:07 AM rue_mohr: wink wink nudge nudge
04:20 AM rue_mohr: http://ruemohr.org/%7Eircjunk/tempimage/image_thres1.jpg <-- AAAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
04:21 AM rue_mohr: https://paste.debian.net/1261814/
04:36 AM rue_mohr: hahah, the stress test image didn't work
04:36 AM rue_mohr: I'll adjust more later
05:19 AM Tom_L: .
05:20 AM rue_mohr: hey
05:22 AM Tom_L: using a camera to count your gear teeth?
05:23 AM rue_mohr: yea!
05:25 AM rue_mohr: my greenscreen trick needs work
05:25 AM rue_mohr: or I have to do something else
05:26 AM rue_mohr: somehow the camera is making everything look green
05:26 AM rue_mohr: its if doing white balance, it should be the opposite
05:26 AM rue_mohr: I'm trying to play with the "green definition" and messing it all up
05:27 AM Tom_L: white or black?
05:27 AM Tom_L: depending on the gear
05:27 AM rue_mohr: mostly white ones right now
05:27 AM Tom_L: i meant backdrop
05:28 AM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/foo.jpg
05:28 AM rue_mohr: I'm attempting to green-screen the back out
05:29 AM rue_mohr: it worked for the first one, but the lights are running on a battery tooo
05:29 AM rue_mohr: I think their getting dimmer
05:29 AM rue_mohr: its been like 6 hours
05:30 AM rue_mohr: ya know
05:30 AM rue_mohr: ya know what I should do...
05:30 AM rue_mohr: I should take a pic of the table and diff it
05:45 AM rue_mohr: so I'm going back to the greyscale threasholding
05:45 AM rue_mohr: with kinda arbitrary thresholds
05:47 AM rue_mohr: OHOHOHOH!
05:48 AM rue_mohr: tom check this out
05:48 AM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/image_thres12.jpg
05:48 AM rue_mohr: this is the torture test!
05:50 AM rue_mohr: I didn't manually count that 57, but its trace is pretty messed up
05:51 AM rue_mohr: its rejecting about 212 bits of noise to make that
05:51 AM rue_mohr: ditching profile 193 becasue toothcount is less than 5!
05:51 AM rue_mohr: ditching profile 194 becasue its smaller than 15 pixzels!
05:51 AM rue_mohr: ditching profile 195 becasue its smaller than 15 pixzels!
05:51 AM rue_mohr: ditching profile 196 becasue its smaller than 15 pixzels!
05:51 AM rue_mohr: ditching profile 197 becasue its smaller than 15 pixzels!
05:51 AM rue_mohr: ditching profile 198 becasue its smaller than 15 pixzels!
06:11 AM rue_mohr: wow, the 57 is right...
06:12 AM rue_mohr: a fourier series on the unrolled teeth profile would help reduce noise on the count
06:12 AM rue_mohr: find the dominant freq and use it for the count
06:13 AM rue_mohr: aandrew, see what you can do about some auto greyscale mechanism to pick up even the inner teeth eh?
06:13 AM rue_mohr: or a different profiler
06:39 AM aandrew: very cool, but what are you doing with polar coordinates
06:41 AM aandrew: yeah the inner teeth are going to be tricky
06:41 AM aandrew: I haven't tried to find multiple gears in an image yet
06:50 AM aandrew: last img
08:39 AM aandrew: huh I found a different way that doesn't involve fitting circles
08:41 AM aandrew: basically you find the gear, fit the circle for the outer dimension (need that anyway for module) and then just AND the gear contour image with a list of circles, find contours for the resulting AND and return the mode of the number of intersections
08:41 AM aandrew: intersections: [2, 10, 20, 18, 22, 31, 28, 30, 29, 29, 28, 28, 28, 29, 31, 41, 45, 47, 52, 58, 56, 58, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 57, 56, 55, 52, 45, 41, 33, 29, 28, 28, 28, 28, 28, 29, 31]
08:42 AM aandrew: (that's going from the outer circle down to circle radius 1)
08:59 AM aandrew: weird, on your picture, the number of intersections is hte right number of teeth
08:59 AM aandrew: on my picture, half of the intersections is the right number of teeth
09:01 AM aandrew: now my pictures are HUGE; 5MP. Yours are small: 0.7MP
09:01 AM aandrew: gonna reduce mine to see what happens
09:03 AM aandrew: yep when I reduce mine to the same size the intersection count is the tooth count, probably because I'm intentionally drawing "wide" lines
09:34 AM aandrew: interestingly enough, your script has different results for me: https://ibb.co/Wp50R3V
03:00 PM rue_mohr: I'm flattening out the teeth, then amplifying them, trimming them above and below the zero mark, reducing it to 1 sample and counting the samples
03:00 PM rue_mohr: it can pick up the inner grears just fine, IF the contour can find them
03:01 PM rue_mohr: its not intersections
03:01 PM rue_mohr: I'm drawing that circle as a ref on what its using
03:02 PM rue_mohr: aandrew, did you try the greyscale or greenscreen code?
03:02 PM rue_mohr: the greyscale is super fudgy with the threashold point
03:03 PM rue_mohr: I'd like to find a way to auto-threadhold
03:12 PM rue_mohr: aandrew, ?
03:15 PM aandrew: no *I* am doing intersections of the teeth with a circle
03:16 PM rue_mohr: I'm not :)
03:16 PM aandrew: I know you are :-)
03:16 PM rue_mohr: I unroll the teeth into an AC waveform
03:16 PM aandrew: opencv also recommended using a polar transform to get a 1d array
03:16 PM rue_mohr: amplify it by 6
03:16 PM aandrew: my brain doesn't understand that
03:16 PM rue_mohr: oh
03:16 PM aandrew: and I'm on a mission right now to try to find **DRY FILM** soldermask
03:16 PM rue_mohr: if you take the path, in cartesian
03:16 PM aandrew: I don't want the UV stuff
03:17 PM rue_mohr: offset the middle to 0,0
03:17 PM rue_mohr: then convert to polar
03:17 PM rue_mohr: the angles will run from 0-360
03:17 PM rue_mohr: the distances will be a "sine wave" with a dc offset
03:17 PM rue_mohr: so I remove the dc offset
03:18 PM rue_mohr: amplify it by 6 to make sure it crosses zero really good
03:18 PM rue_mohr: clip it to +-0.5
03:18 PM Tom_L: wizzards at work
03:18 PM rue_mohr: then I remove seuqntial dups
03:18 PM rue_mohr: so
03:18 PM rue_mohr: ----++++----+++--++++----++++ becomes -+-+-+-+
03:19 PM rue_mohr: then add 0.5 to them ALL meaning I get 0,1,0,1,0,1
03:19 PM rue_mohr: add all the values in the array, and thats the teeth
03:19 PM rue_mohr: look at the really messed up contour and it did count that gears teeth correct!
03:19 PM Tom_L: make a clock with 61 seconds on the 2nd hand
03:20 PM rue_mohr: I'd like to change it up to use a fourier
03:20 PM rue_mohr: I would not need to remove the dc offset OR worry about noise
03:21 PM rue_mohr: even if a tooth was missing, the radial frequency would tell the tooth count
03:22 PM aandrew: hm maybe the dry film soldermask isn't the way, it's still a photographic process after it's laminated
03:22 PM aandrew: I want to just coat the boards and then use the mill to "expose" pads
03:23 PM Tom_L: no UV stuff ehh
03:24 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/boards/USBTiny_Mkii/silkscreen/materials.jpg
03:24 PM * Tom_L bets rue_mohr still hasn't done that
03:25 PM aandrew: well the dry film stuff is UV anyway, it's just not a liquid you spin coat
03:25 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/boards/USBTiny_Mkii/silkscreen/uv_paint.jpg
03:25 PM Tom_L: uv paint
03:25 PM aandrew: I've never silkscreened
03:25 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/boards/USBTiny_Mkii/silkscreen/lettered.jpg
03:25 PM Tom_L: fair
03:26 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/boards/USBTiny_Mkii/silkscreen/text.jpg
03:26 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/boards/USBTiny_Mkii/silkscreen/lid_cutout1.jpg
03:27 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/boards/USBTiny_Mkii/silkscreen/exposure.jpg
03:27 PM Tom_L: you don't really need UV
03:28 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/boards/USBTiny_Mkii/silkscreen/silk_batch.jpg
03:28 PM Tom_L: but for the batch i did
03:28 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/boards/USBTiny_Mkii/silkscreen/silk_batch_cure.jpg
03:29 PM Tom_L: you can smell the ozone when they're on
04:19 PM rue_shop3: the greyscale worked a lot better than the greenscreen
05:51 PM rue_mohr: ok, well
05:51 PM rue_mohr: polprog, you didn't get a camera going did ya?
05:51 PM rue_mohr: you need to be the 3rd voice of reason here
05:54 PM rue_mohr: aandrew, the circle I drew thru the middle of the teeth is the mean amplitude of the teeth
05:54 PM rue_mohr: thats why I dont have an inner circle
08:29 PM rue_mohr: polprog, hang out in #opencv with us! and tom if you want
10:08 PM aandrew: Tom_L: interesting so you silkscreened the text on to the plastic and then "baked" them?