Skip to content

Instantly share code, notes, and snippets.

let udpClientListeningController =
Agent.Start(fun inbox ->
let rec loop (runningClients:UdpClient seq) = async {
let! msg = inbox.Receive()
let closeRunningClients () = runningClients |> Seq.iter (fun client -> client.ProtectedClose())
match msg with
| ListenForSearchResponsesAndNotifyAdverts (port, ipAddresses) ->
closeRunningClients ()
let uniAndMulticastUdpClients = seq {
let portIPPairs = ipAddresses |> Seq.zip (seq { yield port })
the hardest part will be identifying where the gels are - if you make the assumption that the gel is vertical in the middle its a bit easier.
Convert all the pixels to grayscale (could use saturation, simple (R+G+B)/3 is probably ok)
First apply an average the pixels over a strip with width of the gel (if this can be higly variable ~ 5 is probably enough)
Now apply a Gaussian filter of width about 5 pixels in the vertical direction (if you get too many bands near each other which shouldn't be there you increase the width of this filter)
band peaks will be roughly where the difference between peaks switches from positive to negative