mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 11:55:00 +00:00
increase image compression level and re-enabled thread
This commit is contained in:
@@ -421,7 +421,7 @@ void sendKobukiData(TKobukiData &data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CapnSend() {
|
void CapnSend() {
|
||||||
int COMPRESSION_LEVEL = 80;
|
int COMPRESSION_LEVEL = 90;
|
||||||
VideoCapture cap(0); // Open the camera
|
VideoCapture cap(0); // Open the camera
|
||||||
if (!cap.isOpened()) {
|
if (!cap.isOpened()) {
|
||||||
cerr << "Error: Could not open camera" << endl;
|
cerr << "Error: Could not open camera" << endl;
|
||||||
@@ -446,17 +446,17 @@ void CapnSend() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compress the image (JPEG compression with adjustable quality)
|
|
||||||
vector<uchar> buf;
|
vector<uchar> imgbuf;
|
||||||
vector<int> compression_params;
|
vector<int> compression_params;
|
||||||
compression_params.push_back(IMWRITE_JPEG_QUALITY); // Set JPEG quality
|
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)
|
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
|
// 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<uchar> buffer to a string (no casting)
|
// Convert the vector<uchar> 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)
|
// Publish the compressed image data (MQTT, in this case)
|
||||||
client.publishMessage("kobuki/cam", enc_msg);
|
client.publishMessage("kobuki/cam", enc_msg);
|
||||||
|
Reference in New Issue
Block a user