Skip to content

Commit

Permalink
Merge pull request #50 from ch-sa/ch-sa/pip-refactoring
Browse files Browse the repository at this point in the history
Pip Refactoring
  • Loading branch information
ch-sa authored Jan 9, 2022
2 parents 318816d + c4c810d commit 3fa10ac
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 113 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A lightweight tool for labeling 3D bounding boxes in point clouds.
### via pip (PyPI)
```bash
pip install labelCloud
labelCloud # by default looks for a `pointcloud` folder in the same directory
labelCloud --example # start labelCloud with example point cloud
```

### via git (manually)
Expand Down
2 changes: 1 addition & 1 deletion labelCloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.5"
__version__ = "0.6.7"
74 changes: 69 additions & 5 deletions labelCloud/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,77 @@
import sys
import argparse

from PyQt5.QtWidgets import QApplication, QDesktopWidget
from labelCloud import __version__


from labelCloud.view.gui import GUI
from labelCloud.control.controller import Controller
def main():
parser = argparse.ArgumentParser(
description="Label 3D bounding boxes inside point clouds."
)
parser.add_argument(
"-e",
"--example",
action="store_true",
help="Setup a project with an example point cloud and label.",
)
parser.add_argument(
"-v", "--version", action="version", version="%(prog)s " + __version__
)
args = parser.parse_args()

if args.example:
setup_example_project()

start_gui()


def setup_example_project() -> None:
import shutil
from pathlib import Path

from labelCloud.control.config_manager import config

print(
"Starting labelCloud in example mode.\n"
"Setting up project with example point cloud ,label and default config."
)
cwdir = Path().cwd()

# Create folders
pcd_folder = cwdir.joinpath(config.get("FILE", "pointcloud_folder"))
pcd_folder.mkdir(exist_ok=True)
label_folder = cwdir.joinpath(config.get("FILE", "label_folder"))
label_folder.mkdir(exist_ok=True)

# Copy example files
ressources_dir = Path(__file__).resolve().parent.joinpath("ressources")
shutil.copy(
str(ressources_dir.joinpath("default_config.ini")),
str(cwdir.joinpath("config.ini")),
)
shutil.copy(
str(ressources_dir.joinpath("examples").joinpath("exemplary.ply")),
str(pcd_folder.joinpath("exemplary.ply")),
)
shutil.copy(
str(ressources_dir.joinpath("examples").joinpath("exemplary.json")),
str(label_folder.joinpath("exemplary.json")),
)
print(
f"Setup example project in {cwdir}:"
"\n - config.ini"
"\n - pointclouds/exemplary.ply"
"\n - labels/exemplary.json"
)


def start_gui():
import sys

from PyQt5.QtWidgets import QApplication, QDesktopWidget

from labelCloud.control.controller import Controller
from labelCloud.view.gui import GUI

def main():
app = QApplication(sys.argv)

# Setup Model-View-Control structure
Expand Down
Empty file.
24 changes: 0 additions & 24 deletions labelCloud/ressources/interfaces/interface.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,6 @@
<iconset>
<normaloff>../icons/labelCloud.ico</normaloff>../icons/labelCloud.ico</iconset>
</property>
<property name="styleSheet">
<string notr="true">* {
background-color: #FFF;
font-family: &quot;DejaVu Sans&quot;, Arial;
}

QMenu::item:selected { /* when user selects item using mouse or keyboard */
background-color: #0000DD;
}

QListWidget#label_list::item {
padding-left: 22px;
padding-top: 7px;
padding-bottom: 7px;
background: url(&quot;../icons/cube-outline.svg&quot;) center left no-repeat;
}

QListWidget#label_list::item:selected {
color: #FFF;
border: none;
background: rgb(0, 0, 255);
background: url(&quot;../icons/cube-outline_white.svg&quot;) center left no-repeat, #0000ff;
}</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
Expand Down
40 changes: 38 additions & 2 deletions labelCloud/view/gui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re
from pathlib import Path
from typing import TYPE_CHECKING, List, Set

import pkg_resources
Expand Down Expand Up @@ -48,10 +49,36 @@ def set_zrotation_only(state: bool) -> None:
config.set("USER_INTERFACE", "z_rotation_only", str(state))


# CSS file paths need to be set dynamically
STYLESHEET = """
* {{
background-color: #FFF;
font-family: "DejaVu Sans", Arial;
}}
QMenu::item:selected {{
background-color: #0000DD;
}}
QListWidget#label_list::item {{
padding-left: 22px;
padding-top: 7px;
padding-bottom: 7px;
background: url("{icons_dir}/cube-outline.svg") center left no-repeat;
}}
QListWidget#label_list::item:selected {{
color: #FFF;
border: none;
background: rgb(0, 0, 255);
background: url("{icons_dir}/cube-outline_white.svg") center left no-repeat, #0000ff;
}}
"""


