Skip to content

Commit

Permalink
Update face aligment example
Browse files Browse the repository at this point in the history
  • Loading branch information
arrufat committed May 9, 2024
1 parent c784809 commit 2ead875
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

.dependencies = .{
.zignal = .{
.url = "https://github.com/bfactory-ai/zignal/archive/0776105d88325fbeb42f11e6a99371ace421e20b.tar.gz",
.hash = "12204c77931cfeaa780324506f738baf97c2a95f8c4fccf30a3e1fa8fdbe0f87bb27",
.url = "https://github.com/bfactory-ai/zignal/archive/c784809c4c0eb914694998b5434c25d9efd379b9.tar.gz",
.hash = "1220a6447aee50bedc4ecea70a562ef2833267011878db344661627485cdce756b80",
},
},

Expand Down
10 changes: 6 additions & 4 deletions examples/src/face_alignment.zig
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ pub fn extractAlignedFace(
const angle = std.math.atan2(p.y, p.x);
const scale = @sqrt(p.x * p.x + p.y * p.y);
const center = transform.project(.{ .x = side / 2, .y = side / 2 });
var rotated = try image.rotateFrom(allocator, center.x, center.y, angle);
var rotated: Image(Rgba) = undefined;
try image.rotateFrom(allocator, center, angle, &rotated);
defer rotated.deinit(allocator);

const rect = Rectangle.initCenter(center.x, center.y, side * scale, side * scale);
var crop = try rotated.crop(allocator, rect);
defer crop.deinit(allocator);
crop.resize(out);
var chip: Image(Rgba) = undefined;
try rotated.crop(allocator, rect, &chip);
defer chip.deinit(allocator);
chip.resize(out);
}

pub export fn extract_aligned_face(
Expand Down
2 changes: 0 additions & 2 deletions src/image.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const Rgba = @import("color.zig").Rgba;
const as = @import("meta.zig").as;
const isScalar = @import("meta.zig").isScalar;
const isStruct = @import("meta.zig").isStruct;
const Rectangle = @import("geometry.zig").Rectangle(f32);
const Point2d = @import("point.zig").Point2d(f32);

Expand Down

0 comments on commit 2ead875

Please sign in to comment.