| 48 | |
| 49 | # a dialog for inputing a person's name |
| 50 | class AskNameDialog(QtGui.QDialog): |
| 51 | # constructor |
| 52 | # img : the face image (numpy.array) |
| 53 | def __init__(self, img): |
| 54 | super(AskNameDialog, self).__init__() |
| 55 | |
| 56 | self.setGeometry(400, 400, 0, 0) |
| 57 | self.layout = QtGui.QVBoxLayout(self) |
| 58 | |
| 59 | self.label = QtGui.QLabel('Please input his/her name!') |
| 60 | self.layout.addWidget(self.label) |
| 61 | |
| 62 | img = cv2.resize(img, (128, 128)) |
| 63 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) |
| 64 | self.qimg = QtGui.QImage(img.data, img.shape[1], img.shape[0], img.shape[1] * img.shape[2], QtGui.QImage.Format_RGB888) |
| 65 | |
| 66 | self.img_label = QtGui.QLabel() |
| 67 | self.img_label.setPixmap(QtGui.QPixmap.fromImage(self.qimg)) |
| 68 | self.layout.addWidget(self.img_label) |
| 69 | |
| 70 | self.edit = QtGui.QLineEdit() |
| 71 | self.layout.addWidget(self.edit) |
| 72 | |
| 73 | self.button_layout = QtGui.QHBoxLayout() |
| 74 | self.ok_button = QtGui.QPushButton('OK') |
| 75 | self.ok_button.clicked.connect(self.accept) |
| 76 | self.cancel_button = QtGui.QPushButton('Cancel') |
| 77 | self.cancel_button.clicked.connect(self.reject) |
| 78 | self.button_layout.addWidget(self.ok_button) |
| 79 | self.button_layout.addWidget(self.cancel_button) |
| 80 | |
| 81 | self.buttons = QtGui.QWidget() |
| 82 | self.buttons.setLayout(self.button_layout) |
| 83 | self.layout.addWidget(self.buttons) |
| 84 | |
| 85 | |
| 86 | # main widget |