week 13apr 30, 2025
This week, I finally tested out the project with six webcams. I was able to obtain 3 webcams from Professor Todd Bryant, and I purchased 3 additional webcams online, for a total of 6. I also bought 2 USB hubs, because my laptop doesn’t have USB 3 ports. The USB hubs have 4 USB 3 ports each, and connect via USB-C to my laptop. I connected everything to my laptop and tried running Blobby with six webcams. Unfortunately, some of the webcams crashed immediately, with not even an error being thrown. After doing some research online, I think the cause is that BlazePose uses an asynchronous function to do live video processing. What this means is that frames from the webcam are continually loaded into BlazePose, without waiting for the results. Once the model outputs the segmentation masks, they are forwarded to a separate callback function which does the processing. If the callback function doesn’t process the segmentation masks fast enough, BlazePose gets overloaded with frames, and crashes. The purpose of using an asynchronous function in the first place is to lower the processing delay between individual frames, because there is always a segmentation mask ‘on deck.’ However, the lack of guard rails around the system made it dangerous. As a quick fix, I changed the model to ‘image mode’ which means the model will wait for the resulting segmentation mask to be processed before taking in another frame from the webcam. This change stopped webcams from crashing, but it quickly became clear that six webcams was too much for my laptop to handle at the same time. The blob feeds were choppy and slow—it was clear that I needed to adapt my project so that webcams could be spread among multiple machines.
Luckily, adding a second laptop to the project was easy due to the networking infrastructure. Because there’s a WebSocket server that handles all the communication between front-end and back-end, all I have to do is expose the WebSocket server so that a secondary laptop can communicate with it. I changed my WebSocket server code to be accessible through the network, instead of just localhost. Then, I used ipconfig to find the IP address of my main laptop, and I pasted it into the configuration file, with the label WEBSOCKET_HOST. The second laptop uses the IP address to connect to the WebSocket server over WiFi. It can then send its blobs to the WebSocket server which forwards them to the website hosted on the first laptop - so seamless! I tested out the system, and I found that the latency wasn’t even noticeable, probably because the computers are on the same WiFi network so the signal doesn’t have to travel far. Overall, I am very pleased with the system, and if anything, the ease of implementation validates my networking infrastructure.