Skip to content

Commit

Permalink
Add label propagation
Browse files Browse the repository at this point in the history
 - add a feature to carry over labels to the next point cloud
 - can be activated via config and menu action
 - will only copy labels if the next point cloud has no bounding boxes so far

Closes: #120
  • Loading branch information
ch-sa committed Dec 4, 2022
1 parent ca2221a commit 6fb3dd9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ std_rotation = 0.5
std_scaling = 0.03
; minimum value for the length, width and height of a bounding box
min_boundingbox_dimension = 0.01
; propagate labels to next point cloud if it has no labels yet
propagate_labels = False

[USER_INTERFACE]
; only allow z-rotation of bounding boxes. set false to also label x- & y-rotation
Expand Down
12 changes: 9 additions & 3 deletions labelCloud/control/controller.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import logging
from typing import Optional, Union
from typing import Optional

import numpy as np
from PyQt5 import QtCore, QtGui
from PyQt5.QtCore import QPoint

import numpy as np

from ..definitions import BBOX_SIDES, Color, Context
from ..utils import oglhelper
from ..view.gui import GUI
from .alignmode import AlignMode
from .bbox_controller import BoundingBoxController
from .config_manager import config
from .drawing_manager import DrawingManager
from .pcd_manager import PointCloudManger

Expand Down Expand Up @@ -63,9 +63,15 @@ def next_pcd(self, save: bool = True) -> None:
if save:
self.save()
if self.pcd_manager.pcds_left():
previous_bboxes = self.bbox_controller.bboxes
self.pcd_manager.get_next_pcd()
self.reset()
self.bbox_controller.set_bboxes(self.pcd_manager.get_labels_from_file())

if not self.bbox_controller.bboxes and config.getboolean(
"LABEL", "propagate_labels"
):
self.bbox_controller.set_bboxes(previous_bboxes)
else:
self.view.update_progress(len(self.pcd_manager.pcds))
self.view.button_next_pcd.setEnabled(False)
Expand Down
35 changes: 35 additions & 0 deletions labelCloud/resources/interfaces/interface.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1521,25 +1521,35 @@
<property name="title">
<string>File</string>
</property>
<property name="toolTipsVisible">
<bool>true</bool>
</property>
<addaction name="act_set_pcd_folder"/>
<addaction name="act_set_label_folder"/>
</widget>
<widget class="QMenu" name="menuLabels">
<property name="title">
<string>Labels</string>
</property>
<property name="toolTipsVisible">
<bool>true</bool>
</property>
<widget class="QMenu" name="act_set_default_class">
<property name="title">
<string>Set Default Object Class …</string>
</property>
</widget>
<addaction name="act_set_default_class"/>
<addaction name="act_delete_all_labels"/>
<addaction name="act_propagate_labels"/>
</widget>
<widget class="QMenu" name="menuSettings">
<property name="title">
<string>Settings</string>
</property>
<property name="toolTipsVisible">
<bool>true</bool>
</property>
<addaction name="act_z_rotation_only"/>
<addaction name="act_show_floor"/>
<addaction name="act_show_orientation"/>
Expand Down Expand Up @@ -1577,6 +1587,9 @@
<property name="text">
<string>Z-Rotation Only Mode</string>
</property>
<property name="toolTip">
<string>Only allows bounding box rotation around the z-axis.</string>
</property>
</action>
<action name="act_delete_all_labels">
<property name="text">
Expand Down Expand Up @@ -1608,6 +1621,9 @@
<property name="text">
<string>Show Floor</string>
</property>
<property name="toolTip">
<string>Shows a grid along the x-y-plane (z=0).</string>
</property>
</action>
<action name="act_show_orientation">
<property name="checkable">
Expand All @@ -1630,6 +1646,10 @@
<property name="text">
<string>Keep Perspective</string>
</property>
<property name="toolTip">
<string>Saves the last perspective and reuses it,
when opening that point cloud again.</string>
</property>
</action>
<action name="act_align_pcd">
<property name="checkable">
Expand All @@ -1641,6 +1661,9 @@
<property name="text">
<string>Align Point Cloud</string>
</property>
<property name="toolTip">
<string>Transforms the point cloud so that the floor is the x-y-plane.</string>
</property>
</action>
<action name="act_change_settings">
<property name="text">
Expand All @@ -1652,6 +1675,18 @@
<string>test</string>
</property>
</action>
<action name="act_propagate_labels">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Propagate Labels</string>
</property>
<property name="toolTip">
<string>Propagate Labels to the next Point Cloud
if it does not have labels yet.</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
9 changes: 9 additions & 0 deletions labelCloud/view/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def set_keep_perspective(state: bool) -> None:
config.set("USER_INTERFACE", "keep_perspective", str(state))


def set_propagate_labels(state: bool) -> None:
config.set("LABEL", "propagate_labels", str(state))


# CSS file paths need to be set dynamically
STYLESHEET = """
* {{
Expand Down Expand Up @@ -118,6 +122,7 @@ def __init__(self, control: "Controller") -> None:
self.act_delete_all_labels: QtWidgets.QAction
self.act_set_default_class: QtWidgets.QMenu
self.actiongroup_default_class = QActionGroup(self.act_set_default_class)
self.act_propagate_labels: QtWidgets.QAction

# Settings
self.act_z_rotation_only: QtWidgets.QAction
Expand Down Expand Up @@ -323,6 +328,7 @@ def connect_events(self) -> None:
self.act_delete_all_labels.triggered.connect(
self.controller.bbox_controller.reset
)
self.act_propagate_labels.toggled.connect(set_propagate_labels)
self.act_z_rotation_only.toggled.connect(set_zrotation_only)
self.act_show_floor.toggled.connect(set_floor_visibility)
self.act_show_orientation.toggled.connect(set_orientation_visibility)
Expand All @@ -331,6 +337,9 @@ def connect_events(self) -> None:
self.act_change_settings.triggered.connect(self.show_settings_dialog)

def set_checkbox_states(self) -> None:
self.act_propagate_labels.setChecked(
config.getboolean("LABEL", "propagate_labels")
)
self.act_show_floor.setChecked(
config.getboolean("USER_INTERFACE", "show_floor")
)
Expand Down

0 comments on commit 6fb3dd9

Please sign in to comment.