From 0a8b96a45ab9d09034c76c3ec314e8a5e600185c Mon Sep 17 00:00:00 2001 From: Sam Hos Date: Wed, 22 Jan 2025 13:46:47 +0100 Subject: [PATCH] increase image compression level and re-enabled thread --- src/C++/Driver/src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/C++/Driver/src/main.cpp b/src/C++/Driver/src/main.cpp index 87dc3de..4f888ce 100644 --- a/src/C++/Driver/src/main.cpp +++ b/src/C++/Driver/src/main.cpp @@ -421,7 +421,7 @@ void sendKobukiData(TKobukiData &data) } void CapnSend() { - int COMPRESSION_LEVEL = 80; + int COMPRESSION_LEVEL = 90; VideoCapture cap(0); // Open the camera if (!cap.isOpened()) { cerr << "Error: Could not open camera" << endl; @@ -446,17 +446,17 @@ void CapnSend() { } } - // Compress the image (JPEG compression with adjustable quality) - vector buf; + + vector imgbuf; vector compression_params; compression_params.push_back(IMWRITE_JPEG_QUALITY); // Set JPEG quality compression_params.push_back(COMPRESSION_LEVEL); // Adjust the quality level (0-100, lower = more compression) // Encode the image into the byte buffer with the specified compression parameters - imencode(".jpg", frame, buf, compression_params); + imencode(".jpg", frame, imgbuf, compression_params); // Convert the vector buffer to a string (no casting) - string enc_msg(buf.begin(), buf.end()); + string enc_msg(imgbuf.begin(), imgbuf.end()); // Publish the compressed image data (MQTT, in this case) client.publishMessage("kobuki/cam", enc_msg);