• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    C++
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NumPy ndarray ⇋ OpenCV Mat conversion, that just works.

NumPy ndarray ⇋ OpenCV Mat conversion, that just works.

API

  • class NDArrayConverter: The converter class

  • NDArrayConverter::NDArrayConverter(): Constructor

  • cv::Mat NDArrayConverter::toMat(const PyObject* o): Convert a NumPy ndarray to a cv::Mat.

    • o is the object representing the Python representation of the ndarray.

    • Returns a cv::Mat which is the OpenCV representation of o.

  • PyObject* NDArrayConverter::toNDArray(const cv::Mat& mat): Convert a cv::Mat to a NumPy ndarray.

    • mat is the cv::Mat to convert.

    • Returns a PyObject* that is the Python representation of an ndarray.

Examples

examples.cpp contains

  • An implementation of matrix multiplication mul() that takes two ndarray objects, converts them to cv::Mat, multiplies them and returns the result as an ndarray.

  • An image binarization function binarize() that takes an ndarray containing a grayscale image and a threshold value, converts the image to a cv::Mat and thresholds(binarizes) it. It then returns the result as a ndarray.

  • An image display function display(ndarray) that just takes any image as an ndarray object and displays it.

All of these functions are callable from Python.

The plumbing(passing of values to and from Python) is handled by Boost::Python.

test.py contains some testcases that call the aforementioned C++ functions from Python.

Building and testing

After installing Boost::Python and NumPy(maybe the devel package),

$ make
$ make test

This builds and tests the project. Specifically, it builds the core converter in conversion.o and a set of examples in examples.so, which is a Python module containing a few examples of using the converter. test.py contains a test-suite to test (and demonstrate) the converter.

More Repositories

1

orch

Send scribbles from an Android phone to Emacs Org Mode files
Java
54
star
2

zhang-suen-thinning

An OpenCV/C++ implementation of the Zhang-Suen thinning algorithm along with related pre and post processing steps.
C++
43
star
3

exprolution

Evolving expressions using genetic algorithms
Rust
17
star
4

blog-content

Blog contents
Shell
10
star
5

autodiff-rust

Automatic differentiation for Rust
Rust
8
star
6

Genetic-Algorithm-Demo

Python implementation of the Genetic Algorithm demonstration found at http://www.ai-junkie.com/
Python
6
star
7

django-mongo-twt

A Twitter clone using Django and MongoDB to run on OpenShift express
Python
6
star
8

spellsuggest

N-grams based spelling suggestion/correction.
Python
5
star
9

bitrust

Bitcask implementation in Rust
Rust
5
star
10

SevenSegmentDisplay

A simple Python/PyGame 7-segment display library
Python
4
star
11

SmartSweepers

An Artificial Neural Networks application that produces intelligent mineweepers!
Python
3
star
12

phifd

Rust implementation of the phi accrual failure detector
Rust
3
star
13

VoiceXMLDemo

A simple Voice XML app I created for my technical presentation on the topic.
Python
2
star
14

Owl_zwei

A Remote Administration Toolkit for Windows
C++
2
star
15

cloud-server

The server for cloud.js
Python
1
star
16

ascii-delimited-text

ASCII delimited text using UNIT_SEPARATOR and RECORD_SEPARATOR ASCII characters.
C++
1
star
17

mlr

Machine Learning with R
C
1
star
18

nixalbot

Python
1
star
19

PyTiddlyWinks

A Python solution to the Tiddly Winks problem at http://www.ai-junkie.com/
Python
1
star
20

cloud-controller

The controller component of cloud.js
JavaScript
1
star
21

RyDyrect

A redirection web app that uses Google accounts.
Python
1
star
22

cloud.js

The entire cloud.js project
1
star
23

nixal1

nixal test repo
1
star
24

cabl

Going through Jack Crenshaw's "Let's Build A Compiler" series (http://compilers.iecc.com/crenshaw/) using Rust
Rust
1
star
25

nt

A notes application for the command line and beyond written in Rust.
Rust
1
star
26

be-ef

A simple BrainFuck interpreter written in C++
C++
1
star
27

cloud-worker

The worker component of cloud.js
JavaScript
1
star