1
4
Fork
You've already forked zigcv
4
Zig bindings for OpenCV 4
  • PureBasic 99.1%
  • Zig 0.9%
Find a file
2025年02月03日 13:58:09 -06:00
.github chore(deps): update jetify-com/devbox-install-action action to v0.12.0 ( #55 ) 2025年01月27日 02:27:26 +00:00
examples Set names on the opencv build steps for better output while running 2025年02月03日 13:58:09 -06:00
logo fix img name 2022年09月07日 20:32:43 +01:00
src Add missing ColorConversionCode struct to public interface 2025年02月03日 10:22:23 -06:00
test Update to Zig 0.14.0 and OpenCV 4.11.0 2025年02月02日 19:13:28 -06:00
.gitignore Update to Zig 0.14.0 and OpenCV 4.11.0 2025年02月02日 19:13:28 -06:00
.zigversion Update to Zig 0.14.0 and OpenCV 4.11.0 2025年02月02日 19:13:28 -06:00
build.zig Set names on the opencv build steps for better output while running 2025年02月03日 13:58:09 -06:00
build.zig.zon Update to Zig 0.14.0 and OpenCV 4.11.0 2025年02月02日 19:13:28 -06:00
LICENSE init 2022年08月21日 10:58:38 +01:00
README.md Add todo 2025年02月02日 19:21:58 -06:00

ZigCV

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.

Install

Add to your project's dependencies:

zig fetch --save 'git+https://codeberg.org/glitchcake/zigcv'

Add to your build.zig:

constzigcv=b.dependency("zigcv",.{});exe.root_module.addImport("zigcv",zigcv.module("root"));exe.linkLibrary(zigcv.artifact("zigcv"));

Usage

Once added to your project, you may import and use.

constcv=@import("zigcv");

You can also call C bindings directly via the c struct on the import.

cv.c

Example

Here is a minimal program:

conststd=@import("std");constcv=@import("zigcv");pubfnmain()!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()});}

More Examples

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

Demo

./examples/zig-out/bin/face_detection 0
face detection

Technical restrictions

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.

Todo

  • Get all examples working
  • Fix all commented out tests
  • Add cuda and openvino back

License

MIT

Authors

Ryotaro "Justin" Kimura (a.k.a. ryoppippi)

glitchcake