pybind11

pybind11 “Python is 64-bit, chosen compiler is 32-bit”

元气小坏坏 提交于 2021-02-02 06:45:11
问题 I'm trying to compile pybind11 on a Windows machine that has VisualStudio 2015 installed. I also have python 3.5.3 64bit installed, and cmake 2.8.12. I get the error: CMake Error at tools/FindPythonLibsNew.cmake:122 (message): Python config failure: Python is 64-bit, chosen compiler is 32-bit Call Stack (most recent call first): tools/pybind11Tools.cmake:16 (find_package) CMakeLists.txt:28 (include) I did not "choose" the compiler to be 32-bit, and looking at the CMakeLists.txt, I did not

pybind11 “Python is 64-bit, chosen compiler is 32-bit”

我的未来我决定 提交于 2021-02-02 06:45:08
问题 I'm trying to compile pybind11 on a Windows machine that has VisualStudio 2015 installed. I also have python 3.5.3 64bit installed, and cmake 2.8.12. I get the error: CMake Error at tools/FindPythonLibsNew.cmake:122 (message): Python config failure: Python is 64-bit, chosen compiler is 32-bit Call Stack (most recent call first): tools/pybind11Tools.cmake:16 (find_package) CMakeLists.txt:28 (include) I did not "choose" the compiler to be 32-bit, and looking at the CMakeLists.txt, I did not

difficulties using setuptools to compile extension module

梦想的初衷 提交于 2021-01-29 19:33:50
问题 I am developing a package (module?) designed to be pip-installed. The package contains a C++ extension, wrapped using pybind11, which links to some other libraries. I am able to compile and link the extension libraries manually without issue, however I am unable to configure my setup.py file properly such that the extension module installs when invoking pip3 install my_package . I have been following this code (which is linked to by the pybind11 documentation) to configure my setup.py file,

Why is the color space of the CV::Mat image wrong (GBR instead of RGB or BGR)?

时光总嘲笑我的痴心妄想 提交于 2021-01-28 04:19:17
问题 I have a module in Python which sends an RGB to C++ and there its consumed. The image however, has wrong colorspace, regardless of what I do. That is I tried to convert it to RGB , assuming its still in BGR (although in python its deliberately converted into RGB by doing : return img[:,:,::-1] and visualize the image using matplotlib.) and vice versa, they look the same! This is shown below: Original image: This is the output of the image without any tampering This is the output when the I

Pybind11: Transfer Class Ownership to C++ on Construct

随声附和 提交于 2021-01-27 16:36:54
问题 I'm having an issue where a python class, which is derived from a c++ base class using pybind11, is being immediately destructed (garbage collected). I would like C++ to take ownership of the dynamically allocated object, but I can't seem to make that happen. I've tried keep_alive, passing shared_ptr<> as py::class_ template argument, and py::return_value_policy... nothing is working. I suspect this is just user error. This is a simplification of the real issue I'm having with a much larger

How to invoke Python function as a callback inside C++ thread using pybind11

最后都变了- 提交于 2021-01-21 05:36:47
问题 I designed a C++ system that invokes user defined callbacks from procedure running in a separate thread. Simplified system.hpp looks like this: #pragma once #include <atomic> #include <chrono> #include <functional> #include <thread> class System { public: using Callback = std::function<void(int)>; System(): t_(), cb_(), stop_(true) {} ~System() { stop(); } bool start() { if (t_.joinable()) return false; stop_ = false; t_ = std::thread([this]() { while (!stop_) { std::this_thread::sleep_for

How to invoke Python function as a callback inside C++ thread using pybind11

百般思念 提交于 2021-01-21 05:35:28
问题 I designed a C++ system that invokes user defined callbacks from procedure running in a separate thread. Simplified system.hpp looks like this: #pragma once #include <atomic> #include <chrono> #include <functional> #include <thread> class System { public: using Callback = std::function<void(int)>; System(): t_(), cb_(), stop_(true) {} ~System() { stop(); } bool start() { if (t_.joinable()) return false; stop_ = false; t_ = std::thread([this]() { while (!stop_) { std::this_thread::sleep_for

Return Array of Eigen::Matrix from C++ to Python without copying

非 Y 不嫁゛ 提交于 2021-01-21 05:26:29
问题 I have some C++ code that generates and manipulates arrays of Eigen matrices. In the end I want to use those matrices in python and thought this might be a job for pybind11 . Basically what I want back in python are two nested lists / numpy arrays mat_a(I, 4, 4) and mat_b(J, K, 4, 4) . Because I have to do a lot of linear algebra stuff in C++ I wanted to use Eigen and the data structure I used is std::array<std::array<Eigen::Matrix4f, 2>, 3>>> mat_b // for J=3, K=2 . The problem now is how to

Python.h not found while building sample application with cmake and pybind11

醉酒当歌 提交于 2020-11-24 18:27:05
问题 I want to build simple app with pybind11, pybind is already installed in my Ubuntu system with cmake (and make install). I use this simple cmake file: cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(trt_cpp_loader ) find_package(pybind11 REQUIRED) add_executable(trt_cpp_loader main.cpp) set_property(TARGET trt_cpp_loader PROPERTY CXX_STANDARD 11) This is main.cpp: #include <iostream> #include <pybind11/embed.h> namespace py = pybind11; using namespace std; int main(){return 0;} when I