The ZigCV library provides Zig language bindings for the OpenCV 4 computer vision library.
The ZigCV library supports the same nominated version of zig as Mach and the zig-gamedev libraries.
The ZigCV library currently supports OpenCV v4.11.0.
It uses GoCV 0.40.0 for its C bindings to OpenCV.
Caution
Under development. The Zig APIs may be missing or change.
Add to your project's dependencies:
zig fetch --save 'git+https://codeberg.org/glitchcake/zigcv'Add to your build.zig:
const zigcv = b.dependency("zigcv", .{});
exe.root_module.addImport("zigcv", zigcv.module("root"));
exe.linkLibrary(zigcv.artifact("zigcv"));Once added to your project, you may import and use.
const cv = @import("zigcv");You can also call C bindings directly via the c struct on the import.
cv.cHere is a minimal program:
const std = @import("std");
const cv = @import("zigcv");
pub fn main() !void {
std.debug.print("version via zig binding:\t{s}\n", .{cv.openCVVersion()});
std.debug.print("version via c api directly:\t{s}\n", .{cv.c.openCVVersion()});
}There are a handful of sample programs in the examples/ directory.
You can build them by running zig build there:
cd examples && zig build; popd; ./examples/zig-out/bin/hello./examples/zig-out/bin/face_detection 0
Due to zig being a relatively new language it does not have full C ABI support at the moment. For use that mainly means we can't use any functions that return structs that are less than 16 bytes large on x86, and passing structs to any functions may cause memory error on arm.
- Get all examples working
- Fix all commented out tests
- Add cuda and openvino back
MIT
Ryotaro "Justin" Kimura (a.k.a. ryoppippi)

