JFJOchReader: Add ReadAllSpots option to handle reading just spot finding result
This commit is contained in:
@@ -374,3 +374,31 @@ void JFJochHttpReader::UploadUserMask(const std::vector<uint32_t>& mask) {
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Server rejected user mask upload");
|
||||
}
|
||||
|
||||
std::vector<SpotToSave> JFJochHttpReader::ReadSpots(int64_t image) const {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
if (image < 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Image number must be non-negative");
|
||||
|
||||
if (addr.empty())
|
||||
return {};
|
||||
|
||||
httplib::Client cli_cmd(addr);
|
||||
auto res = cli_cmd.Get("/image_buffer/image.cbor?id=" + std::to_string(image));
|
||||
|
||||
if (!res || res->status != httplib::StatusCode::OK_200 || res->body.empty())
|
||||
return {};
|
||||
|
||||
try {
|
||||
auto msg = CBORStream2Deserialize(res->body);
|
||||
|
||||
if (msg->msg_type != CBORImageType::IMAGE)
|
||||
return {};
|
||||
|
||||
return msg->data_message->spots;
|
||||
} catch (std::exception &e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user