Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 在视频上叠加一个圆圈_Matlab_Video_Matlab Figure - Fatal编程技术网

Matlab 在视频上叠加一个圆圈

Matlab 在视频上叠加一个圆圈,matlab,video,matlab-figure,Matlab,Video,Matlab Figure,我想用MATLAB在视频中插入一个覆盖在帧上的圆。我想在某些视频帧中出现特定情况时插入圆圈。这些特殊情况将在稍后出现,但我的问题是:如何在视频中的某些帧中覆盖圆 到目前为止,我掌握的代码如下: xyloObj = VideoReader('shishe.mp4'); %% nFrames = xyloObj.NumberOfFrames; vidHeight = xyloObj.Height; vidWidth = xyloObj.Width; energy=zeros(xyloObj.Num

我想用MATLAB在视频中插入一个覆盖在帧上的圆。我想在某些视频帧中出现特定情况时插入圆圈。这些特殊情况将在稍后出现,但我的问题是:如何在视频中的某些帧中覆盖圆

到目前为止,我掌握的代码如下:

xyloObj = VideoReader('shishe.mp4');

%%
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
energy=zeros(xyloObj.NumberOfFrames,3);

% Preallocate the movie structure.

mov(1:nFrames) = ...
    struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),...
           'colormap',[]);

% Read one frame at a time.

for k = 1 : nFrames
    mov(k).cdata = read(xyloObj,k);
    b2=rgb2hls_fst(mov(k).cdata);
    r1=b2(:,:,1);
    r2=b2(:,:,2);
    r3=b2(:,:,3);
    energy(k,1)=sum(sum(r1 .* r1))/ numel(r1);
    energy(k,2)=sum(sum(r2 .* r2))/ numel(r2);
    energy(k,3)=sum(sum(r3 .* r3))/ numel(r3);
    %if(mycondition)
    %    (insert shape)
    %end    
end

我找到了我的答案,并用下面的代码来做 我通过
mov(k).cdata=insertshape(mov(k).cdata,'circle',[320 240 200],'Color',{dcolor})在每个帧中插入形状

%%
clc
范围=5;
对于k=1:n帧
平均能量=能量(k,3);
if(k>范围和&k=阈值红色)
%disp(“红色”);
dcolor='red';
elseif(平均能量>=阈值黄色)
%disp(“黄色”);
dcolor='yellow';
其他的
%显示(“绿色”);
dcolor='green';
结束
mov(k).cdata=insertShape(mov(k).cdata,'circle',[320240200],'Color',{dcolor});
结束
disp(“结束”);
内爆(mov)

你知道怎么画圆吗?你知道如何覆盖一个点吗?我找到了,tnx,我使用insertShape.tnx
%%
clc
range=5;
for k = 1 : nFrames
    meanenergy=energy(k,3);

    if(k>range &&  k< nFrames-range)
       meanenergy=mean( energy(k-5:k+5,3));
    end
    if(meanenergy >=ThresholdRed)
%         disp('red');
        dcolor='red';
    elseif(meanenergy >= ThresholdYellow )
%          disp('yellow');
         dcolor='yellow';
    else
%          disp('green');
         dcolor='green';
    end

     mov(k).cdata= insertShape( mov(k).cdata, 'circle', [320 240 200],'Color',{dcolor});
end
disp('end');
implay(mov)