gui_flann_matching.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 # Copyright (c) 2016 PAL Robotics SL. All Rights Reserved
00004 #
00005 # Permission to use, copy, modify, and/or distribute this software for
00006 # any purpose with or without fee is hereby granted, provided that the
00007 # above copyright notice and this permission notice appear in all
00008 # copies.
00009 #
00010 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00011 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00012 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00013 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00014 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00015 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00016 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00017 #
00018 # Author:
00019 #   * Job van Dieten
00020 
00021 #System imports
00022 import sys
00023 import signal
00024 
00025 #ROS imports
00026 import rospy
00027 import rospkg
00028 
00029 #GUI imports
00030 from PyQt4 import QtGui, uic
00031 
00032 #Custom msg imports
00033 from opencv_tut.msg import valueMatrix
00034 
00035 pub = rospy.Publisher('opencv_tut/flann_matching_gui', valueMatrix, queue_size=10)
00036 
00037 class MyWindow(QtGui.QMainWindow):
00038         def __init__(self):
00039                 super(MyWindow, self).__init__()
00040                 self.rospack = rospkg.RosPack()
00041                 path = self.rospack.get_path('opencv_tut')
00042                 uic.loadUi(path + '/resources/gui_flann_matching.ui', self)
00043                 self.setMinMax()
00044                 self.setLabels()
00045                 self.setTick()
00046                 self.k_slider.valueChanged.connect(self.k_cb)
00047                 self.dist_slider.valueChanged.connect(self.dist_cb)
00048                 self.feature_choice.currentIndexChanged.connect(self.feature_choice_cb)
00049                 self.extractor_choice.currentIndexChanged.connect(self.extractor_choice_cb)
00050                 self.matcher_choice.currentIndexChanged.connect(self.matcher_choice_cb)
00051                 self.knnMatching_check.stateChanged.connect(self.knn_cb)
00052                 self.use_button.clicked.connect(self.use_button_cb)
00053                 self.show()
00054 
00055         def setLabels(self):
00056                 self.dist_label_var.setText(str(0.5))
00057                 self.k_label_var.setText(str(2))
00058 
00059         def setMinMax(self):
00060                 self.dist_slider.setMinimum(0)
00061                 self.dist_slider.setMaximum(10)
00062                 self.k_slider.setMinimum(1)
00063                 self.k_slider.setMaximum(10)
00064                 self.dist_slider.setValue(6)
00065                 self.k_slider.setValue(2)
00066 
00067         def setTick(self):
00068                 self.knnMatching_check.setChecked(False)
00069         
00070         def use_button_cb(self):
00071                 value = self.path_text.toPlainText()
00072                 self.pubString("path", str(value))
00073 
00074         def knn_cb(self):
00075                 tick = self.knnMatching_check.checkState()
00076                 self.pubTickMsg("knn", tick)
00077                 rospy.loginfo("knn: %s", tick)
00078         
00079         def feature_choice_cb(self):
00080                 value = self.feature_choice.currentText()
00081                 self.pubString("feature_choice", str(value))
00082 
00083         def matcher_choice_cb(self):
00084                 value = self.matcher_choice.currentText()
00085                 self.pubString("matcher_choice", str(value))
00086 
00087         def extractor_choice_cb(self):
00088                 value = self.extractor_choice.currentText()
00089                 self.pubString("extractor_choice", str(value))
00090 
00091         def dist_cb(self):
00092                 value = float(self.dist_slider.value())
00093                 value_dec = float(value/10)
00094                 self.dist_label_var.setText(str(value_dec))
00095                 self.pubValMsg("dist", value_dec)
00096 
00097         def k_cb(self):
00098                 value = self.k_slider.value()
00099                 self.k_label_var.setText(str(value))
00100                 self.pubValMsg("k", value)
00101 
00102         def pubValMsg(self, name, value):
00103                 msg = valueMatrix()
00104                 msg.header.frame_id = name
00105                 msg.value = value
00106                 pub.publish(msg)
00107 
00108         def pubTickMsg(self, name, tick):
00109                 msg = valueMatrix()
00110                 msg.header.frame_id = name
00111                 msg.tick = tick
00112                 pub.publish(msg)
00113 
00114         def pubString(self,name, string):
00115                 msg = valueMatrix()
00116                 msg.header.frame_id = name
00117                 msg.option = string
00118                 pub.publish(msg)
00119                 
00120 if __name__ == '__main__':
00121         rospy.init_node('flann_matching_gui')
00122         app = QtGui.QApplication(sys.argv)
00123         signal.signal(signal.SIGINT, signal.SIG_DFL)
00124         myWindow = MyWindow()
00125         sys.exit(app.exec_())


opencv_tut
Author(s): Job van Dieten
autogenerated on Fri Aug 26 2016 13:20:16