77#include < QFileDialog>
88#include < QLabel>
99#include < QDir>
10+ #include < QGroupBox>
11+ #include < QRadioButton>
1012#include < cfloat>
1113#include < QDirIterator>
1214#include < QVBoxLayout>
2931#include " Common/Cpp/Json/JsonValue.h"
3032#include " Common/Cpp/Json/JsonTools.h"
3133#include " Common/Qt/CollapsibleGroupBox.h"
34+ #include " Pokemon/Pokemon_Strings.h"
3235#include " Pokemon/Resources/Pokemon_PokemonForms.h"
3336#include " CommonFramework/VideoPipeline/VideoOverlayScopes.h"
3437#include " ML/UI/ML_ImageAnnotationDisplayWidget.h"
@@ -134,12 +137,18 @@ LabelImages::LabelImages(const LabelImages_Descriptor& descriptor)
134137 , WIDTH(" <b>Width:</b>" , LockMode::UNLOCK_WHILE_RUNNING, 0.4 , 0.0 , 1.0 )
135138 , HEIGHT(" <b>Height:</b>" , LockMode::UNLOCK_WHILE_RUNNING, 0.4 , 0.0 , 1.0 )
136139 , FORM_LABEL(" bulbasaur" )
140+ , CUSTOM_LABEL_DATABASE(create_string_select_database({
141+ " sun" ,
142+ " mc"
143+ }))
144+ , CUSTOM_LABEL(CUSTOM_LABEL_DATABASE, LockMode::UNLOCK_WHILE_RUNNING, 0 )
137145{
138146 ADD_OPTION (X);
139147 ADD_OPTION (Y);
140148 ADD_OPTION (WIDTH);
141149 ADD_OPTION (HEIGHT);
142150 ADD_OPTION (FORM_LABEL);
151+ ADD_OPTION (CUSTOM_LABEL);
143152
144153 // , m_sam_session{RESOURCE_PATH() + "ML/sam_cpu.onnx"}
145154 const std::string sam_model_path = RESOURCE_PATH () + " ML/sam_cpu.onnx" ;
@@ -529,12 +538,35 @@ LabelImages_Widget::LabelImages_Widget(
529538 button_row->addWidget (next_anno_button, 1 );
530539
531540 // add a row for user annotation
541+ // the user can annotate in two modes:
542+ // - set a pokemon form label
543+ // - load a predefined custom string list and select from the list
544+ // The custom list cannot contain pokemon form name. Otherwise it will be set to the pokemon form label
545+ // so underlying data is only a single string. The UI reflects on what dropdown menu is set.
546+ // the UI needs to have a
532547 QHBoxLayout* annotation_row = new QHBoxLayout ();
533548 scroll_layout->addLayout (annotation_row);
549+
534550 annotation_row->addWidget (new QLabel (" <b>Select Label:</b>" , scroll_inner), 0 );
535551
536- ConfigWidget* option_widget = program.FORM_LABEL .make_QtWidget (*scroll_inner);
537- annotation_row->addWidget (&option_widget->widget (), 5 );
552+ // add a group box for user to pick whether to choose from pokemon form label or custom label
553+ QGroupBox* label_type_group = new QGroupBox ();
554+ QRadioButton* pokemon_radio_button = new QRadioButton (QString::fromStdString (Pokemon::STRING_POKEMON + " Forms" ));
555+ QRadioButton* custom_label_radio_button = new QRadioButton (" Custom Set" );
556+ pokemon_radio_button->setChecked (true );
557+
558+ QHBoxLayout* group_box_layout = new QHBoxLayout;
559+ group_box_layout->addWidget (pokemon_radio_button);
560+ group_box_layout->addWidget (custom_label_radio_button);
561+ label_type_group->setLayout (group_box_layout);
562+ annotation_row->addWidget (label_type_group);
563+
564+ ConfigWidget* pokemon_label_widget = program.FORM_LABEL .make_QtWidget (*scroll_inner);
565+ annotation_row->addWidget (&pokemon_label_widget->widget (), 2 );
566+ ConfigWidget* custom_label_widget = program.CUSTOM_LABEL .make_QtWidget (*scroll_inner);
567+ annotation_row->addWidget (&custom_label_widget->widget (), 2 );
568+ // disable the custom label widget to correpsond to the default selection of label_type_group
569+ custom_label_widget->widget ().setEnabled (false );
538570
539571 // add compute embedding button
540572
@@ -558,6 +590,15 @@ LabelImages_Widget::LabelImages_Widget(
558590 program.update_rendered_objects (this ->m_overlay_set );
559591 });
560592
593+ connect (pokemon_radio_button, &QPushButton::clicked, this , [pokemon_label_widget, custom_label_widget](bool ){
594+ pokemon_label_widget->widget ().setEnabled (true );
595+ custom_label_widget->widget ().setEnabled (false );
596+ });
597+ connect (custom_label_radio_button, &QPushButton::clicked, this , [pokemon_label_widget, custom_label_widget](bool ){
598+ pokemon_label_widget->widget ().setEnabled (false );
599+ custom_label_widget->widget ().setEnabled (true );
600+ });
601+
561602 connect (compute_embedding_button, &QPushButton::clicked, this , [this ](bool ){
562603 std::string folder_path = QFileDialog::getExistingDirectory (
563604 nullptr , " Open image folder" , " ." ).toStdString ();
0 commit comments