Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add find_convex_hull using Graham scan #2889

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

arrufat
Copy link
Contributor

@arrufat arrufat commented Nov 10, 2023

So, I know I've not been very active on dlib really...
The thing is, at my current job I am using Zig quite a bit, and therefore, not using dlib as much as I'd like.

However, today I had to compute the convex hull of a set of points at work and checked if an implementation on dlib existed to port it to Zig, but I couldn't find it.

So I coded it in Zig, and now I am back porting it to dlib, as I think it may be useful.

Let me know if you think the stuff in the impl namespace should also be exposed to the users.

@arrufat arrufat force-pushed the add-find-convex-hull branch 3 times, most recently from 7a6a206 to b0db1a5 Compare November 10, 2023 11:57
@arrufat arrufat force-pushed the add-find-convex-hull branch from b0db1a5 to 0861ab9 Compare November 10, 2023 12:04
@pfeatherstone
Copy link
Contributor

Interesting companies are already using Zig even though it hasn't reached 1.0 yet. Do you find there are enough libraries in the Zig ecosystem to be productive ? I'm genuinely interested. I quite like the look of it, but don't fancy rewriting the world.

@arrufat
Copy link
Contributor Author

arrufat commented Nov 11, 2023

@pfeatherstone, well, I did have to rewrite the world, basically. We built a virtual try on for makeup that runs completely on the browser using WebAssembly.
First, I made a version in C++ and Emscripten.
I was using dlib, of course, but there are some functions that implicitly allocate, and couldn't be used for WebAssembly directly. At least I didn't know how to, without modifying them.

Eventually, we got interested in Zig because it has native support for Wasm, and all functions that allocate take an allocator as a parameter. So it's easy to just allocate a bunch of memory from JavaScript, pass it to Zig and create a fixed buffer allocator, and use that as a memory pool. But I had to write everything (some PRs made it into dlib from the C++ version):

It's a nice little language, though.

This reminds me of this Tweet:

Use a library? No. I didn't pick C++ so someone else can just go and do all of the fun stuff.

— Ólafur Waage (@olafurw) April 22, 2023

@pfeatherstone
Copy link
Contributor

Great work! I still think I'll only start paying attention to Zig when there is something like onnxruntime and a good tasking system. Though it looks like Zig supports coroutines so on the latter point, it seems like that's on its way. In general, these days I hate not being productive. So I'm using Python a lot more and if you use it correctly, the performance gap between Python and C can be quite small. And there is a library for anything possibly imaginable in Python. I basically only use C++ for systems programming now.

dlib/geometry/vector.h Outdated Show resolved Hide resolved
dlib/geometry/vector.h Outdated Show resolved Hide resolved
dlib/geometry/vector.h Outdated Show resolved Hide resolved
@davisking
Copy link
Owner

Yeah, this is cool :)

@davisking
Copy link
Owner

And the impl namespace stuff is fine as is :)

Copy link
Contributor Author

@arrufat arrufat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, much nicer, thank you!

@davisking
Copy link
Owner

Thanks, this is great :)

@davisking davisking merged commit b20e974 into davisking:master Nov 13, 2023
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants