필터 지우기
필터 지우기

"Dot indexing is not supported for variables of this type." error in reading VideoReader Object by its index?

조회 수: 5 (최근 30일)
I am working in video shot boundary detection, for that I need to read a specific video frame by its index, But in such cases when the video is read by its index in the main file, it runs perfectly but when it is ran in a seperate function, It gives an error "Dot indexing is not supported for variables of this type. in matlab", I am providing the code for which it is givning the error.
V=VideoReader("anni007.mpg");
if class1(1)>2
A=final(class1,V); % class1 is a frame transition numbers
else
class1 = class1(2:length(class1));
A=final(class1,V);
end
function A2 = final(C,V)
count = 1; th1 = 0.2; th2 =1;th3= 1;
for i = 1:length(C)
St = StdDifference(V,C(i));
if (St(2) > th1 && St(3)< th1 && St(1) < th1)
A2(count) = C(i);
count = count + 1;
end
end
end
function d = StdDifference(V,i)
count = 1;
for j=i-2:i+1
I = read(V,j);% This line the code gives error of "Dot indexing is not supported for variables of this type" I cannot understand why?
J = read(V,j+1);
Ir_std = std2(I(:,:,1));
Ig_std = std2(I(:,:,2));
Ib_std = std2(I(:,:,3));
Jr_std = std2(J(:,:,1));
Jg_std = std2(J(:,:,2));
Jb_std = std2(J(:,:,3));
d(count) = sqrt((Ir_std-Jr_std)^2+(Ig_std-Jg_std)^2+(Ib_std-Jb_std)^2);
count = count + 1;
end
end
  댓글 수: 5
Jan
Jan 2022년 5월 5일
편집: Jan 2022년 5월 6일
@INDRANATH ROY: I've tried to format the code properly.
"Dot indexing is not supported for variables of this type" I cannot understand why?" - I cannot understand this also, because this line does not contain any dot. So please post the complete error message, which should tell also, in which line the error occurs.
Walter Roberson
Walter Roberson 2022년 5월 5일
If the VideoReader call failed then that read() might be the first place affected.
Also I wonder if there is additional code beyond what was posted, with that additional code happening to have a "clear all"

댓글을 달려면 로그인하십시오.

답변 (1개)

yanqi liu
yanqi liu 2022년 5월 7일
yes,sir,may be use VideoReader to make video to frame image file list,and then use the images to analysis,such as
function nFrames = GetVideoImgList(videoFilePath)
xyloObj = VideoReader(videoFilePath);
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
[pathstr, name, ext] = fileparts(videoFilePath);
video_imagesPath = fullfile(pwd, sprintf('%s_images', name));
if ~exist(video_imagesPath, 'dir')
mkdir(video_imagesPath);
end
files = dir(fullfile(video_imagesPath, '*.jpg'));
if length(files) == nFrames
return;
end
h = waitbar(0, '', 'Name', 'process...');
steps = nFrames;
for step = 1 : nFrames
temp = read(xyloObj, step);
temp_str = sprintf('%s\\%04d.jpg', video_imagesPath, step);
imwrite(temp, temp_str);
pause(0.01);
waitbar(step/steps, h, sprintf('%d%%', round(step/nFrames*100)));
end
close(h)

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by