Overlay visual stimuli on to a video

2 次查看(过去 30 天)
I'm currently using Psychtoolbox to attempt to write a visual task on top of a video background, and looking at EEG patterns and response times. I'm currently attempting to adapt the Demo function "DetectionRTInVideoDemo" to do this and not having much luck. Could anyone tell me if there is a way to either 1. create a transparent screen where stimuli can be placed while still viewing the video underneath, or 2. placing small pictures (e.g. small circles) over top of the texture at certain times in the video ?

采纳的回答

Mihaela Duta
Mihaela Duta 2016-11-4
If you need an image with transparent background, you can create it in other packages, for example GIMP
In your script, you first need to read the image with the transparent background together with the information about the alpha channel:
[img_data ~ img_alpha] = imread(img_fname); img_data(:,:,4) = img_alpha(:,:);
When opening the psychtoolbox window, enable alpha blending
Screen('BlendFunction', theWindow, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Create the texture for the image
img_tex = Screen('MakeTexture', win, double(img_data));
In the main loop of movie playback, overlay the image texture over every movie texture
Screen('DrawTexture', win, movietexture);
Screen('DrawTexture', win, img_tex);
  3 个评论
Walter Roberson
Walter Roberson 2016-11-8
[imdata, imgmap, imgalpha] = imread(...)
You appear to be using R2008b or earlier
Joanna Scanlon
Joanna Scanlon 2016-11-9
It was on 2012b, but yes this makes sense. Thanks!

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2016-10-27
If you were drawing in MATLAB instead of using the Psychtoolbox drawing routines, then you could place image() objects on top of the display (set the sorting order to be sure it is on top; see http://blogs.mathworks.com/graphics/2014/11/04/sortmethod/) . Set the AlphaData channel of the image objects to 0 in the places where what is behind is to show through and set it to 1 in the places where the overlay stimulus is to show.

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by