Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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
String Matlab中的增量字符串_String_Matlab_Increment - Fatal编程技术网

String Matlab中的增量字符串

String Matlab中的增量字符串,string,matlab,increment,String,Matlab,Increment,我使用的是一个背景简单的视频,每当有人经过时都会提示一条警告信息 clear all myVideoObj = VideoReader('video.avi'); nFrames = myVideoObj.NumberOfFrames; sound = wavread('somethingwrong.wav'); flag = 1; % Read one frame at a time. for i = 2 : nFrames-1 frame1 = read(myVideoObj,

我使用的是一个背景简单的视频,每当有人经过时都会提示一条警告信息

clear all

myVideoObj = VideoReader('video.avi');

nFrames = myVideoObj.NumberOfFrames;
sound = wavread('somethingwrong.wav');
flag = 1;

% Read one frame at a time.
for i = 2 : nFrames-1
    frame1 = read(myVideoObj, i-1); frame2 = read(myVideoObj, i);
    diff = abs(rgb2gray(frame1) - rgb2gray(frame2));

    if sum(sum(diff)) < 46000
        imshow(frame2, [])
        drawnow
    else 
        imshow(frame2, [])
        text(100, 100, 'Intruder!!!' , 'FontSize',24)
        drawnow
    end
end
全部清除
myVideoObj=VideoReader('video.avi');
nFrames=myVideoObj.NumberOfFrames;
声音=wavread('somethingwread.wav');
flag=1;
%一次读一帧。
对于i=2:n帧-1
frame1=读取(myvideobj,i-1);frame2=读取(myVideoObj,i);
diff=abs(rgb2gray(帧1)-rgb2gray(帧2));
如果总和(总和(差值))<46000
imshow(第2帧,[])
刷新屏幕
其他的
imshow(第2帧,[])
文本(100100,“入侵者!!!”,“字体大小”,24)
刷新屏幕
结束
结束

这支索起作用了。但是现在我想知道如何为每个路过的人增加字符串。我怎么开始?提前感谢

您是否试图使文本在每次检测到入侵者时都增加一个计数器(因此这包含在“入侵者!!!”消息中)?如果是这样,您应该能够通过以下方式完成此任务:

您可以创建字符串变量和计数器:

message_string = 'Intruder #';
count = 1;
然后每次你找到一个新的人,你都会设置一个新的消息字符串:

total_message = strcat(message_string, num2str(count));
将被发送到文本功能:

text(100, 100, total_message, 'FontSize', 24)
然后增加计数

如果这不是您问题的答案,请澄清您为每个经过的人增加字符串的意思