clang optimizations and improved error handling

This commit is contained in:
Maik Jurischka
2025-12-19 07:42:24 +01:00
parent 43c172c03f
commit 108c56ab06
5 changed files with 29 additions and 29 deletions

View File

@@ -46,7 +46,8 @@ bool StreamingEngine::start(const std::string& gstPipeline) {
currentFormat_ = fmtList[0];
// Allocate buffer (assume worst case: uncompressed)
bufferSize_ = currentFormat_.width * currentFormat_.height * 4;
const size_t calculatedBufferSize = currentFormat_.width * currentFormat_.height * 4;
bufferSize_ = calculatedBufferSize;
buffer_ = std::make_unique<uint8_t[]>(bufferSize_);
// Start GStreamer pipeline
@@ -104,7 +105,7 @@ void StreamingEngine::acquisitionLoop() {
while (running_) {
int dataSize = 0;
VX_CAPTURE_RESULT result = VxGetImage(camera_, buffer_.get(), &dataSize, 1000);
const VX_CAPTURE_RESULT result = VxGetImage(camera_, buffer_.get(), &dataSize, 1000);
if (result == VX_CAPTURE_RESULT::VX_SUCCESS && dataSize > 0) {
// Push frame to GStreamer pipeline
@@ -128,8 +129,8 @@ void StreamingEngine::acquisitionLoop() {
framesInLastSecond++;
// Print statistics every second
auto now = std::chrono::steady_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(now - lastStatsTime);
const auto now = std::chrono::steady_clock::now();
const auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(now - lastStatsTime);
if (elapsed.count() >= 1) {
std::cout << "FPS: " << framesInLastSecond
<< " | Total frames: " << frameCount