10 ms·
How many flies are in my apartment?
- aetherspawn 5y agoThis would be an interesting thing to prove with OpenCV
- mschuster91 5y agoFlies are small... you'd need a lot of light, multiple angles and good cameras/lenses to decently illuminate the flies, which has the problem that all the light will only attract more flies.
- nly 5y agoIs this really true? I mean we've had tech like Hawk-Eye[0] for a couple of decades now. Surely we cameras good enough for fly tracking technology in 2021? [0] https://en.wikipedia.org/wiki/Hawk-Eye https://en.wikipedia.org/wiki/Hawk-Eye
- yarcob 5y agoThat camera system tracks a single, largish object in perfect lighting. I think the biggest problem with insect tracking is focus: They are so small that they can only be recognized if they are perfectly in focus, so you probably can't track them in 3D volumes. Maybe you could track them with clever lighting tricks. Eg. illuminate room with very bright light coming from the side, with a black wall, so that mosquitos show up as bright spots in the video.
- aetherspawn 5y agoI think it would be fine if you tracked only the flies that entered or exited through the small hole in the wall, ie not tracking the whole room just a tiny corridor. So yes, you know the delta-fly(er) but not the number of flies.
- anyonecancode 5y agoAnd if there were a small door over the hole, that opened only to allow fast moving flies to go through it from one direction and slow moving flies to go through it in the other...
- pharmakom 5y agoIs it better to leave windows open so flies can escape or closed so they never come in?
- codetrotter 5y agoOpen windows for air, but have a finely masked net covering the opening so insects don’t get in.
- purplecats 5y agoNot sure that answered the question properly
- nsomaru 5y agoit makes the question not exist any more, same thing.
- fmax30 5y agoThis is the norm in the south asian country I come from. But ever since I moved to the EU, there have been no nets, then again there are noticeably fewer flies here too.
- AlgorithmicTime 5y agoAlso the norm in the US. All my windows have screens built in.
- masklinn 5y agoAlso less mosquitoes, and the drier air makes airflow somewhat less of a living requirement: iirc screen doors are also ubiquitous in the (humid and hot) US south, much less so in the north. window and door screens do absolutely exist in europe, but they’re definitely uncommon.
- TeMPOraL 5y agoIt's becoming increasingly common where I live (Poland). We've installed nets in our last apartment, and the current one came with them already in place. There may not be that many flies in the EU as there are in South Asia, but there's enough of them to be annoying. Then there are mosquitoes, moths, wasps, bees - and the very bugs I've been installing these nets against - hornets. Before the net, we'd get 3-5 hornet visits per season. Running around the house late at night with an improvised flamethrower got tiring very quickly.
- dmitriid 5y agoThis sounds like the "how many balls can fit in a bus" interview question, but somehow more entertaining. Possibly because it addresses a real-world situation.
- Tempest1981 5y agoLooking forward to this showing up on my next interview...
- kzrdude 5y agoI tried showing the flies using matplotlib.animation.FuncAnimation in a notebook, animating even 1000 frames is slow and it warns the animation becomes too large. Maybe there's a better way to do it? Preferably in a notebook interface.
- immmmmm 5y agopyqtgraph is a nice matplotlib replacement when speed matters, but doesn't work in a notebook
- kzrdude 5y agoI ended up writing some very rudimentary HTML canvas + javascript drawing code into the notebook and for my purposes it's fast and does the job. Just to note to others, that this is a possibility within a Jupyter notebook. One obvious benefit is that it can start rendering "live" and continuously and doesn't have to generate the whole animation before starting to show it.
- maverickleopard 5y agoHow exactly do you that and can you interop with python?
- kzrdude 5y agoI just used this in the Jupyter notebook (toldya it was very simple, written today :). It interoperates with python by being passed data to the draw call. Usage like: c = Canvas(); c.draw(xs); xs is a numpy array of shape (N, 2), the points to draw on the canvas. It's not fancy. But it drew animations faster than matplotlib (I ran this for thousands of frames, just to watch the simulation). import IPython.display as ipydisplay import json import numpy as np class Canvas: def __init__(self, canvas_id=None, width=500, height=500): self.display_id = None self._canvas_id = canvas_id or ('canvas_' + str(np.random.randint(0, 10000))) display(ipydisplay.HTML(f""" <canvas id="{self._canvas_id}" width="{width}" height="{height}" style="border:1px solid #d3d3d3;"> Your browser does not support the HTML5 canvas tag.</canvas> """)) def draw(self, xs, world_size): xs_string = json.dumps(xs.tolist()) obj = ipydisplay.HTML(f""" <script> var c = document.getElementById("{self._canvas_id}"); var ctx = c.getContext("2d"); var xs = {xs_string}; var size = {world_size}; ctx.clearRect(0, 0, c.width, c.height); var scale = c.width / size; for (let i = 0; i < xs.length; i++) {{ ctx.fillRect(xs[i][0] * scale, c.height - xs[i][1] * scale, 2, 2) }} </script> """) if self.display_id: ipydisplay.update_display(obj, display_id=self.display_id) return self.display_id self.display_id = display(obj, display_id=True).display_id
- OJFord 5y agoBased on my experience, those flies need to be less like jittery dots, and more like kamikaze pilots, hurtling themselves from one side of the simulation to the other, repeatedly.
- knbknb 5y agoIn the NetLogo Models Library there are quite a few similar models already, "Moths", "Ants", "Gaslab Maxwells Demon", and more variations (adaptive/nonadaptive, single/flocking etc) http://ccl.northwestern.edu/netlogo/docs/ http://ccl.northwestern.edu/netlogo/docs/
- jdowner 5y agoMaxwell's kinetic theory of flies?
- StavrosK 5y agoYes, the path each one takes can very accurately be called a "random fly".
- ahartmetz 5y agoFrom experience: about 5x as many as you think Story: I was living in a large flatshare that was plagued by flies from nearby horse stables. We were organizing a decent sized party (maybe 40 guests). In the afternoon, we had 15ish items of food that needed to be stored for a few hours until guests arrived. At first we considered covering all the food (creating work and waste of aluminum or plastic foil), then I had the idea to kill all the flies in that room and close the door. We saw about four flies. In the end we killed about 20 before we declared the situation good enough. I don't recall if there was a last fly that we eventually killed, or that we eventually gave up on killing. It took half an hour or so.
- solarkraft 5y agoIf you’re already interested in flies, check out how they behave in nature. They can be quite territorial about their leaf or stick and fights between these agile little beasts are fascinating to watch (extremely quickly orbiting each other).
- lolc 5y agoAll these models ignore how insects actually zero in on a smell. For a fly outside, the source of the smell is the gap in the window. What looks like random direction changes is actually a search pattern for that source.
- teddyh 5y agoSlightly related: Anemotaxis https://www.youtube.com/watch?v=hIqmIQbQkW8 https://www.youtube.com/watch?v=hIqmIQbQkW8
- lolc 5y agoThanks, that was actually the screensaver I was thinking of when I wrote my comment :-) But I don't actually know whether flies do use this pattern.
- btbuildem 5y agoVery good point -- and that's why they find their way inside so easily, but look really dumb trying to find their way out. Same principle behind a DIY fruit fly trap (glass of juice with a plastic cover with a few holes poked in it).
- josefresco 5y agoThen why only two?
- pelasaco 5y agoYou are right. Even though it is probably a great exercise to improve your skills as data scientists, I'm afraid that without understanding how the insects actually "work/think", it is nothing more than garbage in, garbage out (GIGO).
- TchoBeer 5y agoI don't know how intentional it was but that's a great roast on data scientists.
- m12k 5y agoIn my statistics class we were taught a technique for estimating the number of flies in a barn. You capture a fixed size sample of flies, e.g. 100, and give them each a little white dot on the back, then release them all back in the barn. Leave them to mingle for a while, then capture another fixed number of flies, e.g. 100. If 5 of them have a white dot on them, then you estimate that the 100 flies you captured originally and marked make up 5% of the total population, meaning your estimate of the total population must be 2000 flies.
- OnlyMortal 5y agoIf they’re randomly distributed, that makes sense.
- mkreis 5y agoReminds me of how the Allies estimated the production capacity of German tanks during WW2: https://medium.com/dataseries/how-data-science-gave-the-allied-forces-an-edge-in-world-war-ii-7fe92a74add5 https://medium.com/dataseries/how-data-science-gave-the-alli...
- pelasaco 5y agoThank you! Great read, indeed!
- thearn4 5y agoGreat read! In comparison, I have to wonder why the "intelligence estimates" were so bad/severe over estimates.
- atatatat 5y agolol spend more taxes on missiles, pleb.
- bena 5y agoMy intuition says counter-intelligence. The Allies were using intercepted communications, visual confirmation, captured sources, etc. You can send fake reports if you think the other side is listening. You can move or mock material if you think the other side is watching. You can feed false information if you are captured.
- madethemcry 5y agoThis reminds me of the flocking boids algorithm by Craig Reynolds [0] which is based on three principles: + separation: steer to avoid crowding local flockmates + alignment: steer towards the average heading of local flockmates + cohesion: steer to move towards the average position (center of mass) of local flockmates The algorithm was used to animate the bat swarms in Batman Returns (1992) [1]. I love this algorithm, it's easy to develop and experiment with and the results feel beautiful & natural. [0]: https://www.red3d.com/cwr/boids/ [1]: https://en.wikipedia.org/wiki/Boids
- mannykannot 5y agoLévy flight foraging hypothesis: https://en.wikipedia.org/wiki/L%C3%A9vy_flight_foraging_hypothesis https://en.wikipedia.org/wiki/L%C3%A9vy_flight_foraging_hypo... The scent-tracking mode used here seems to be a sort of variant, in which the long legs are not chosen randomly. WRT the insect density decreasing as some fly away: in reality, others will arrive at approximately the same rate, keeping the density approximately the same, so it is probaby more realistic to put a box around the simulation, e.g. by reversing the direction of those that have moved away to the point that they would be several time-slices away from entering the window even if they flew back in a straight line.
- NorwegianDude 5y agoI was really confused about where this was going when I started reading as I thought the title sad files, not flies...
- ernst_mulder 5y agoSame here. Turns out to be a staggering number of files actually, much larger than the number of flies.
- qwertox 5y agoNext step is to set up a grid of ESP32s with MEMS microphones and a FFT routine, stream that data to a server and apply some neural network to get to know the real amount of flies by tracking them individually. Then compare this to the model, and keep improving it until it fits.
- mLuby 5y agoI want a mosquito-killing turret [1] that you could put in your bedroom and sleep in peace. Turns out one exists [2] (in theory—no commercial product a decade later), but the one I was thinking of would use microphones rather than cameras [3] to detect the bloody suckers. Thing is, I can't find any prior research or even hints that people have considered this approach. (The closest I can find is an app [4] that detects a mosquito from ≤10cm away.) Here are some of my guesses for why it's not been done: A. Maybe it's too difficult to distinguish mosquito buzz/whine from background noise, even when filtering in only known mosquito frequencies (~400Hz [5]). B. Maybe it's too slow to sweep a room with a directional mic that's focused enough to detect mosquito sounds? (Say the turret in one ceiling corner of a 12x12x8ft room.) C. Maybe directional mics don't work well for all sound in their cone and so need to be able to "focus" at different distances (by dynamically changing the parabolic dish's shape), thereby increasing the room sweep time? D. Maybe the parabolic dish needs to be so big that it just looks ridiculous? E. Maybe all of this is possible but the type of microphone is so expensive that it's worth pursuing commercially? I'm curious what you all think about this. It'd be an interesting thing to try making—who hasn't wanted to make a death ray while simultaneously furthering the fight against humanity's deadliest enemy? [6] See also this research paper: Detecting Insect Flight Sounds in the Field: Implications for Acoustical Counting of Mosquitoes [7] (I'm pretty sure this is not directional—they hung an attractant 15cm from the mic and I don't see any dish.) [1]: https://www.youtube.com/watch?v=BKm8FolQ7jw https://www.youtube.com/watch?v=BKm8FolQ7jw [2]: https://www.ted.com/talks/nathan_myhrvold_could_this_laser_zap_malaria#t-816312 https://www.ted.com/talks/nathan_myhrvold_could_this_laser_z... [3]: I don't think cameras are well-suited to detecting something so small. The "photonic fence" from the TED talk only kinda works by adding a white background behind the bugs so it's really easy for the camera to detect them—not that practical in a normal room. [4]: https://www.theguardian.com/science/2018/mar/29/mosquito-early-warning-app-detects-the-insects-from-their-buzz https://www.theguardian.com/science/2018/mar/29/mosquito-ear... [5]: https://www.youtube.com/watch?v=Rcm3rPz_Q94&t=127 https://www.youtube.com/watch?v=Rcm3rPz_Q94&t=127 [6]: https://mysteriousuniverse.org/2014/08/why-mosquitos-are-humanitys-deadliest-enemy/ https://mysteriousuniverse.org/2014/08/why-mosquitos-are-hum... [7]: https://pdfs.semanticscholar.org/a0bf/4fcd478b6214759046a739bdab03586059df.pdf https://pdfs.semanticscholar.org/a0bf/4fcd478b6214759046a739...
- 0xBA5ED 5y agoA tip if you have an annoying fly in your house that's hard to swat. Turn off all the lights except the bathroom. In a few minutes it'll fly in. Close the door and it's mano-a-mano.
- Tempest1981 5y agoAlso works with a computer display in a dark room. Until you hit the display going mano-a-mano.
- pjerem 5y agoWorks well with mosquitoes too. I just let them do whatever they want in the bathroom once the door is closed. However I would admit that switching lights on at 3AM and deliberately opening all the doors for the light to be seen is not something my family appreciate. But, at least, I’m their hero.
- crispyambulance 5y agoWell, there was at least one startup that addressed the issue of flies/mosquitoes indoors. Bzigo. https://bzigo.com/ https://bzigo.com/ It's a machine vision system that tracks mosquitoes and aims a laser pointer on them (so you can swat them). Don't know if this company still exists. It was/is an Israeli start-up and apparently not an April Fool's day joke. It seems to me the best solution is to use screens, but that is not as sexy as machine vision.
- jdavis703 5y ago> It seems to me the best solution is to use screens, but that is not as sexy as machine vision. There are lots of windows that don’t work with screens. For example some windows are pushed out as opposed to up, and the latching mechanism would conflict with the screen.
- mig39 5y agoReally interesting work. I love the different models of how a fly moves around. This jumped out at me, though: >If we take a look at the animation now, we can see the flies look slightly more realistic (if not still a bit spazzy) Is "spazzy" a word that's used in different regional dialects of English as a term to just mean jittery? In most of the places I've lived, it's an offensive word.
- laputan_machine 5y agoUh oh, sounds like they need to be sent to the gulags for re-education, then. Report the site to GitHub and I'm sure they'll scrub this horrifying prose.
- mig39 5y agohuh? It was a legit question. I've lived in a lot of places with different dialects of English. Where a term in one place is seen as harmless, but means something completely different in another. In this case, I've never heard "spazzy" used other than as an offensive term. Your reaction seems more Reddit than HN, though. So you have that going for you.
- sp332 5y agoI remember thinking that the UK has a much more negative connotation for "spastic" than the US. In the US it's still pejorative but something you could say casually.
- rossdavidh 5y ago"Spazzy" or "spastic" is not especially offensive in the US, although I suppose given our ever-escalating sensitivity it soon will be. It mostly just implies "given to spasms", which I suppose is the origin. More generally, it implies not terribly well-organized in behavior. A person might say it of their own behavior without meaning anything exceptionally bad.
- morelisp 5y agoIt has been offensive in the US since the 90s. It just gets used anyway anytime there's some "anti-PC" movement, along with "gay" to mean "bad", the r word, sudden spikes in the use of "niggardly", and so on. Like those, its offensiveness does not come from offense taken by the person/thing it is proximately describing.
- tenderfault 5y ago> The perfect question for a Sunday afternoon when you have no friends I have one, we both read your post and we just befriended you without authorization
- twphysicsphd99 5y agovery cool it would be fun to add static attractors -ie fruit to see how it biases the trajectories
- maverickleopard 5y agoAre you trolling or did you not read far enough?
- deleted 5y ago[deleted]
- jjfine 5y agogo to the store and buy a removable screen dude. i got one in chinatown for like 5 bucks.
- pacman2 5y agoA fly is unlikely to fly randomly. https://en.wikipedia.org/wiki/L%C3%A9vy_flight https://en.wikipedia.org/wiki/L%C3%A9vy_flight
- Lio 5y agoFor some reason this reminds me of the Damien Hirst art work A Thousand Years[1]. Next step for me would be to turn the attractor into an Insectecuter. 1. https://damienhirst.com/a-thousand-years https://damienhirst.com/a-thousand-years
- mhb 5y agoFly salt guns: https://www.bugasalt.com/ https://www.bugasalt.com/
- mrlonglong 5y agoThere are two hanging around and I've named them after people I hate. I keep the windows open in the hope they'll just fly off.