https://github.com/wasmvision/go-wasmcv
Go bindings for wasmCV computer vision interfaces using WebAssembly. This package is generated.
https://github.com/wasmvision/go-wasmcv
computer-vision golang opencv tinygo wasi wasm wasmcv
Last synced: 28 days ago
JSON representation
Go bindings for wasmCV computer vision interfaces using WebAssembly. This package is generated.
- Host: GitHub
- URL: https://github.com/wasmvision/go-wasmcv
- Owner: wasmvision
- License: other
- Created: 2024-09-16T13:58:31.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-01-31T17:14:31.000Z (3 months ago)
- Last Synced: 2025-03-22T07:22:57.699Z (about 1 month ago)
- Topics: computer-vision, golang, opencv, tinygo, wasi, wasm, wasmcv
- Language: Assembly
- Homepage: http://wasmcv.org
- Size: 115 KB
- Stars: 6
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-tinygo - wasmCV - Go bindings for wasmCV computer vision interfaces using WebAssembly. (WebAssembly / WASI and WASM Unknown)
README
# wasmCV
Generated Go bindings for wasmCV WebAssembly interfaces to computer vision systems.
See https://github.com/wasmvision/wasmcv for information about wasmCV.
## How to use
This example Go module exports a `process()` function to the WASM host application. When the host calls the processor, it passes in the wasmCV image `Mat` to be processed. The wasmCV module then calls functions on that `Mat` which are handled by the host application, by calling OpenCV to actually perform the operations.
```go
package mainimport (
"github.com/hybridgroup/mechanoid/convert"
"wasmcv.org/wasm/cv/mat"
)//go:wasmimport hosted println
func println(ptr, size uint32)//export process
func process(image mat.Mat) mat.Mat {
println(convert.StringToWasmPtr("Cols: " +
convert.IntToString(int(image.Cols())) +
" Rows: " +
convert.IntToString(int(image.Rows())) +
" Type: " +
convert.IntToString(int(image.Mattype()))))return image
}
```Install the `wasmcv` package into your Go package:
```shell
go get wasmcv.org/wasm/cv
```You can then compile this module using the TinyGo compiler.
```shell
tinygo build -o processor.wasm -target=wasm-unknown processor.go
```Note that the `wasm-unknown` target can be used with wasmCV to produce very lightweight guest modules. The example above compiles to around 31k, including debug information.
```shell
-rwxrwxr-x 1 ron ron 31248 sep 11 11:00 processor.wasm
```