Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

[issue #706] Added jderobotComm and logo to colorTuner_py #711

Merged
merged 3 commits into from
Mar 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tools/colorTuner_py/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ENDFOREACH(header)

INSTALL(FILES colorTuner.py DESTINATION share/jderobot/python/colorTuner_py/ COMPONENT tools)
INSTALL(FILES resources_rc.py DESTINATION share/jderobot/python/colorTuner_py/ COMPONENT tools)

# Install gui
INSTALL (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gui DESTINATION share/jderobot/python/colorTuner_py COMPONENT tools PATTERN .svn EXCLUDE)
Expand Down
11 changes: 7 additions & 4 deletions src/tools/colorTuner_py/colorTuner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.5
#!/usr/bin/python2
#
# Copyright (C) 1997-2016 JDE Developers Team
#
Expand All @@ -22,7 +22,7 @@
import sys
import easyiceconfig as EasyIce
from gui.threadGUI import ThreadGUI
from parallelIce.cameraClient import CameraClient
import jderobotComm as comm
from sensors.cameraFilter import CameraFilter
from gui.GUI import MainWindow
from PyQt5.QtWidgets import QApplication
Expand All @@ -34,8 +34,11 @@

if __name__ == '__main__':
ic = EasyIce.initialize(sys.argv)
prop = ic.getProperties()
cameraCli = CameraClient(ic, "ColorTuner.Camera", True)

#starting comm
ic, node = comm.init(ic)

cameraCli = comm.getCameraClient(ic, "ColorTuner.Camera", True)
camera = CameraFilter(cameraCli)

app = QApplication(sys.argv)
Expand Down
7 changes: 6 additions & 1 deletion src/tools/colorTuner_py/colorTuner_py.cfg
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
ColorTuner.Camera.Proxy = cameraA:default -h localhost -p 9999
# 0 -> Deactivate, 1 -> Ice , 2 -> ROS
ColorTuner.Camera.Server=1
ColorTuner.Camera.Proxy=cameraA:default -h localhost -p 9999
ColorTuner.Camera.Format=RGB8
ColorTuner.Camera.Topic=/camera/rgb/image_raw
ColorTuner.Camera.Name=ColorTuner
7 changes: 5 additions & 2 deletions src/tools/colorTuner_py/gui/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
from PyQt5.QtCore import pyqtSignal, Qt, QRect
from PyQt5.QtWidgets import QMainWindow, QVBoxLayout, QWidget
#from gui.communicator import Communicator
from gui.imagesWidget import ImagesWidget
from gui.controlWidget import ControlWidget
from .imagesWidget import ImagesWidget
from .controlWidget import ControlWidget


class MainWindow(QMainWindow):

Expand All @@ -49,6 +50,8 @@ def __init__(self, parent=None):

self.updGUI.connect(self.updateGUI)

#self.verticalLayoutWidget.setStyleSheet("background-color:black;")

#self.controlCommunicator=Communicator()
#self.imageCommunicator=Communicator()

Expand Down
19 changes: 16 additions & 3 deletions src/tools/colorTuner_py/gui/controlWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
from filters.hsvFilter import HSVMAX, HSVMIN
from filters.rgbFilter import RGBMAX, RGBMIN
from filters.yuvFilter import YUVMAX, YUVMIN
from .logoWidget import LogoWidget


WIDTH = 1340
HEIGTH = 200

class ControlWidget(QWidget):

Expand All @@ -42,8 +44,8 @@ def __init__(self,winParent):

def initUI(self):

self.setMinimumSize(1340,200)
self.setMaximumSize(1340,200)
self.setMinimumSize(WIDTH,HEIGTH)
self.setMaximumSize(WIDTH,HEIGTH)

'''Radio buttons for Original/RGB/HSV/YUV images'''
self.origButton = QRadioButton("Original")
Expand All @@ -63,6 +65,7 @@ def initUI(self):
self.hLayout = QHBoxLayout(self)
self.hLayout.setObjectName("hLayout")


''' Vertical Layout for radio buttons '''
self.radioLayout = QVBoxLayout()
self.radioLayout.setObjectName("radioLayout")
Expand All @@ -73,6 +76,13 @@ def initUI(self):
self.vSpacer = QSpacerItem(30, 500, QSizePolicy.Ignored, QSizePolicy.Ignored);
self.radioLayout.addItem(self.vSpacer)


self.logoLayout = QVBoxLayout()
self.logo = LogoWidget(self, HEIGTH, HEIGTH)
self.logoLayout.addWidget(self.logo)




hmin,smin,vmin = HSVMIN
hmax,smax,vmax = HSVMAX
Expand All @@ -89,6 +99,7 @@ def initUI(self):
self.hminLayout.addWidget(self.hminLabel)
self.hminLayout.addWidget(self.hminValue)
self.hminLayout.addWidget(self.hminSlider)


''' Vertical Layout for HMAX Slider'''
self.hmaxLayout = QVBoxLayout()
Expand Down Expand Up @@ -162,6 +173,7 @@ def initUI(self):

'''Adding all the vertical layouts to the main horizontal layout'''
self.hLayout.addLayout(self.radioLayout)
self.hLayout.addLayout(self.logoLayout)
self.hLayout.addLayout(self.hminLayout)
self.hLayout.addLayout(self.hmaxLayout)
self.hLayout.addLayout(self.sminLayout)
Expand All @@ -170,6 +182,7 @@ def initUI(self):
self.hLayout.addLayout(self.vmaxLayout)
self.setLayout(self.hLayout)


'''Signals for sliders value changes'''
self.hminSlider.valueChanged.connect(self.changeHmin)
self.hmaxSlider.valueChanged.connect(self.changeHmax)
Expand Down
44 changes: 44 additions & 0 deletions src/tools/colorTuner_py/gui/logoWidget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Copyright (C) 1997-2015 JDE Developers Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
# Authors :
# Alberto Martin Florido <almartinflorido@gmail.com>
#
import resources_rc
from PyQt5 import QtGui
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget

class LogoWidget(QWidget):

def __init__(self,winParent, width=0, height=0):
super(LogoWidget, self).__init__()
self.winParent=winParent
qimage=QtGui.QImage()
qimage.load(':images/jderobot.svg')
if (width != 0 and height != 0):
self.qimage = qimage.scaled(0.8*width, 0.8*height, Qt.KeepAspectRatio)
#self.qimage = qimage.scaled(0.8*width, 0.8*height)
self.resize(width, height)
else:
self.qimage = qimage


def paintEvent(self, e):

painter=QtGui.QPainter(self)
painter.drawImage(self.width()/2-self.qimage.width()/2, self.height()/2-self.qimage.height()/2, self.qimage)


4 changes: 4 additions & 0 deletions src/tools/colorTuner_py/resources/genResources
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
pyrcc5 resources.qrc -o resources_rc.py
mv resources_rc.py ..

Binary file added src/tools/colorTuner_py/resources/jderobot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/tools/colorTuner_py/resources/jderobot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/tools/colorTuner_py/resources/resources.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="images">
<file>jderobot.svg</file>
</qresource>
</RCC>
100 changes: 100 additions & 0 deletions src/tools/colorTuner_py/resources_rc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-

# Resource object code
#
# Created by: The Resource Compiler for PyQt5 (Qt v5.5.1)
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore

qt_resource_data = b"\
\x00\x00\x03\xc6\
\x3c\
\x3f\x78\x6d\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x31\x2e\
\x30\x22\x20\x65\x6e\x63\x6f\x64\x69\x6e\x67\x3d\x22\x55\x54\x46\
\x2d\x38\x22\x20\x73\x74\x61\x6e\x64\x61\x6c\x6f\x6e\x65\x3d\x22\
\x6e\x6f\x22\x3f\x3e\x0a\x3c\x21\x44\x4f\x43\x54\x59\x50\x45\x20\
\x73\x76\x67\x20\x50\x55\x42\x4c\x49\x43\x20\x22\x2d\x2f\x2f\x57\
\x33\x43\x2f\x2f\x44\x54\x44\x20\x53\x56\x47\x20\x31\x2e\x30\x2f\
\x2f\x45\x4e\x22\x20\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\
\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x54\x52\x2f\x32\x30\x30\x31\x2f\
\x50\x52\x2d\x53\x56\x47\x2d\x32\x30\x30\x31\x30\x37\x31\x39\x2f\
\x44\x54\x44\x2f\x73\x76\x67\x31\x30\x2e\x64\x74\x64\x22\x3e\x0a\
\x3c\x73\x76\x67\x20\x77\x69\x64\x74\x68\x3d\x22\x31\x33\x63\x6d\
\x22\x20\x68\x65\x69\x67\x68\x74\x3d\x22\x31\x35\x63\x6d\x22\x20\
\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\x37\x39\x20\x37\x39\x20\x32\
\x34\x33\x20\x32\x39\x35\x22\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\
\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\
\x2f\x32\x30\x30\x30\x2f\x73\x76\x67\x22\x20\x78\x6d\x6c\x6e\x73\
\x3a\x78\x6c\x69\x6e\x6b\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\
\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\x39\x2f\x78\
\x6c\x69\x6e\x6b\x22\x3e\x0a\x20\x20\x3c\x65\x6c\x6c\x69\x70\x73\
\x65\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x20\x6e\
\x6f\x6e\x65\x3b\x20\x66\x69\x6c\x6c\x2d\x6f\x70\x61\x63\x69\x74\
\x79\x3a\x30\x3b\x20\x73\x74\x72\x6f\x6b\x65\x2d\x77\x69\x64\x74\
\x68\x3a\x20\x38\x3b\x20\x73\x74\x72\x6f\x6b\x65\x3a\x20\x23\x66\
\x66\x61\x35\x30\x30\x22\x20\x63\x78\x3d\x22\x31\x38\x34\x22\x20\
\x63\x79\x3d\x22\x32\x31\x38\x22\x20\x72\x78\x3d\x22\x38\x37\x22\
\x20\x72\x79\x3d\x22\x38\x34\x22\x2f\x3e\x0a\x20\x20\x3c\x65\x6c\
\x6c\x69\x70\x73\x65\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\
\x6c\x3a\x20\x6e\x6f\x6e\x65\x3b\x20\x66\x69\x6c\x6c\x2d\x6f\x70\
\x61\x63\x69\x74\x79\x3a\x30\x3b\x20\x73\x74\x72\x6f\x6b\x65\x2d\
\x77\x69\x64\x74\x68\x3a\x20\x38\x3b\x20\x73\x74\x72\x6f\x6b\x65\
\x3a\x20\x23\x30\x38\x39\x31\x66\x38\x22\x20\x63\x78\x3d\x22\x31\
\x36\x35\x22\x20\x63\x79\x3d\x22\x32\x33\x33\x22\x20\x72\x78\x3d\
\x22\x35\x34\x22\x20\x72\x79\x3d\x22\x35\x34\x22\x2f\x3e\x0a\x20\
\x20\x3c\x65\x6c\x6c\x69\x70\x73\x65\x20\x73\x74\x79\x6c\x65\x3d\
\x22\x66\x69\x6c\x6c\x3a\x20\x6e\x6f\x6e\x65\x3b\x20\x66\x69\x6c\
\x6c\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x30\x3b\x20\x73\x74\x72\
\x6f\x6b\x65\x2d\x77\x69\x64\x74\x68\x3a\x20\x38\x3b\x20\x73\x74\
\x72\x6f\x6b\x65\x3a\x20\x23\x66\x66\x30\x30\x30\x30\x22\x20\x63\
\x78\x3d\x22\x32\x30\x31\x22\x20\x63\x79\x3d\x22\x32\x30\x31\x22\
\x20\x72\x78\x3d\x22\x31\x31\x37\x22\x20\x72\x79\x3d\x22\x31\x31\
\x37\x22\x2f\x3e\x0a\x20\x20\x3c\x65\x6c\x6c\x69\x70\x73\x65\x20\
\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x20\x6e\x6f\x6e\
\x65\x3b\x20\x66\x69\x6c\x6c\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\
\x30\x3b\x20\x73\x74\x72\x6f\x6b\x65\x2d\x77\x69\x64\x74\x68\x3a\
\x20\x38\x3b\x20\x73\x74\x72\x6f\x6b\x65\x3a\x20\x23\x30\x62\x62\
\x64\x30\x62\x22\x20\x63\x78\x3d\x22\x31\x35\x32\x22\x20\x63\x79\
\x3d\x22\x32\x34\x35\x22\x20\x72\x78\x3d\x22\x32\x39\x22\x20\x72\
\x79\x3d\x22\x32\x39\x22\x2f\x3e\x0a\x20\x20\x3c\x74\x65\x78\x74\
\x20\x66\x6f\x6e\x74\x2d\x73\x69\x7a\x65\x3d\x22\x33\x39\x2e\x34\
\x39\x39\x38\x22\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\
\x3a\x20\x23\x30\x37\x32\x35\x39\x33\x3b\x74\x65\x78\x74\x2d\x61\
\x6e\x63\x68\x6f\x72\x3a\x6d\x69\x64\x64\x6c\x65\x3b\x66\x6f\x6e\
\x74\x2d\x66\x61\x6d\x69\x6c\x79\x3a\x73\x61\x6e\x73\x2d\x73\x65\
\x72\x69\x66\x3b\x66\x6f\x6e\x74\x2d\x73\x74\x79\x6c\x65\x3a\x6e\
\x6f\x72\x6d\x61\x6c\x3b\x66\x6f\x6e\x74\x2d\x77\x65\x69\x67\x68\
\x74\x3a\x37\x30\x30\x22\x20\x78\x3d\x22\x32\x30\x35\x22\x20\x79\
\x3d\x22\x33\x36\x35\x22\x3e\x0a\x20\x20\x20\x20\x3c\x74\x73\x70\
\x61\x6e\x20\x78\x3d\x22\x32\x30\x35\x22\x20\x79\x3d\x22\x33\x36\
\x35\x22\x3e\x4a\x64\x65\x52\x6f\x62\x6f\x74\x3c\x2f\x74\x73\x70\
\x61\x6e\x3e\x0a\x20\x20\x3c\x2f\x74\x65\x78\x74\x3e\x0a\x3c\x2f\
\x73\x76\x67\x3e\x0a\
"

qt_resource_name = b"\
\x00\x06\
\x07\x03\x7d\xc3\
\x00\x69\
\x00\x6d\x00\x61\x00\x67\x00\x65\x00\x73\
\x00\x0c\
\x07\x72\xc8\x67\
\x00\x6a\
\x00\x64\x00\x65\x00\x72\x00\x6f\x00\x62\x00\x6f\x00\x74\x00\x2e\x00\x73\x00\x76\x00\x67\
"

qt_resource_struct = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
"

def qInitResources():
QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)

def qCleanupResources():
QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)

qInitResources()
8 changes: 5 additions & 3 deletions src/tools/colorTuner_py/sensors/cameraFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ def __init__(self, camera):
self.lock = threading.Lock()
self.client = camera

self.height= self.client.getHeight()
self.width = self.client.getWidth()
img = self.client.getImage()

self.height= img.height
self.width = img.width


self.kill_event = threading.Event()
Expand Down Expand Up @@ -98,7 +100,7 @@ def getYUVImage (self):


def update(self):
img = self.client.getImage()
img = self.client.getImage().data
rgb = self.getFilter(RGB).apply(img)
hsv = self.getFilter(HSV).apply(img)
yuv = self.getFilter(YUV).apply(img)
Expand Down