Overlay visual stimuli on to a video
3 views (last 30 days)
Show older comments
Joanna Scanlon
on 27 Oct 2016
Commented: Joanna Scanlon
on 9 Nov 2016
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 ?
0 Comments
Accepted Answer
Mihaela Duta
on 4 Nov 2016
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 Comments
Walter Roberson
on 8 Nov 2016
[imdata, imgmap, imgalpha] = imread(...)
You appear to be using R2008b or earlier
More Answers (1)
Walter Roberson
on 27 Oct 2016
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.
0 Comments
See Also
Categories
Find more on Timing and presenting 2D and 3D stimuli in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!