当前位置: 首页>>代码示例>>Python>>正文


Python Screen.draw_image方法代码示例

本文整理汇总了Python中pygaze.screen.Screen.draw_image方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.draw_image方法的具体用法?Python Screen.draw_image怎么用?Python Screen.draw_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygaze.screen.Screen的用法示例。


在下文中一共展示了Screen.draw_image方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1:

# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_image [as 别名]
# pause screen
scr.clear()
scr.draw_text(text="Press Space to continue.")
disp.fill(scr)
disp.show()
kb.get_key(keylist=["space"], timeout=None, flush=True)


# # # # #
# IMAGES

# loop through images
for imgpath in IMAGES:
	# draw image
	scr.clear(colour=(255,255,255))
	scr.draw_image(imgpath)
	disp.fill(scr)
	# start recording
	tracker.start_recording()
	tracker.log("IMAGE_TRIALSTART")
	tracker.log("imgname=%s" % (os.path.basename(imgpath)))
	# show display
	disp.show()
	tracker.log("image_on")
	# wait for a bit
	clock.pause(IMGTIME)
	# clear screen
	scr.clear()
	disp.fill(scr)
	disp.show()
	# stop recording
开发者ID:mattfloat,项目名称:EyeTribe_test,代码行数:33,代码来源:experiment.py

示例2: EyelinkGraphics

# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_image [as 别名]

#.........这里部分代码省略.........
        """
		Prints alert message.

		Arguments:
		msg		--	The message to be played.
		"""

        print "eyelink_graphics.alert_printf(): %s" % msg

    def setup_image_display(self, width, height):

        """
		Initializes the buffer that will contain the camera image.

		Arguments:
		width		--	The width of the image.
		height		--	The height of the image.
		"""

        self.size = width, height
        self.clear_cal_display()
        self.last_mouse_state = -1
        self.imagebuffer = self.new_array()

    def image_title(self, text):

        """
		Sets the current image title.

		Arguments:
		text	--	An image title.
		"""

        while ": " in text:
            text = text.replace(": ", ":")
        self.title = text.split()

    def draw_image_line(self, width, line, totlines, buff):

        """
		Draws a single eye video frame, line by line.

		Arguments:

		width		--	Width of the video.
		line		--	Line nr of current line.
		totlines	--	Total lines in video.
		buff		--	Frame buffer.
		imagesize	--	The size of the image, which is (usually?) 192x160 px.
		"""

        # If the buffer hasn't been filled yet, add a line.
        for i in range(width):
            try:
                self.imagebuffer.append(self.pal[buff[i]])
            except:
                pass
                # If the buffer is full, push it to the display.
        if line == totlines:
            self.scale = totlines / 320.0
            self._size = int(self.scale * self.size[0]), int(self.scale * self.size[1])
            # Convert the image buffer to a pygame image, save it ...
            self.cam_img = pygame.image.fromstring(self.imagebuffer.tostring(), self._size, "RGBX")
            if self.extra_info:
                self.draw_cross_hair()
                self.draw_title()
            pygame.image.save(self.cam_img, self.tmp_file)
            # ... and then show the image.
            self.screen.clear()
            self.screen.draw_image(self.tmp_file, scale=1.5 / self.scale)
            self.display.fill(self.screen)
            self.display.show()
            # Clear the buffer for the next round!
            self.imagebuffer = self.new_array()

    def set_image_palette(self, r, g, b):

        """
		Sets the image palette.

		TODO: What this function actually does is highly mysterious. Figure it
		out!

		Arguments:
		r		--	The red channel.
		g		--	The green channel.
		b		--	The blue channel.
		"""

        self.imagebuffer = self.new_array()
        self.clear_cal_display()
        sz = len(r)
        i = 0
        self.pal = []
        while i < sz:
            rf = int(b[i])
            gf = int(g[i])
            bf = int(r[i])
            self.pal.append((rf << 16) | (gf << 8) | (bf))
            i += 1
开发者ID:neuropil,项目名称:EyeTribe_test,代码行数:104,代码来源:eyelinkgraphics.py

示例3: EyelinkGraphics

# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_image [as 别名]

