Пример #1
0
	def stretch(self):
		curr_pixmap = self.temp_image
		height = curr_pixmap.height()
		zoom_interval = int(height * 0.2)
		self.zoom_time =  self.zoom_time + 1
		d("before:"+str(height))
		l("after: "+str(height*1.2))
		curr_pixmap = curr_pixmap.scaledToHeight(height+self.zoom_time*zoom_interval)
		self.current_image_item.setPixmap(curr_pixmap)
Пример #2
0
	def on_item_double_clicked(self, item):
		l("open item: " + item.text())
		if self.item_is_floder(item):
			self.openfolder(self.path + item.text())
		elif self.item_is_image(item):
			self.hide()
			d("path :"+self.path + item.text())
			sinview = SingleView(self.path + item.text())
			sinview.exec_()
			self.show()
Пример #3
0
	def turn_right(self):
		l("turn right")
		curr_image = self.current_image_item.pixmap()
		width = curr_image.width()
		height = curr_image.height()
		matrix = QtGui.QMatrix()
		matrix.rotate(90)
		after_rotate_image = curr_image.transformed(matrix)
		self.current_image_item.setPixmap(after_rotate_image)

		temp_img = self.temp_image
		width = temp_img.width()
		height = temp_img.height()
		matrix = QtGui.QMatrix()
		matrix.rotate(90)
		self.temp_image = temp_img.transformed(matrix)
Пример #4
0
	def show_image(self):
		d("index of image is "+ str(g_image_index))
		d(g_image_list[g_image_index].abspath)
		self.photo = QtGui.QPixmap( g_image_list[g_image_index].abspath )
		self.temp_image = QtGui.QPixmap(self.photo)
		self.zoom_time = 0
		if self.photo :
			l('load image success')
		else:
			l('load image faild: check file '+image_path+' exist.')
			exit(1)
		if self.current_image_item:
			image_size = self.photo.size()
			#step 1: remove before image and face rectangle
			self.ui.scene.removeItem(self.current_image_item)
			self.reomve_face_rects()

	 		self.ui.scene.setSceneRect(0, 0, image_size.width(), image_size.height())
			self.current_image_item = self.ui.scene.addPixmap(self.photo)
		else:
			self.current_image_item = self.ui.scene.addPixmap(self.photo)
Пример #5
0
	def openfolder(self, floder_path):
		self.ui.listWidget.clear()
		self.path = floder_path+"/"
		p_floder_icon_pixmap = QtGui.QPixmap("res/10.png")
		floder_icon_pixmap = QtGui.QPixmap("res/Black.png")
		if floder_icon_pixmap:
			l("load floder icon success!")
		floder_icon = QtGui.QIcon(floder_icon_pixmap)
		p_floder_icon = QtGui.QIcon(p_floder_icon_pixmap)
		p_floder_item = QtGui.QListWidgetItem(p_floder_icon, "..")
		self.ui.listWidget.addItem(p_floder_item)
		for item in os.listdir(floder_path):
			print item
			if ispath(item):
				list_item = QtGui.QListWidgetItem(floder_icon, item)
				self.ui.listWidget.addItem(list_item)
			elif isimage(item):
				pixmap = QtGui.QPixmap(floder_path+"/"+item)
				item_icon = QtGui.QIcon(pixmap)
				list_item = QtGui.QListWidgetItem(item_icon, item)
				self.ui.listWidget.addItem(list_item)

		self.ui.listWidget.setViewMode(QtGui.QListView.IconMode)
Пример #6
0
def play(self):
    time.sleep(1)
    l("enter ppt mode")
    self.setWindowFlags(QtCore.Qt.Window)
    self.showFullScreen()
    tmp_image_index = g_image_index
    while tmp_image_index+1 <= len(g_image_list):
        image = QtGui.QPixmap( g_image_list[tmp_image_index].abspath )
        label_width = self.ui.image_label.width()
        label_height = self.ui.image_label.height()
        if image.width() > label_width :
            image = image.scaledToWidth(label_width)
            if image.height() > label_height:
                image = image.scaledToHeight(label_height)
        elif image.height() > label_height:
            image = image.scaledToHeight(label_height)
            if image.width() > label_width:
                image = image.scaledToWidth(label_width)
        d("showing "+str(tmp_image_index)+":"+g_image_list[tmp_image_index].abspath)
        self.ui.image_label.setPixmap(image)
        time.sleep(3)
        tmp_image_index = tmp_image_index + 1
    thread.exit_thread()
Пример #7
0
	def init_image_list(self, image_path):
		global g_image_index
		image_path = str(image_path)
		self.floder_name = os.path.dirname(os.path.abspath(image_path))
		target_name = os.path.basename( image_path )
		l("opening floder:"+ self.floder_name)
		l("opening target:"+ target_name)
		#clear the link list of image
		del g_image_list[:]
		g_image_index = 0
		count = 0
		for filename in os.listdir(self.floder_name):
			#find all image
			if isimage( filename ):
				l(filename)
				g_image_list.append(Picture( self.floder_name , filename))
				if filename == target_name:
					d("found!")
					g_image_index = count
				count = count +1
		l("this floder has "+str(len(g_image_list))+" photos")
		d("target index is "+ str(g_image_index))
Пример #8
0
	def click_detect(self):
		cv_image = QPixmapToIplImage(self.current_image_item.pixmap())
		l(type(cv_image))
		self.reomve_face_rects()
		cascade = cv.Load("./haarcascade_frontalface_alt.xml")
		self.detect_and_draw(cv_image, cascade)