Always when I try to create an .avi video out of matrices I get the following error: Invalid video data - must be numeric or logical data type.
function [video] = CreateVideo(obj)
video = VideoWriter('test.avi');
video.FrameRate = 1;
open(video)
% loop 2d matrix sequence with ones and zeros and create video
for i_inc = 1 : size(obj.square_move_seq_, 3)
gray_img = double(obj.square_move_seq_(:, :, i_inc));
img = cat(3, gray_img, gray_img, gray_img);
writeVideo(video, img);
end
% Finalize the video file.
close(video);
end
Does somebody have a clue what I do wrong?
Thank you very much in advance.

 採用された回答

Image Analyst
Image Analyst 2017 年 8 月 19 日

0 投票

Try
writeVideo(video, uint8(img));

6 件のコメント

baxbear
baxbear 2017 年 8 月 19 日
Sorry to say this, but nothing changed -> still the same error
Image Analyst
Image Analyst 2017 年 8 月 19 日
編集済み: Image Analyst 2017 年 8 月 19 日
Please give the ENTIRE error message - ALL the red text - not just a small snippet snipped out of it.
You can see my attached demos for a way that works.
Also explain why you convert grayImage to double(). Why??? Did someone incorrectly tell you to do that?
baxbear
baxbear 2017 年 8 月 20 日
編集済み: baxbear 2017 年 8 月 20 日
There is no red text, what I have is only the error message in the implay window (Invalid video data - must be numeric or logical data type.)
clear all
clc
sq = TestSquare(10, [1, 1]);
sq.Move(1, 1);
sq.NextStep();
sq.Move(1, 2);
sq.NextStep();
% CreateVideo() is a method from TestSquare
implay(sq.CreateVideo())
PS.: I used double because I was hoping to fix the error this way.
baxbear
baxbear 2017 年 8 月 22 日
didn't work because I used close in CreateVideo()
Image Analyst
Image Analyst 2017 年 8 月 22 日
So, is it solved now? Or do you still have a problem?
baxbear
baxbear 2017 年 8 月 27 日
編集済み: baxbear 2017 年 8 月 27 日
Yes, this particular problem is solved. I still have some problems with the visualisation but I will open a separate thread for it.
Thank you very much.

サインインしてコメントする。

その他の回答 (0 件)

タグ

質問済み:

2017 年 8 月 19 日

編集済み:

2017 年 8 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by