flowchart TD
Notes -.-> Problem-based
Notes -.-> Observations
Notes --You are here--> Logs[<strong>Logs</strong>]
Notes -.-> Challenges
Notes -.-> Electronics
click Problem-based "https://gist.github.com/wzulfikar/ba2f58d7aeeb3cf53743316f96f91594"
click Observations "https://gist.github.com/wzulfikar/2cff9bcd64ba5f15296e0b57ff402f79"
click Logs "https://gist.github.com/wzulfikar/5ea5779d7f2ea0e27809e94e7904f93d"
click Challenges "https://gist.github.com/wzulfikar/7d5e9426d1c7efc3ceeabb29adb2f4fd"
click Electronics "https://gist.github.com/wzulfikar/16c3b5f10b8f28d8b0e325d03c948d1c"
Problem-based · Observations · Logs · Challenges · Electronics
Log #2 ·
facegrep
– my first Rust program 🚀Last week (Nov 4, 2022) I wrote my first Rust program, facegrep. It's a command line program that detects a face from an image:
facegrep assets/test/scientists.jpg
facegrep assets/test/scientists.jpg --json | jq
bbox
andscore
) in json formatScreen.Recording.2022-11-13.at.11.42.59.mov
▲▼▲
Here's how I got the idea.
I was checking twitter and saw a tweet from @levelsio:
and I thought, "maybe I can do it in Rust? Maybe someone has done the algorithm and I only need to port it to Rust?". After a quick search, I found about Rustface which fits the bill: it detects face, doesn't require GPU, no external dependencies (eg. dlib, opencv). In fact, it's a port of C++ library Seetaface which is a face recognition engine.
I started digging Rustface codebase and felt like I'am profiting from my learning: I know where to start my digging (I started from
src/lib.rs
), how the type system works, and most importantly I wasn't afraid of looking at the codes. The codebase was modular so I know it's not going to be heavy work to just wrap the library in a command line.I used examples/image_demo.rs as starting point. It detects faces from the test image and draw red boxes on each face, so I only need to:
You'll see the final code in main.rs file of the facegrep repo. As you may have noticed, I didn't actually do a lot of work. It was mostly reorganizing the existing code to fit my need. Nevertheless, it was a good exercise to practice what I learnt.
Yes, definitely. I was able to pick random repository (ie. Rustface) and figure out what it does. Rust codebase is no longer something scary to look at.
Yes, I should. From this exercise, I've seen that the knowledge I gained from the resources (see Log #1) has materialized easily in real use case.
That's it! I think I'm on the right path. Looking forward to learning more Rust 🦀
▲▼▲