Incorrectly getting a blank video when using videowriter function to display data
11 views (last 30 days)
Hello, I am having a difficulty with writing and displaying a video for data that is meant to represent multiple frames that have been corrected for motion. I am essentially stabilizing the motion of a "shaky" video. I am still learning how to use Matlab within my research so this could be lack of coding experience on my end.
I am not receiving any error message but rather getting a video output of a blank video. In the first section, I am correcting the frame offsets. "Stabilized" should be the data used that I want to represent in a movie. When calling on it as a singular and averaged frames figure, I receive what I expect. The "Stabilized" file contains Y axis, X axis, RGB, and number of frames. The second section is my attempt to write a movie of my data which is where I believe I might be doing it incorrectly. I followed the examples provided in youtube and under "Help: Videowriter" in the command row, but nothing has worked. If more information is needed, please do not hesistate to ask. I greatly appreciate the help.
Walter Roberson on 28 Sep 2022
You are not changing the display between getframe() so all of the frames would be the same.
If you have pre-computed frames stored in stabilized then write them directly, like
for i = 1 : size(stabilized,3)
currFrame = stabilized(:,:,:,i);
And... you should be sure to initialize stabilized to the appropriate data type, such as
stabilized = zeros([2 2 1 1].*size(video), 'like', video);
which I suspect was the major source of your problem with the output being white.