#.........这里部分代码省略.........

		Arguments:
		msg		--	The message to be played.
		"""

		print "eyelink_graphics.alert_printf(): %s" % msg

	def setup_image_display(self, width, height):

		"""
		Initializes the buffer that will contain the camera image.

		Arguments:
		width		--	The width of the image.
		height		--	The height of the image.
		"""

		self.size = (width,height)
		self.clear_cal_display()
		self.last_mouse_state = -1
		self.imagebuffer = array.array('l')

	def image_title(self, text):

		"""
		TODO: What does this do?

		Arguments:
		text	--	Unknown.
		"""

		pass

	def draw_image_line(self, width, line, totlines, buff):

		"""
		Draws a single eye video frame, line by line.

		Arguments:

		width		--	Width of the video.
		line		--	Line nr of current line.
		totlines	--	Total lines in video.
		buff		--	Frame buffer.
		imagesize	--	The size of the image, which is (usually?) 192x160 px.
		"""

		# If the buffer hasn't been filled yet, add a line.
		for i in range(width):
			try:
				self.imagebuffer.append(self.pal[buff[i]])
			except:
				pass
		# If the buffer is full, push it to the display.
		if line == totlines:
			# First create a PIL image, then convert it to a PyGame image, and
			# then save it to a temporary file on disk. This juggling with
			# formats is necessary to show the image without distortions under
			# (so far) all conditions. Surprisingly, it doesn't cause any
			# appreciable delays, relative to directly invoking PyGame or
			# PsychoPy functions.
			bufferv = self.imagebuffer.tostring()
			img = Image.new("RGBX", self.size)
			imgsz = self.xc, self.yc
			img.fromstring(bufferv)
			img = img.resize(imgsz)
开发者ID:AA33,项目名称:PyGaze,代码行数:70,代码来源:eyelinkgraphics.py

示例4:

# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_image [as 别名]
#scr.draw_fixation()
scr.clear()
scr.draw_text("There should be three fixation targets on the screen: \
\nred cross on the left, green X in the centre, and blue dot on the right", pos=(DISPSIZE[0]/2, DISPSIZE[1]/4))
scr.draw_fixation(fixtype='cross', colour=(255,0,0), pos=(DISPSIZE[0]*0.25,DISPSIZE[1]/2), pw=3, diameter=15)
scr.draw_fixation(fixtype='x', colour=(0,255,0), pos=(DISPSIZE[0]/2,DISPSIZE[1]/2), pw=3, diameter=15)
scr.draw_fixation(fixtype='dot', colour=(0,0,255), pos=(DISPSIZE[0]*0.75,DISPSIZE[1]/2), pw=3, diameter=15)
disp.fill(scr)
disp.show()
kb.get_key()

#scr.draw_image()
scr.clear()
scr.draw_text("There should be an image in the centre of the screen", pos=(DISPSIZE[0]/2, DISPSIZE[1]/10))
scr.draw_image(imagefile)
disp.fill(scr)
disp.show()
kb.get_key()

#scr.set_background_colour()
scr.set_background_colour(colour=(200,100,100))
scr.clear()
scr.draw_text("This screen should a different background colour than the previous screen", pos=(DISPSIZE[0]/2, DISPSIZE[1]/4))
disp.fill(scr)
disp.show()
kb.get_key()
scr.set_background_colour(BGC)


# # # # #
开发者ID:AA33,项目名称:PyGaze,代码行数:32,代码来源:PyGaze_supertest.py

示例5: str

# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_image [as 别名]
	kb.get_key()
	eventfuncs[i]()
	scr.clear()
	scr.draw_text("Function %s works! Press space to test the next" % str(eventfuncs[i]))
	disp.fill(scr)
	disp.show()
	kb.get_key()


# # # # #
# test gaze contingency

# AOI
scr.clear()
scr.draw_text("There should be an image in the centre of the screen", pos=(DISPSIZE[0]/2, DISPSIZE[1]/10))
scr.draw_image(imagefile) # imginfo: 400x600 px; kitten head position relative to image x=40, y=160, w=130, h=140
x = (DISPSIZE[0]/2 - 200) + 40 # centre minus half of the image width, plus kitten head X position in image
y = (DISPSIZE[1]/2 - 300) + 160 # centre minus half of the image height, plus kitten head Y position in image
aoi = AOI('rectangle',(x,y),(130,140))
disp.fill(scr)
t1 = disp.show()
log.write(["AOI", t1])
key = None
tracker.start_recording()
while key != 'space':
	# check for key input
	key, presstime = kb.get_key(keylist=['space'],timeout=1)
	# get gaze position
	gazepos = tracker.sample()
	# check if the gaze position is within the aoi
	if aoi.contains(gazepos):
开发者ID:AA33,项目名称:PyGaze,代码行数:33,代码来源:PyGaze_trackertest.py


注:本文中的pygaze.screen.Screen.draw_image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。