Skip to content

Instantly share code, notes, and snippets.

View Xonxt's full-sized avatar

Nikita Kovalenko Xonxt

View GitHub Profile
@Xonxt
Xonxt / main.cpp
Last active February 24, 2023 02:03
Sending a cv::Mat from C++ to a Python script
/*
This requires adding the "include" directory of your Python installation to the include diretories
of your project, e.g., in Visual Studio you'd add `C:\Program Files\Python36\include`.
You also need to add the 'include' directory of your NumPy package, e.g.
`C:\Program Files\PythonXX\Lib\site-packages\numpy\core\include`.
Additionally, you need to link your "python3#.lib" library, e.g. `C:\Program Files\Python3X\libs\python3X.lib`.
*/
// python bindings
@Xonxt
Xonxt / opencv_text_rendering.py
Last active October 6, 2020 20:44
A function, that allows more flexibility when rendering text with OpenCV in Python. You can add text outline, draw a list of strings with just one call, and even align the text block horizontally or vertically relative to an anchor point.
import numpy as np
import cv2
from enum import Enum
class Align(Enum):
LEFT = 0
CENTER = 1
RIGHT = 2
class Valign(Enum):