def addPreviewImage(self, color_image, parent = None): image = color_image image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) if not parent is None: parent.progress_bar.setValue(12) h, w = image.shape self.img_height = h self.ocr_areas = OCRAreasFinder(color_image) self.market_width = self.ocr_areas.market_width if not parent is None: parent.progress_bar.setValue(14) points = self.ocr_areas.market_table self.valid_market = self.ocr_areas.valid if self.valid_market: cut = image[0:points[1][1] + 20, 0:points[1][0] + 20] else: cut = image[:] processedimage = array2qimage(cut) if not parent is None: parent.progress_bar.setValue(16) pix = QPixmap() pix.convertFromImage(processedimage) if not parent is None: parent.progress_bar.setValue(18) return pix
def addPreviewImage(self, color_image, parent = None): image = color_image image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) if not parent is None: parent.progress_bar.setValue(12) h, w = image.shape self.img_height = h self.ocr_areas = OCRAreasFinder(color_image, self.settings["contrast"]) self.market_width = self.ocr_areas.market_width if not parent is None: parent.progress_bar.setValue(14) self.valid_market = self.ocr_areas.valid if self.valid_market: points = self.ocr_areas.market_table self.market_offset = (points[0][0], points[0][1]) station = self.ocr_areas.station_name self.station_offset = (station[0][0], station[0][1]) cut = image[0:points[1][1] + 20, 0:points[1][0] + 20] else: cut = image[:] self.market_offset = (0, 0) self.station_offset = (0, 0) processedimage = array2qimage(cut) if not parent is None: parent.progress_bar.setValue(16) pix = QPixmap() pix.convertFromImage(processedimage) if not parent is None: parent.progress_bar.setValue(18) return pix
def drawStationName(self): """Draw station name snippet to station_name_img""" res = self.current_result name = res.station.name #self.station_name.setText('') #self.station_name.clear() #self.station_name.addItems(name.optional_values) if not self.file_list.currentItem().station is None: self.station_name.setText(self.file_list.currentItem().station) else: self.station_name.setText(name.value) #font = QFont("Consolas", 11) #self.station_name.lineEdit().setFont(font) #self.setConfidenceColor(self.station_name, name) img = self.cutImage(res.contrast_station_img, name) if self.dark_theme: img = 255 - img processedimage = array2qimage(img) pix = QPixmap() pix.convertFromImage(processedimage) if self.station_name_img.height() < pix.height(): pix = pix.scaled(self.station_name_img.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation) scene = QGraphicsScene() scene.addPixmap(pix) self.station_name_img.setScene(scene) self.station_name_img.show()
def addPreviewImage(self, color_image, parent = None): image = color_image image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) if not parent is None: parent.progress_bar.setValue(12) h, w = image.shape self.img_height = h self.ocr_areas = OCRAreasFinder(color_image) self.market_width = self.ocr_areas.market_width self.hud_color = self.ocr_areas.hud_color if not parent is None: parent.progress_bar.setValue(14) points = self.ocr_areas.market_table self.valid_market = self.ocr_areas.valid if self.valid_market: cut = image[0:points[1][1] + 20, 0:points[1][0] + 20] else: cut = image[:] processedimage = array2qimage(cut) if not parent is None: parent.progress_bar.setValue(16) pix = QPixmap() pix.convertFromImage(processedimage) if not parent is None: parent.progress_bar.setValue(18) return pix
def addPreviewImage(self): image = self.color_image image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) h, w = image.shape cut = image[0:self.settings["cal_points"][7]*h + 20, 0:self.settings["cal_points"][6]*w + 20] processedimage = array2qimage(cut) pix = QPixmap() pix.convertFromImage(processedimage) return pix
def drawSnippet(self, graphicsview, snippet): """Draw single result item to graphicsview""" processedimage = array2qimage(snippet) pix = QPixmap() pix.convertFromImage(processedimage) pix = pix.scaled(graphicsview.width(), graphicsview.height()-1, Qt.KeepAspectRatio, Qt.SmoothTransformation) scene = QGraphicsScene() scene.addPixmap(pix) graphicsview.setScene(scene) graphicsview.show()
def addPreviewImage(self, color_image): image = color_image image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) h, w = image.shape ocr_areas = OCRAreasFinder(color_image) points = ocr_areas.market_table self.valid_market = ocr_areas.valid if self.valid_market: cut = image[0:points[1][1] + 20, 0:points[1][0] + 20] else: cut = image[:] processedimage = array2qimage(cut) pix = QPixmap() pix.convertFromImage(processedimage) return pix
def drawSnippet(self, graphicsview, item): """Draw single result item to graphicsview""" res = self.current_result snippet = self.cutImage(res.contrast_commodities_img, item) #cv2.imwrite('snippets/'+str(self.currentsnippet)+'.png',snippet) #self.currentsnippet += 1 processedimage = array2qimage(snippet) pix = QPixmap() pix.convertFromImage(processedimage) if graphicsview.height() < pix.height(): pix = pix.scaled(graphicsview.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation) scene = QGraphicsScene() scene.addPixmap(pix) graphicsview.setScene(scene) graphicsview.show()
def drawSnippet(self, graphicsview, item): """Draw single result item to graphicsview""" res = self.current_result snippet = self.cutImage(res.contrast_commodities_img, item) #cv2.imwrite('snippets/'+unicode(self.currentsnippet)+'.png',snippet) #self.currentsnippet += 1 processedimage = array2qimage(snippet) pix = QPixmap() pix.convertFromImage(processedimage) if graphicsview.height() < pix.height(): pix = pix.scaled(graphicsview.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation) scene = QGraphicsScene() scene.addPixmap(pix) graphicsview.setScene(scene) graphicsview.show()
def addPreviewImage(self, color_image): image = color_image image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) h, w = image.shape ocr_areas = OCRAreasFinder(color_image) points = ocr_areas.market_table self.valid_market = ocr_areas.valid if self.valid_market: cut = image[0:points[1][1] + 20, 0:points[1][0] + 20] else: cut = image[:] processedimage = array2qimage(cut) pix = QPixmap() pix.convertFromImage(processedimage) return pix
def __init__(self, path): # QtGui.QWidget.__init__(self) #初始化position super(ImageFrame, self).__init__() self.m_DragPosition = self.pos() screen = QtGui.QDesktopWidget().screenGeometry() self.resize(screen.width(), screen.height()) self.setStyleSheet("background-color:#000000;") self.label = QLabel() self.label.setGeometry(0, 0, screen.width(), screen.height()) self.label.setAlignment(Qt.AlignCenter) self.setCentralWidget(self.label) img = QImage(path) img = img.mirrored(True, False) pix = QPixmap() pix.convertFromImage(img) self.label.setPixmap(pix)
def drawSnippet(self, graphicsview, snippet): """Draw single result item to graphicsview""" try: h, w = snippet.shape except: h, w, c = snippet.shape if h < 1 or w < 1: return processedimage = array2qimage(snippet) pix = QPixmap() pix.convertFromImage(processedimage) pix = pix.scaled(graphicsview.width(), graphicsview.height() - 1, Qt.KeepAspectRatio, Qt.SmoothTransformation) scene = QGraphicsScene() scene.addPixmap(pix) graphicsview.setScene(scene) graphicsview.show()
def drawStationName(self): """Draw station name snippet to station_name_img""" res = self.current_result name = res.station.name self.station_name.setEditText(name.value) img = self.cutImage(res.contrast_station_img, name) processedimage = array2qimage(img) pix = QPixmap() pix.convertFromImage(processedimage) if self.station_name_img.height() < pix.height(): pix = pix.scaled(self.station_name_img.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation) scene = QGraphicsScene() scene.addPixmap(pix) self.station_name_img.setScene(scene) self.station_name_img.show()
def drawStationName(self): """Draw station name snippet to station_name_img""" res = self.current_result name = res.station.name self.station_name.addItems(name.optional_values) self.station_name.setEditText(name.value) font = QFont() font.setPointSize(11) self.station_name.lineEdit().setFont(font) self.setConfidenceColor(self.station_name, name) img = self.cutImage(res.contrast_station_img, name) processedimage = array2qimage(img) pix = QPixmap() pix.convertFromImage(processedimage) if self.station_name_img.height() < pix.height(): pix = pix.scaled(self.station_name_img.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation) scene = QGraphicsScene() scene.addPixmap(pix) self.station_name_img.setScene(scene) self.station_name_img.show()
class Qt4_VimbaVideo(GenericVideoDevice): def __init__(self, name): GenericVideoDevice.__init__(self,name) self.camera = None self.camera_id = str self.qimage = None self.qpixmap = None def init(self): # start Vimba self.camera_id = u"%s" % self.getProperty("camera_id") atexit.register(self.close_camera) GenericVideoDevice.init(self) self.image_dimensions = [1360, 1024] def do_image_polling(self, sleep_time): with Vimba() as vimba: system = vimba.getSystem() if system.GeVTLIsPresent: system.runFeatureCommand("GeVDiscoveryAllOnce") time.sleep(0.2) cameraIds = vimba.getCameraIds() #self.camera = vimba.getCamera(self.camera_id) self.camera = vimba.getCamera(cameraIds[-1]) self.camera.openCamera(cameraAccessMode=2) self.camera.framerate = 1 self.frame0 = self.camera.getFrame() # creates a frame self.frame0.announceFrame() self.camera.startCapture() self.image_dimensions = (self.frame0.width, self.frame0.height) while True: self.frame0.waitFrameCapture(1000) self.frame0.queueFrameCapture() self.qimage = QImage(self.frame0.getBufferByteData(), self.image_dimensions[0], self.image_dimensions[1], QImage.Format_RGB888) if self.cam_mirror is not None: self.qimage = self.qimage.mirrored(self.cam_mirror[0], self.cam_mirror[1]) if self.qpixmap is None: self.qpixmap = QPixmap(self.qimage) else: self.qpixmap.convertFromImage(self.qimage) self.emit("imageReceived", self.qpixmap) time.sleep(sleep_time) def get_new_image(self): return self.qimage def get_video_live(self): return True def close_camera(self): with Vimba() as vimba: self.camera.flushCaptureQueue() self.camera.endCapture() self.camera.revokeAllFrames() vimba.shutdown() def start_camera(self): pass def change_owner(self): pass