No description
Find a file
2023-06-27 15:23:25 -05:00
examples Minor cleanup and a new webdemo 2023-06-21 19:09:55 -05:00
src Add task for documentation generation 2023-06-27 13:48:13 -05:00
tests Initial commit of OpenCV binding 2023-06-05 11:52:57 -05:00
.gitignore Initial commit of OpenCV binding 2023-06-05 11:52:57 -05:00
LICENSE Initial commit 2023-06-04 14:45:36 -05:00
mvb.nimble Add task for documentation generation 2023-06-27 13:48:13 -05:00
nim.cfg Initial commit of OpenCV binding 2023-06-05 11:52:57 -05:00
README.md Small style cleanup of example code 2023-06-27 15:23:25 -05:00

mvb

Minimum Viable Bindings to OpenCV for Nim

These are new bindings compatible with the latest version of OpenCV. (4.7.x as of today.) MVB stands for "Minimum Viable Bindings" and/or "Machine Vision Bindings" (🖥️👁️📒). The library is minimal at the moment, but it can read and display from the camera, and read/write and encode files. These are the absolute minimum features required for a viable OpenCV binding. The plan is to keep improving the bindings until MVB is an acronym for "Maximum Viable Bindings".

Installation

Prerequisite: Install OpenCV

Linux (Debian/Ubuntu)

sudo apt install libopencv-dev

macOS

homebrew install opencv

Windows

choco install opencv

Install MVB

nimble install mvb

Demo

First, check out the code

git clone https://github.com/tapsterbot/mvb-opencv.git
cd mvb-opencv

Then run this demo... (Using OpenCV's built-in GUI)

nimble demo

Or this demo... (Viewable in any browser at http://127.0.0.1:8080/

nimble webdemo

Interactive Demo

Interactive Nim (INim) is required

nimble install inim

Read from camera

nimble i

nim> import mvb
nim> var frame: Mat
nim> let cap = newVideoCapture()
nim> for i in 1 .. 100:
....   cap.read frame
....   imshow "MVB - OpenCV Demo", frame
....   waitKey(5)
....
nim>

Read from file

nimble i

nim> import mvb
nim> const imagePath = "tests/img/nim-logo.png"
nim> var img = imread imagePath
nim> imshow "MVB - OpenCV Demo", img
nim> waitKey(0)
nim>

Write to file

nimble i

nim> import os
nim> import mvb
nim> const imagePath = "tests/img/nim-logo.png"
nim> const imageResultPath = "tests/img/nim-logo.test.png"
nim> var img = imread imagePath
nim>
nim> fileExists imageResultPath
false == type bool
nim>
nim> imwrite imageResultPath, img
nim>
nim> fileExists imageResultPath
true == type bool
nim>