Skip to content

Instantly share code, notes, and snippets.

View j-medland's full-sized avatar

John Medland j-medland

  • Control Software Solutions
  • Manchester, UK
  • X @j_medland
View GitHub Profile
@mmozeiko
mmozeiko / webcam_capture.c
Created August 28, 2019 20:25
Capture webcam device with Media Foundation API
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <stdio.h>
#include <intrin.h>
@ranr01
ranr01 / Exposing raw C++ buffers as NumPy arrays using Pybind11.md
Last active November 27, 2022 19:45
Exposing raw C++ buffers as NumPy arrays using Pybind11

Exposing raw C++ buffers as NumPy arrays using Pybind11

Sometimes you have to work with C++ libraries that use raw pointers and arrays that you need to have access to from python. Indeed, working with C styles arrays is sometimes considered bad practice but many people still do...

The solution here is for the C++ side to provide the raw memory address of the data buffer, and then use numpy's array interface mechanism to create an ndarray that uses this buffer.

This allows the user to view and change elements of the buffers with no copies in a way that is visible to both C++ and Python sides.