123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- #ifndef __IMAGELABELER_H__
- #define __IMAGELABELER_H__
- #include "ImageHolder.h"
- #include "LineEditForm.h"
- #include "OptionsForm.h"
- #include <QMainWindow>
- #include <QDir>
- #include "ui_ImageLabeler.h"
- class QMenuBar;
- class QMenu;
- class QAction;
- class QHBoxLayout;
- class QVBoxLayout;
- class QGridLayout;
- class QPushButton;
- class QPixmap;
- class QLabel;
- class QScrollArea;
- class QFrame;
- class QListWidget;
- class QListWidgetItem;
- class QButtonGroup;
- class QDomDocument;
- class QDomElement;
- class QSettings;
- struct Image {
- QString image_;
- bool labeled_;
- bool pas_;
- };
- class ImageLabeler : public QMainWindow, public Ui::ImageLabelerGui
- {
- Q_OBJECT
- protected:
-
- void resizeEvent(QResizeEvent *anEvent);
- void mousePressEvent(QMouseEvent *anEvent);
- void wheelEvent(QWheelEvent *anEvent);
- void keyPressEvent(QKeyEvent *anEvent);
- void keyReleaseEvent(QKeyEvent *anEvent);
- void closeEvent(QCloseEvent *anEvent);
- bool readSettings(QSettings *aSettings);
- bool writeSettings(QSettings *aSettings);
- void getImagesFromDir(const QDir &dir);
- void showWarning(const QString &text);
- bool askForUnsavedData();
- bool askForKeepingAnnotations();
- void loadLegendFromNode(QDomElement *anElement);
- void addLabel(
- int aLabelID,
- bool isMain,
- QString aLabel
- );
- void addPoly(Polygon *poly);
- void addBBox(BoundingBox *bbox);
- void addPolyFromData(
- QString *aPolyData,
- int *labelID
- );
- void addBBoxFromData(
- QString *aBBoxData,
- int *labelID
- );
- Polygon polyFromData(
- QString *aPolyData
- );
- Polygon polyFromListItemText(
- QString *aString,
- int *oldID
- );
- bool BBoxFromData(const QString *aBBoxData, BoundingBox &p_BBox);
- BoundingBox BBoxFromListItemText(
- QString *aString,
- int *oldID
- );
- void addBBoxArea(
- int anID,
- BoundingBox aBBox,
- int itemID = -1
- );
- void addPolyArea(
- int aPolyID,
- Polygon aPoly,
- int itemID = -1
- );
- bool deleteArea(QListWidgetItem *anItem);
- bool toggleLabelPriority(QListWidgetItem *anItem);
- void enableTools();
- void disableTools();
- void legendToXml(QDomDocument *aDoc, QDomElement *aRoot);
- void objectsToXml(QDomDocument *aDoc, QDomElement *aRoot);
- void addImage(Image *anImage);
- bool loadInfo(QString filename);
- bool loadPascalFile(QString aFilename, QString aPath = QString());
- bool loadPascalPolys(QString aFilename);
- bool selectImage(int anImageID);
- void setLabelColor(int anID, QColor aColor);
- public:
- ImageLabeler(QWidget *aParent = 0, QString aSettingsPath = QString());
- virtual ~ImageLabeler();
- public slots:
- void addLabel();
- void editLabel(QListWidgetItem *anItem);
- void removeLabel();
- void removeLabel(int aLabelID);
- void setLabelID(QListWidgetItem *anItem);
- void toggleLabelPriority();
- void focusOnArea();
- void editArea();
- void deleteArea();
- void saveAllInfo();
- void saveSegmentedPicture();
- void saveLegend();
- void loadImage();
- void loadImages();
- void loadInfo();
- void loadPascalFile();
- void loadPascalPolys();
- void loadLegendFromFile();
-
- void nextImage(int iImageStep = 1);
-
- void prevImage(int iImageStep = 1);
- void setBoundingBoxTool(bool aButtonPressed);
- void setPolygonTool(bool aButtonPressed);
- void generateColors();
- void confirmSelection();
- void clearAll();
- void clearAllTool();
- void clearLabelList();
- void clearLabelColorList();
- void areaListPopupMenu(const QPoint &aPos);
- void labelListPopupMenu(const QPoint &aPos);
- void imageListPopupMenu(const QPoint &);
- void setDataFromForm(QString aData);
- void onSelectionStarted();
- void onAreaItemChange(QListWidgetItem *);
- void onAreaEdit();
- void setPureData();
- void setLabelColor();
- void viewNormal();
- void viewSegmented();
- void interruptSearch();
- void selectImage(QListWidgetItem *);
- void removeImage();
- void writeSettings();
- void readSettings();
- private:
-
-
-
- QMenu *popup_area_list_;
-
- QAction *action_delete_area_;
-
- QAction *action_edit_area_;
-
-
- QMenu *popup_label_list_;
-
- QAction *action_toggle_priority_;
-
- QAction *action_set_color_;
-
- QAction *action_delete_label_;
-
-
- QMenu *popup_images_list_;
-
- QAction *action_remove_image_;
-
-
- QPixmap *image_;
-
- ImageHolder *image_holder_;
-
-
-
- LineEditForm line_edit_form_;
-
- OptionsForm options_form_;
-
-
- Qt::KeyboardModifiers keyboard_modifier_;
-
- int main_label_;
-
-
- int **pure_data_;
-
-
- int label_ID_;
-
-
- int image_ID_;
-
- QString image_description_;
-
- QString tags_;
-
- QString PASCALpath_;
-
- QString current_image_;
-
- QString segmented_image_;
-
-
- QList< BoundingBox * > list_bounding_box_;
-
-
- QList< Polygon * > list_polygon_;
-
- QList< Image > *list_images_;
-
- QList< uint > list_label_colors_;
-
-
- QString old_area_string_;
-
-
- bool auto_color_generation_;
-
-
-
-
-
- bool interrupt_search_;
-
- bool unsaved_data_;
-
- QSettings *settings_;
- };
- #endif
|