Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 import sys
00023 import signal
00024
00025
00026 import rospy
00027 import rospkg
00028
00029
00030 from PyQt4 import QtGui, uic
00031
00032
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_())