summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2022-05-30 17:27:12 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-06-01 12:08:58 +0300
commite8317de05ce62e5e7ccdef3d18a76ecd590e9ef6 (patch)
treed7fd33ddde5ed4db9fe3a0a8161e04818f059502 /src
parent80e0ff355ee64cd50940b1e94d6e43c5f19afdfa (diff)
py: Add FrameMetadataPlane
Add FrameMetadataPlane class and adjust the methods and uses accordingly. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/py/cam/cam.py3
-rw-r--r--src/py/libcamera/py_main.cpp13
2 files changed, 10 insertions, 6 deletions
diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py
index 677dd680..bf8529d9 100755
--- a/src/py/cam/cam.py
+++ b/src/py/cam/cam.py
@@ -285,7 +285,8 @@ class CaptureState:
print('{:.6f} ({:.2f} fps) {}-{}: seq {}, bytes {}, CRCs {}'
.format(ts / 1000000000, fps,
ctx.id, stream_name,
- meta.sequence, meta.bytesused,
+ meta.sequence,
+ '/'.join([str(p.bytes_used) for p in meta.planes]),
crcs))
if ctx.opt_metadata:
diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp
index 9e827845..52f70811 100644
--- a/src/py/libcamera/py_main.cpp
+++ b/src/py/libcamera/py_main.cpp
@@ -163,6 +163,7 @@ PYBIND11_MODULE(_libcamera, m)
auto pyRequestReuse = py::enum_<Request::ReuseFlag>(pyRequest, "Reuse");
auto pyFrameMetadata = py::class_<FrameMetadata>(m, "FrameMetadata");
auto pyFrameMetadataStatus = py::enum_<FrameMetadata::Status>(pyFrameMetadata, "Status");
+ auto pyFrameMetadataPlane = py::class_<FrameMetadata::Plane>(pyFrameMetadata, "Plane");
auto pyTransform = py::class_<Transform>(m, "Transform");
auto pyColorSpace = py::class_<ColorSpace>(m, "ColorSpace");
auto pyColorSpacePrimaries = py::enum_<ColorSpace::Primaries>(pyColorSpace, "Primaries");
@@ -512,11 +513,10 @@ PYBIND11_MODULE(_libcamera, m)
.def_readonly("status", &FrameMetadata::status)
.def_readonly("sequence", &FrameMetadata::sequence)
.def_readonly("timestamp", &FrameMetadata::timestamp)
- /* \todo Implement FrameMetadata::Plane properly */
- .def_property_readonly("bytesused", [](FrameMetadata &self) {
- std::vector<unsigned int> v;
- v.resize(self.planes().size());
- transform(self.planes().begin(), self.planes().end(), v.begin(), [](const auto &p) { return p.bytesused; });
+ .def_property_readonly("planes", [](const FrameMetadata &self) {
+ /* Convert from Span<> to std::vector<> */
+ /* Note: this creates a copy */
+ std::vector<FrameMetadata::Plane> v(self.planes().begin(), self.planes().end());
return v;
});
@@ -525,6 +525,9 @@ PYBIND11_MODULE(_libcamera, m)
.value("Error", FrameMetadata::FrameError)
.value("Cancelled", FrameMetadata::FrameCancelled);
+ pyFrameMetadataPlane
+ .def_readwrite("bytes_used", &FrameMetadata::Plane::bytesused);
+
pyTransform
.def(py::init([](int rotation, bool hflip, bool vflip, bool transpose) {
bool ok;