Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use OpenCV pybind tools (cv2.cpp & gen2.py ...) to generate a python binding use OpenCV Mat as input parameters.

License

Notifications You must be signed in to change notification settings

TracelessLe/cv2_gen_python_bindings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

6 Commits

Repository files navigation

Introduction

Use OpenCV pybind tools (cv2.cpp & gen2.py ...) to generate a python binding use OpenCV Mat as input parameters.

issueBadge starBadge repoSize lastCommit

Guide

  1. python3 gen2.py build
  2. generate python binding
g++ -shared -rdynamic -g -O3 -Wall -fPIC \
qy.cpp src/qymodule.cpp \
-DMODULE_STR=qy -DMODULE_PREFIX=pyopencv \
-DNDEBUG -DPY_MAJOR_VERSION=3 \
`pkg-config --cflags --libs opencv` \
`/root/miniconda3/envs/pytorch1.6/bin/python3.7m-config --includes --ldflags` \
-I . -I/root/miniconda3/envs/pytorch1.6/lib/python3.7/site-packages/numpy/core/include \
-L`/root/miniconda3/envs/pytorch1.6/bin/python3.7m-config --exec-prefix`/lib \
-Ibuild \
-fno-lto \
-o build/qy.so
  1. python import and use.

Use in Python

import sys
import cv2
#sys.path.append('build')
import qy
im = cv2.imread('holes.jpg', cv2.IMREAD_GRAYSCALE)
imfilled = im.copy()
qy.fillHoles(imfilled)
filters = qy.Filters() 
imedge = filters.edge(im)
cv2.imwrite("Originalimage.png", im)
cv2.imwrite("PythonModuleFunctionExample.png", imfilled)
cv2.imwrite("PythonModuleClassExample.png", imedge)

holes.jpg

Originalimage.png

PythonModuleFunctionExample.png

PythonModuleClassExample.png

Appreciation

Thanks for spmallick for his inspiring learnopencv.

About

Use OpenCV pybind tools (cv2.cpp & gen2.py ...) to generate a python binding use OpenCV Mat as input parameters.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /