video_writ​er_linux_u​buntu

11 Ansichten (letzte 30 Tage)
Sankarganesh P
Sankarganesh P am 25 Feb. 2023
Kommentiert: Sankarganesh P am 28 Feb. 2023
%Hello friends,
%i am very new to matlab. i am using linux ubuntu 22.10. i have to create video for the matrix A(x,y,t). but i facing the the following issues.
%1.The specified folder, resiliente@resiliente-S2600STB:, does not exist
%2.if i used the path like E:\newfile.avi , am getting error like -IMG must be of one of the following classes: double, single, uint8
%kindly help me to resolve this issuse. thanks in advance
x1 = randi([0, 5], [4,4])
x2 = randi([0, 5], [4,4])
x3 = randi([0, 5], [4,4])
A(:,:,1)=x1;
A(:,:,2)=x2;
A(:,:,3)=x3;
figure
Q = size(A,3);
W = A(:,:,1);
h = pcolor(W);
drawnow();
pause(0.3);
for K = 2 : Q
W = A(:,:,K);
set(h, 'CData', W);
drawnow();
end
video = VideoWriter('resiliente@resiliente-S2600STB:/home:\newfile.avi');
video.FrameRate = 10;
open(video)
writeVideo(video, h);
close(video);

Akzeptierte Antwort

Aditya
Aditya am 27 Feb. 2023
Hi,
I understand that you are trying to create a video from images that are coming in the loop. There are multiple issues related to usage to video writer and so on.
Majorly, whenever a call is made to writeVideo, it is expecting an image frame. However, you are passing h, which is a handle to a pcolor object. Hence, you are getting the error: IMG must be of one of the following classes: double, single, uint8.
The way you can solve it is, draw pcolor on an axes and then get the image from that axes for each frame. Once, you get that image, write it to the video.
Here is a full working example,
x1 = randi([0, 5], [4,4]);
x2 = randi([0, 5], [4,4]);
x3 = randi([0, 5], [4,4]);
A(:,:,1)=x1;
A(:,:,2)=x2;
A(:,:,3)=x3;
f = figure;
ax = axes(f);
Q = size(A,3);
W = A(:,:,1);
h = pcolor(ax,W);
drawnow();
pause(0.3);
video = VideoWriter('newfile.avi');
video.FrameRate = 10;
open(video);
for K = 2 : Q
W = A(:,:,K);
set(h, 'CData', W);
drawnow();
img = getframe(f);
writeVideo(video, img);
end
close(video);
Regarding the error resiliente@resiliente-S2600STB:, does not exist.
On a linux machine, the prompt is something like this: "username@machine: path"
You only need to pick up the path from it. The path would be something like /home/..
  1 Kommentar
Sankarganesh P
Sankarganesh P am 28 Feb. 2023
This solution works for me as well, thank you so much.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by