Counting, one pipe at a time
Construction sites and steel warehouses handle huge numbers of pipes and beams, and every batch has to be counted. For a long time, the usual way was surprisingly manual: workers marked the end of each pipe with paint and counted them one by one. The pipes are rarely stacked neatly, so it is easy to skip a row, count one twice, or simply lose track halfway. And because each piece of steel is not cheap, a single mistake can mean real money — or a dispute between buyer and seller.
Early in my undergraduate years at Xidian University, our team took this very ordinary problem as our starting point. Could a phone camera do the counting instead?
Turning a photo into a number
The idea behind JiaCaiLiShu (佳材立数) was simple: take a photo of a stack of steel, or choose one from the album, and get the count back in seconds. We built it as a WeChat mini program, because almost everyone on a work site already has WeChat on their phone and nobody would need to install anything new. Each counting result could then be saved as a warehouse record, with the material type, manufacturer, quantity and status, so the number didn’t disappear after the photo was taken.
I worked on two sides of the project: the mini program front end, and the computer vision algorithm behind the count.
On the front end, I built the login page and the photo workflow — taking a picture or picking one from the album, previewing it, and sending it to the server — and helped put together the warehouse pages where users could view and edit their records.

Tuning by trial
The algorithm was where most of the patience went. We used classical image processing with OpenCV rather than a large neural network. For H-beams, the method turns the photo into a black-and-white image, pulls out the vertical edges of each beam, removes the background, and counts what remains. For round pipes, it enhances the edges of each pipe end and then looks for circles.

None of this worked well on the first try. The results depended heavily on small settings — the shape and size of the filters, and how finely the image was processed. For the same photo, some settings counted around 300 pipes and others more than 540. So we tested combination after combination and compared each count with the true number. In one test image with 520 pipes, the best setting landed between 517 and 527. Not perfect, but close — and it took seconds.
Beyond the phone
As the project grew, so did the plan. We started thinking about the whole warehouse, not just a single photo: each batch would get a QR code, and a small patrol robot could move around the yard, read the codes and check the stock on its own. The name of the full system in our proposal reflected that ambition — an integrated system for counting, patrolling and managing building materials.
What came out of it
The project won a First Prize in the Northwest regional round of the China Undergraduate Computer Design Competition in 2022 and a Provincial First Prize in the Shaanxi Challenge Cup in 2023. The mini program was registered as computer software, its interface received a national design patent, and the university’s innovation training program rated it Excellent at its final review.
I’m grateful to my teammates, who turned a small idea into a working product together, and to everyone who helped us along the way.
Looking back, JiaCaiLiShu was where I first saw an algorithm leave the notebook and meet a real problem. The math only mattered because, at the end of it, someone could point a phone at a pile of steel and trust the number on the screen. That feeling — that code can quietly save someone an afternoon of counting — is a big part of why I kept going in computer vision.