diff options
author | Anthony Wang | 2024-08-04 19:48:42 -0500 |
---|---|---|
committer | Anthony Wang | 2024-08-04 19:48:42 -0500 |
commit | f72e85db9c1577f2f4f331cdf04ae79874f74c8e (patch) | |
tree | 9cce93b26077cbdf881171260a1da4525b37af2e | |
parent | 449f7041214bf3488c33127de88350bc784cfd03 (diff) |
Extreme Epilepsend
-rw-r--r-- | content/posts/bad-apple-animated-qr-code.md | 2 | ||||
-rw-r--r-- | content/posts/extreme-epilepsend.md | 28 | ||||
-rw-r--r-- | static/vid/monitor.mp4 | bin | 0 -> 3247634 bytes |
3 files changed, 29 insertions, 1 deletions
diff --git a/content/posts/bad-apple-animated-qr-code.md b/content/posts/bad-apple-animated-qr-code.md index 5c9a4e9..1bf1dde 100644 --- a/content/posts/bad-apple-animated-qr-code.md +++ b/content/posts/bad-apple-animated-qr-code.md @@ -3,7 +3,7 @@ title: "Bad Apple!! But It's An Animated QR Code of Bad Apple!!" date: 2024-05-15T00:14:48-04:00 description: "Final project for the MIT 6.8301 Computer Vision class" type: "post" -tags: ["computer-vision", "algorithms", "anime", "kevin", "mit"] +tags: ["computer-vision", "algorithms", "anime", "kevin", "mit", "epilepsend"] --- diff --git a/content/posts/extreme-epilepsend.md b/content/posts/extreme-epilepsend.md new file mode 100644 index 0000000..ea174ef --- /dev/null +++ b/content/posts/extreme-epilepsend.md @@ -0,0 +1,28 @@ +--- +title: "Extreme Epilepsend" +date: 2024-08-04T18:58:07-05:00 +description: "Throwing more compute at Epilepsend, because that's obviously how you solve all problems" +type: "post" +tags: ["computer-vision", "multiprocessing", "epilepsend", "video"] +--- + + +Kevin and I created [Epilepsend](/posts/bad-apple-animated-qr-code/) for an MIT final project a few months ago, and the thing about final projects is the deadline is always a day too early, no matter how early you start. Our project couldn't even break the 0.3 mbps barrier until two days before the deadline! Fortunately, I discovered that an earlier commit had cropped the camera feed to avoid distortion, at the cost of significantly reducing the camera acuity. [Removing that code](https://git.exozy.me/k/6.8301-Project/commit/a1d77a466dcc694f0101d2588529ada8c858ed94) boosted our bandwidth by an order of magnitude. So I've been wondering: Are there any other bandwidth-boosting tweaks out there that we just didn't have time to try? + +I initially wanted Epilepsend to be lightweight enough to run on my laptop, but it has a bad habit of scorching my CPU. Sure, it can hit 2 mbps for a few seconds, and then the temperature skyrockets and Epilepsend starts lagging behind the camera stream. For the *Bad Apple!!* demo, I had to use a 32-thread Ryzen 3950X CPU instead. More compute never hurts, so I recently tried some tweaks to fully embrace the more powerful CPU. + +My first idea was actually to disable one of my earlier bandwidth tweaks. I've been testing Epilepsend using a 60 Hz monitor with a 30 FPS video, and it turns out that monitors are really slow. Monitor says 60 Hz? Yeah, it'll take 1/60 seconds to fully display a frame. You see this in action in this video of a 30 FPS video on my monitor: + +{{< video "/vid/monitor.mp4" >}} + +The monitor only shows the entire complete frame for 1/60 seconds! Consequently, I can't run the camera (my phone) for the decoder at 30 Hz since it easily desyncs from the monitor, and instead have to run at 60 Hz and use every other frame. Decoding a frame is CPU-intensive, so if the current frame decodes successfully, the next frame is skipped, and otherwise, the next frame is skipped with half probability. This helps decrease the CPU load and quickly recover from desyncs. + +And if you have a beefy CPU and cooling, it's completely useless. Instead, just try to decode every frame. Easy as that. + +Another conceptually simple tweak I tried was putting the Reed-Solomon decoding in its own thread. Welp, Python's GIL decided to ruin my day so I had to use both the `threading` and `multiprocessing` modules, but it worked in the end. CPU usage went up by a factor of three! Hooray! + +On the physical side of things, I built a structure out of random books to hold my phone so my arms don't get sore. I also tried placing a large foam board, held in place by a plush unicorn, behind the camera and turning up the encoder's screen brightness to avoid stuff from the background appearing as reflections in the encoder's screen. + +Sadly, these tweaks weren't magic. The bandwidth went up to 2.242 mbps which is pretty good, but only 7% more than my previous record. I did manage to reduce the amount of time to decode *Bad Apple!!* in *Bad Apple!!* from nearly 180 seconds to 70 seconds. In the end, my biggest obstacle was that my phone also has a bad habit of boiling up too, so I had to sometimes stick it in the refrigerator to cool it off quickly between tests. + +Maybe someday I'll buy an igloo and try again. I'm sure 4 mbps is within reach, with enough ingenuity and ice! diff --git a/static/vid/monitor.mp4 b/static/vid/monitor.mp4 Binary files differnew file mode 100644 index 0000000..d07f189 --- /dev/null +++ b/static/vid/monitor.mp4 |