Commit 82ef3ab 1 parent 5b40c04 commit 82ef3ab Copy full SHA for 82ef3ab
File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -158,13 +158,21 @@ bool regex_valid(const std::wstring& regex)
158
158
159
159
cv::Mat decode_image (const std::string& data)
160
160
{
161
+ if (data.empty ()) {
162
+ return {};
163
+ }
164
+
161
165
std::string base64 = base64::base64_decode (data);
162
166
std::vector<uchar> buffer (std::make_move_iterator (base64.begin ()), std::make_move_iterator (base64.end ()));
163
167
return cv::imdecode (buffer, cv::IMREAD_COLOR);
164
168
}
165
169
166
170
std::string encode_image (const cv::Mat& image)
167
171
{
172
+ if (image.empty ()) {
173
+ return {};
174
+ }
175
+
168
176
std::vector<uchar> buffer;
169
177
cv::imencode (" .png" , image, buffer);
170
178
return base64::base64_encode (buffer.data (), buffer.size ());
Original file line number Diff line number Diff line change @@ -907,9 +907,17 @@ inline std::string short_str(const std::string& str)
907
907
inline json::value log_msg (const json::value& j)
908
908
{
909
909
json::value j_copy = j;
910
- if (j .exists (" image" )) {
910
+ if (j_copy .exists (" image" )) {
911
911
j_copy[" image" ] = short_str (j.at (" image" ).as_string ());
912
912
}
913
+ if (j_copy.exists (" raw" )) {
914
+ j_copy[" raw" ] = short_str (j.at (" raw" ).as_string ());
915
+ }
916
+ if (j_copy.exists (" draws" )) {
917
+ for (auto & d : j_copy[" draws" ].as_array ()) {
918
+ d = short_str (d.as_string ());
919
+ }
920
+ }
913
921
return j_copy;
914
922
}
915
923
You can’t perform that action at this time.
0 commit comments