Insert variable into video in Matlab -


i have 2 scripts. 1 plots luminescence of pixel in video on time , horizontally merges 2 videos. first video original video , second same video has been processed. wanted insert luminescence variable on second video in comparison video, in bottom right hand corner. think may have gotten lost somewhere though:

close clc clear  vid1 = videoreader('original.avi'); vid2 = videoreader('result.avi');  videoplayer = vision.videoplayer;  row = vid2.height/3; col = vid2.width/2;  outputvideo = videowriter('comparison.avi'); outputvideo.framerate = vid1.framerate; open(outputvideo);  while hasframe(vid1) && hasframe(vid2)     result_vid = readframe(vid2);      r = result_vid(row, col, 1);     g = result_vid(row, col, 2);     b = result_vid(row, col, 3);      lum = 0.2126 * r + 0.7152 * g + 0.0722 * b;      l = [l lum];      text_str = l;     position = [vid2.width 10];       original_vid = readframe(vid1);     imgt = horzcat(original_vid, result_vid);      plot(l)     ylim auto     xlim([0 600]);      % play video     step(videoplayer, imgt);     rgb = inserttext(imgt,position,text_str);      % record new video     writevideo(outputvideo, imgt); end  release(videoplayer); close(outputvideo); 

any great!

you writing frame contained in imgt video file. annotation contained in rgb variable.

writevideo(outputvideo, rgb); 

should fix it.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -