Skip to content

Commit

Permalink
Remove sendCurrentFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
Geeoon committed Jul 21, 2024
1 parent ff4766b commit 277f93a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
10 changes: 9 additions & 1 deletion src/network/MissionControlProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../control_interface.h"
#include "../utils/core.h"
#include "../utils/json.h"
#include "../base64/base64_img.h"
#include "../world_interface/data.h"
#include "../world_interface/world_interface.h"
#include "MissionControlMessages.h"
Expand Down Expand Up @@ -325,7 +326,14 @@ static bool validateCameraFrameRequest(const json& j) {

void MissionControlProtocol::handleCameraFrameRequest(const json& j) {
CameraID cam = j["camera"];
_camera_stream_task.sendCurrentFrame(cam);
auto camDP = robot::readCamera(cam);
if (camDP) {
auto data = camDP.getData();
cv::Mat frame = data.first;
std::string b64_data = base64::encodeMat(frame, ".jpg");
json msg = {{"type", CAMERA_FRAME_REP_TYPE}, {"camera", cam}, {"data", b64_data}};
_server.sendJSON(Constants::MC_PROTOCOL_NAME, msg);
}
}

void MissionControlProtocol::sendArmIKEnabledReport(bool enabled) {
Expand Down
12 changes: 0 additions & 12 deletions src/network/MissionControlTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "../Constants.h"
#include "../Globals.h"
#include "../base64/base64_img.h"
#include "../control_interface.h"
#include "../utils/core.h"
#include "../world_interface/world_interface.h"
Expand Down Expand Up @@ -142,17 +141,6 @@ void CameraStreamTask::closeStream(const CameraID& cam) {
_camera_encoders.erase(cam);
}

void CameraStreamTask::sendCurrentFrame(const robot::types::CameraID& cam) {
auto camDP = robot::readCamera(cam);
if (camDP) {
auto data = camDP.getData();
cv::Mat frame = data.first;
std::string b64_data = base64::encodeMat(frame, ".jpg");
json msg = {{"type", CAMERA_FRAME_REP_TYPE}, {"camera", cam}, {"data", b64_data}};
_server.sendJSON(Constants::MC_PROTOCOL_NAME, msg);
}
}

void CameraStreamTask::task(std::unique_lock<std::mutex>&) {
while (isRunningInternal()) {
{
Expand Down
7 changes: 0 additions & 7 deletions src/network/MissionControlTasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ class CameraStreamTask : public util::AsyncTask<> {
*/
void closeStream(const robot::types::CameraID& cam);

/**
* @brief Send the current frame of an open stream to Mission Control as a
* base64 encoded string.
* @param cam The camera that should be sent.
*/
void sendCurrentFrame(const robot::types::CameraID& cam);

protected:
void task(std::unique_lock<std::mutex>& lock) override;

Expand Down

0 comments on commit 277f93a

Please sign in to comment.