Skip to content
OpenCv NIF Bindings for Erlang/Elixir.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
c_src
config Initial commit Jan 13, 2019
lib Format Jan 14, 2019
test Turns out multi file doesn't work Jan 14, 2019
.formatter.exs
.gitignore Turns out multi file doesn't work Jan 14, 2019
LICENSE Initial commit Jan 13, 2019
Makefile Turns out multi file doesn't work Jan 14, 2019
README.md Added instructions for using the pre-release from GitHub. (#1) Jan 30, 2019
mix.exs Mirror cv::VideoCapture Jan 13, 2019
mix.lock Initial commit Jan 13, 2019

README.md

OpenCv

OpenCv NIF Bindings for Erlang/Elixir.

Current status

Currently almost nothing works. Opening a video device and capturing jpeg frames works currently.

Usage

Capturing a jpeg encoded frame frame can be done by:

Interactive Elixir (1.7.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> {:ok, conn} = OpenCv.new()
{:ok, #Reference<0.1511271170.1095630852.139975>}
iex(2)> {:ok, cap} = OpenCv.VideoCapture.open(conn, '/dev/video0')
{:ok, #Reference<0.1511271170.1095630848.138924>}
iex(3)> true = OpenCv.VideoCapture.is_opened(conn, cap)
true
iex(4)> {:ok, frame} = OpenCv.VideoCapture.read(conn, cap)
{:ok, #Reference<0.1511271170.1095630848.138925>}
iex(5)> jpg = OpenCv.imencode(conn, frame, '.jpg', [])
<<255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 255,
  219, 0, 67, 0, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 4, 3, 2, 2, 2, 2,
  5, 4, 4, 3, ...>>
iex(6)> File.write("img.jpg", jpg)
:ok

Building

This currently supports opencv3 and opencv4. It may support opencv2, but I have not tested. Nerves builds are currently supported given you have a system that has opencv installed. this system has opencv 3 installed. I've only tested build on linux, and it is likely that paths for the Makefile may be wrong.

Installation

To pull in this package directly from GitHub, amend your list of dependencies in mix.exs as follows:

def deps do
  [
    {:open_cv, github: "ConnorRigby/elixir-opencv", branch: "master"}
  ]
end

If available in Hex, the package can be installed by adding open_cv to your list of dependencies in mix.exs:

def deps do
  [
    {:open_cv, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/open_cv.

You can’t perform that action at this time.