Skip to content

Commit

Permalink
Send b64 jpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
Geeoon committed Jul 18, 2024
1 parent 31ab9c1 commit 161c92d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/network/MissionControlTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../control_interface.h"
#include "../utils/core.h"
#include "../world_interface/world_interface.h"
#include "../base64/base64_img.h"
#include "MissionControlMessages.h"

#include <loguru.hpp>
Expand Down Expand Up @@ -142,15 +143,21 @@ void CameraStreamTask::closeStream(const CameraID& cam) {
}

void CameraStreamTask::sendCurrentFrame(const robot::types::CameraID& cam) {
// robot::types::CameraFrame data;
std::string b64_data = "";
{
// std::lock_guard lg(_mutex);
// check if there is a stream with the camera name
// grab frame
std::lock_guard lg(_mutex);
if (_open_streams.find(cam) != _open_streams.end()) {
auto camDP = robot::readCamera(cam);
if (camDP) {
auto data = camDP.getData();
cv::Mat frame = data.first;
b64_data = base64::encodeMat(frame, ".jpg");
}
}
}
json msg = {{"type", CAMERA_FRAME_REP_TYPE},
{"camera", cam},
{"data", "base64encoded!!!"}};
{"data", b64_data}};
_server.sendJSON(Constants::MC_PROTOCOL_NAME, msg);
}

Expand Down

0 comments on commit 161c92d

Please sign in to comment.