@@ -145,11 +145,19 @@ PYBIND11_MODULE(_libcamera, m)
.value("RequestCompleted", CameraEventType::RequestCompleted)
.value("BufferCompleted", CameraEventType::BufferCompleted);
+ /*
+ * For camera, request and fb fields, manually typecast to the C++ type,
+ * so that pybind11 assigns the actual type for the return value. This
+ * makes the stubs generated by pybind11-stubgen contain the correct type,
+ * instead of "object".
+ *
+ * Maybe there's a better way to do this...
+ */
pyEvent
.def_readonly("type", &PyCameraEvent::type_)
- .def_readonly("camera", &PyCameraEvent::camera_)
- .def_readonly("request", &PyCameraEvent::request_)
- .def_readonly("fb", &PyCameraEvent::fb_);
+ .def_property_readonly("camera", [](PyCameraEvent &self) { return self.camera_.cast<Camera *>(); })
+ .def_property_readonly("request", [](PyCameraEvent &self) { return self.request_.cast<Request *>(); })
+ .def_property_readonly("fb", [](PyCameraEvent &self) { return self.fb_.cast<FrameBuffer *>(); });
pyCameraManager
.def_static("singleton", []() {