Код: Выделить всё
#include
#include "optixSphere.h"
#include "common.h"
namespace py = pybind11;
PYBIND11_MODULE(rts, m) {
py::class_(m, "KNN")
.def(py::init()) // Default constructor
.def_readwrite("num", &rts::KNN::num)
.def_readwrite("dist_list", &rts::KNN::dist_list)
.def_readwrite("knn_list", &rts::KNN::knn_list);
py::class_(m, "RTSphere")
.def(py::init())
.def("Query", &rts::RTSphere::Query, py::arg("queries"), py::arg("query_num"),
py::arg("result"))
.def("DisplayMetrics", &rts::RTSphere::DisplayMetrics);
}
Код: Выделить всё
### ===== For pybind11
pybind11_add_module(rts
bindings.cpp
${embedded_ptx_code}
optixSphere.cpp
cuda_helper.cu
)
# Install the module to Python site-packages
message(STATUS "Python3_SITEARCH: ${Python3_SITEARCH}")
install(TARGETS rts DESTINATION ${Python3_SITEARCH}/rts)
Код: Выделить всё
import numpy as np
from scipy.spatial import KDTree
import random
import rts
data_path = "data/test_point.csv"
device_id = 3
radius = 20.0
header = np.genfromtxt(data_path, delimiter=',', max_rows=1, dtype=int)
point_num = header[0]
point_dim = header[1]
print(f"num = {point_num}, dim = {point_dim}")
data = np.genfromtxt(data_path, delimiter=',', skip_header=1).tolist()
print(data[0:10])
bvh = rts.RTSphere(data, point_num, radius, device_id)
Код: Выделить всё
Traceback (most recent call last):
File "/home/xzx/Project/RTCC/example/rt_search.py", line 22, in
bvh = rts.RTSphere(data, point_num, radius, device_id)
^^^^^^^^^^^^
AttributeError: module 'rts' has no attribute 'RTSphere'
Я попытался переместить программу Python в каталог, где находится модуль, возникла ошибка ушел.
Подробнее здесь: https://stackoverflow.com/questions/793 ... n-pybind11
Мобильная версия