Skip to content

Commit 5c8d79c

Browse files
committed
Update core/FW: stereo_fixes (LR-check flip, depth align),
ImgFrame CV conversion: more verbose about size mismatch
1 parent 40aa5c6 commit 5c8d79c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/DatatypeBindings.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <pybind11/chrono.h>
3737
#include <pybind11/numpy.h>
3838

39+
#include "spdlog/spdlog.h"
3940

4041
void DatatypeBindings::bind(pybind11::module& m){
4142

@@ -493,10 +494,14 @@ void DatatypeBindings::bind(pybind11::module& m){
493494
}
494495

495496
// Check if enough data
497+
long actualSize = img.getData().size();
496498
long requiredSize = dtype.itemsize();
497499
for(const auto& dim : shape) requiredSize *= dim;
498-
if(img.getData().size() < requiredSize){
499-
throw std::runtime_error("ImgFrame doesn't have enough data to encode specified frame. Maybe metadataOnly transfer was made?");
500+
if(actualSize < requiredSize){
501+
throw std::runtime_error("ImgFrame doesn't have enough data to encode specified frame, required " + std::to_string(requiredSize)
502+
+ ", actual " + std::to_string(actualSize) + ". Maybe metadataOnly transfer was made?");
503+
} else if(actualSize > requiredSize) {
504+
spdlog::warn("ImgFrame has excess data: actual {}, expected {}", actualSize, requiredSize);
500505
}
501506
if(img.getWidth() <= 0 || img.getHeight() <= 0){
502507
throw std::runtime_error("ImgFrame size invalid (width: " + std::to_string(img.getWidth()) + ", height: " + std::to_string(img.getHeight()) + ")");

0 commit comments

Comments
 (0)