class GUI(QtWidgets.QMainWindow):
def __init__(self, control: "Controller") -> None:
super(GUI, self).__init__()
print(os.getcwd())
uic.loadUi(
pkg_resources.resource_filename(
"labelCloud.ressources.interfaces", "interface.ui"
Expand All @@ -60,6 +87,16 @@ def __init__(self, control: "Controller") -> None:
)
self.resize(1500, 900)
self.setWindowTitle("labelCloud")
self.setStyleSheet(
STYLESHEET.format(
icons_dir=str(
Path(__file__)
.resolve()
.parent.parent.joinpath("ressources")
.joinpath("icons")
)
)
)

# MENU BAR
# File
Expand Down Expand Up @@ -454,7 +491,6 @@ def update_label_completer(self, classnames=None) -> None:
if classnames is None:
classnames = set()
classnames.update(config.getlist("LABEL", "object_classes"))
print("COMPLETER CLASSNAMES: %s" % str(classnames))
self.curr_class_edit.setCompleter(QCompleter(classnames))

def update_bbox_stats(self, bbox) -> None:
Expand Down
67 changes: 67 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[metadata]
name = labelCloud
version = attr: labelCloud.__version__
maintainer = Christoph Sager
maintainer_email = [email protected]
license = GNU General Public License v3.0
description = A lightweight tool for labeling 3D bounding boxes in point clouds.
keywords =
labelCloud
machine learning
computer vision
annotation tool
labeling
point clouds
bounding boxes
3d object detection
6d pose estimation
url = https://github.com/ch-sa/labelCloud
long_description = file: README.md
long_description_content_type = text/markdown
classifiers =
Development Status :: 4 - Beta
Natural Language :: English
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Topic :: Scientific/Engineering :: Artificial Intelligence
Topic :: Multimedia :: Graphics :: Viewers

[options]
packages =
labelCloud
labelCloud.control
labelCloud.definitions
labelCloud.label_formats
labelCloud.labeling_strategies
labelCloud.model
labelCloud.ressources.icons
labelCloud.ressources.interfaces
labelCloud.ressources
labelCloud.tests
labelCloud.utils
labelCloud.view
zip_safe = False
install_requires =
numpy
open3d
PyOpenGL
PyQt5 <= 5.14.1;platform_system=='Windows'
PyQt5;platform_system!='Windows'
python_requires = >=3.6

[options.entry_points]
console_scripts =
labelCloud = labelCloud.__main__:main

[options.extras_require]
tests = pytest; pytest-qt

[options.package_data]
labelcloud.ressources = *
labelcloud.ressources.icons = *
labelcloud.ressources.interfaces = *
labelcloud.ressources.examples = *
81 changes: 1 addition & 80 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,82 +1,3 @@
from pathlib import Path

from setuptools import setup

this_directory = Path(__file__).parent
README = (this_directory / "README.md").read_text()


setup(
name="labelCloud",
version="0.6.5",
description="A lightweight tool for labeling 3D bounding boxes in point clouds.",
long_description=README,
long_description_content_type="text/markdown",
maintainer="Christoph Sager",
maintainer_email="[email protected]",
url="https://github.com/ch-sa/labelCloud",
license="GNU Geneal Public License v3.0",
packages=[
"labelCloud",
"labelCloud.control",
"labelCloud.definitions",
"labelCloud.label_formats",
"labelCloud.labeling_strategies",
"labelCloud.model",
"labelCloud.ressources.icons",
"labelCloud.ressources.interfaces",
"labelCloud.ressources",
"labelCloud.tests",
"labelCloud.utils",
"labelCloud.view",
],
package_data={
"labelCloud.ressources": ["*"],
"labelCloud.ressources.icons": ["*"],
"labelCloud.ressources.interfaces": ["*"],
},
entry_points={"console_scripts": ["labelCloud=labelCloud.__main__:main"]},
install_requires=[
"numpy",
"open3d",
"PyOpenGL",
"PyQt5 <= 5.14.1;platform_system=='Windows'", # avoids PyQt5 incompatibility on windows
"PyQt5;platform_system!='Windows'",
],
extras_require={
"tests": [
"pytest",
"pytest-qt",
],
},
zip_safe=False,
keywords=[
"labelCloud",
"machine learning",
"computer vision",
"annotation tool",
"labeling",
"point clouds",
"bounding boxes",
"3d object detection",
"6d pose estimation",
],
python_requires=">=3.6",
classifiers=[
"Development Status :: 4 - Beta",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Multimedia :: Graphics :: Viewers",
],
project_urls={
"GitHub": "https://github.com/ch-sa/labelCloud",
"YouTube Demo": "https://www.youtube.com/watch?v=8GF9n1WeR8A",
"Publication": "https://arxiv.org/abs/2103.04970",
},
)
setup()

0 comments on commit 3fa10ac

Please sign in to comment.