13 class ImageSink_Node :
public NodeInternal
20 : NodeInternal(
"Image Sink")
22 inputs.push_back({
"Image"});
27 std::shared_ptr<image::Image> img = std::static_pointer_cast<image::Image>(inputs[0].ptr);
29 image::save_img(*img, path);
36 ImGui::SetNextItemWidth(200 * ui_scale);
37 ImGui::InputText(
"Path", &path);
40 nlohmann::json to_json()
47 void from_json(nlohmann::json j)
53 class ImageSource_Node :
public NodeInternal
56 std::string product_path;
60 : NodeInternal(
"Image Source")
62 outputs.push_back({
"Image"});
67 std::shared_ptr<image::Image> img_out = std::make_shared<image::Image>();
68 image::load_img(*img_out, product_path);
69 outputs[0].ptr = img_out;
76 ImGui::SetNextItemWidth(200 * ui_scale);
77 ImGui::InputText(
"Path", &product_path);
80 nlohmann::json to_json()
83 j[
"path"] = product_path;
87 void from_json(nlohmann::json j)
89 product_path = j[
"path"];
93 class ImageGetProj_Node :
public NodeInternal
100 : NodeInternal(
"Image Get Projection")
102 inputs.push_back({
"Image"});
103 outputs.push_back({
"Projection"});
108 std::shared_ptr<image::Image> img = std::static_pointer_cast<image::Image>(inputs[0].ptr);
110 std::shared_ptr<projection::Projection> ptr = std::make_shared<projection::Projection>(image::get_metadata_proj_cfg(*img));
111 ptr->height = img->height();
112 ptr->width = img->width();
113 outputs[0].ptr = ptr;
119 nlohmann::json to_json() {
return {}; }
120 void from_json(nlohmann::json j) {}
123 class ImageReproj_Node :
public NodeInternal
127 bool processing =
false;
132 : NodeInternal(
"Reproj Image")
134 inputs.push_back({
"Image"});
135 inputs.push_back({
"Projection"});
136 outputs.push_back({
"Image"});
142 std::shared_ptr<image::Image> img = std::static_pointer_cast<image::Image>(inputs[0].ptr);
143 std::shared_ptr<projection::Projection> proj = std::static_pointer_cast<projection::Projection>(inputs[1].ptr);
145 std::shared_ptr<image::Image> img_out = std::make_shared<image::Image>();
150 op.output_width = proj->width;
151 op.output_height = proj->height;
152 op.target_prj_info = *proj;
155 auto cfg = image::get_metadata_proj_cfg(*op.img);
156 cfg[
"width"] = img->width();
157 cfg[
"height"] = img->height();
158 image::set_metadata_proj_cfg(*op.img, cfg);
159 *img_out = projection::reproject(op, &progress);
161 outputs[0].ptr = img_out;
170 ImGui::ProgressBar(progress, {200 * ui_scale, 0});
172 nlohmann::json to_json() {
return {}; }
173 void from_json(nlohmann::json j) {}
176 class ImageExpression_Node :
public NodeInternal
181 std::string input_name;
184 NLOHMANN_DEFINE_TYPE_INTRUSIVE(ChConfig, input_name, tokens);
187 std::vector<ChConfig> channels;
188 std::string expression;
191 ImageExpression_Node()
192 : NodeInternal(
"Image Expression")
194 outputs.push_back({
"Image"});
199 std::vector<image::ExpressionChannel> ch;
200 for (
int i = 0; i < channels.size(); i++)
202 std::shared_ptr<image::Image> img = std::static_pointer_cast<image::Image>(inputs[i].ptr);
203 ch.push_back({channels[i].tokens, img.get()});
204 logger->warn(channels[i].tokens);
207 std::shared_ptr<image::Image> img_out = std::make_shared<image::Image>();
208 *img_out = image::generate_image_expression(ch, expression);
209 outputs[0].ptr = img_out;
216 ImGui::SetNextItemWidth(200 * ui_scale);
217 ImGui::InputTextMultiline(
"Expression", &expression);
219 for (
auto &c : channels)
222 ImGui::Text(
"%s", c.input_name.c_str());
224 ImGui::SetNextItemWidth(200 * ui_scale);
225 ImGui::InputText(std::string(
"##input" + c.input_name).c_str(), &c.tokens);
229 if (ImGui::Button(
"Add"))
231 std::string name =
"Img" + std::to_string(channels.size() + 1);
232 addInputDynamic({name});
233 channels.push_back({name,
"chimg" + std::to_string(channels.size() + 1)});
237 nlohmann::json to_json()
240 j[
"expression"] = expression;
241 j[
"channels"] = channels;
245 void from_json(nlohmann::json j)
247 expression = j[
"expression"];
248 channels = j[
"channels"];
250 for (
auto &c : channels)
251 inputs.push_back({c.input_name});