clear all; clc; close all; testName = 'CB2'; % Test = Start End X Y W H vidParams = [240 2800 0 0 720 480]; fileName = '../../Tyco Warehouse Tests/TYCO_30FT_ CLASS III DRY.wmv'; startTime = vidParams(1) ; % Start capturing at this frame endTime = vidParams(2) ; % End capturing at this frame fps = 3 ; % Frame sampling rate found by x/28 cropArea = [vidParams(3) vidParams(4) vidParams(5) vidParams(6)] ; % [x, y, width, height] of rectangle to crop vidCheck = 0 ; % Should frames be saved to a video for verification? 1 for yes, 0 for no showEdges = 0 ; % Show pic, color edge, and edge comparison images for each frame vid = mmreader(fileName); nframes = (startTime:fps:endTime); limits = [3.6 13.5]; % Area limits for cardboard for plotting test_cb2_time_coarse = (1:61)'; test_cb2_mass_coarse = [9.80000000000000;9.77000000000001;9.74000000000001;9.70000000000001;9.66000000000001;9.62000000000001;9.56000000000001;9.50000000000001;9.43000000000001;9.35000000000001;9.26000000000001;9.16000000000001;9.05000000000001;8.94000000000001;8.82000000000001;8.70000000000001;8.58000000000001;8.46000000000001;8.34000000000001;8.22000000000001;8.10000000000001;7.98000000000001;7.86000000000001;7.75000000000001;7.64000000000001;7.53000000000001;7.41000000000001;7.28000000000001;7.16000000000001;7.05000000000001;6.94000000000001;6.83000000000001;6.73000000000001;6.64000000000001;6.55000000000001;6.47000000000001;6.40000000000001;6.34000000000001;6.28000000000001;6.22000000000001;6.16000000000001;6.09000000000001;6.02000000000001;5.96000000000001;5.91000000000001;5.85000000000001;5.80000000000001;5.76000000000001;5.71000000000001;5.67000000000001;5.63000000000001;5.59000000000001;5.56000000000001;5.52000000000001;5.48000000000001;5.44000000000001;5.40000000000001;5.37000000000001;5.34000000000001;5.30000000000001;5.26000000000001]-5.26; mass_cb2_time = (0:1/(30/fps):18)'; mass_cb2_data = interp1(test_cb2_time_coarse, test_cb2_mass_coarse, mass_cb2_time, 'spline'); % from the video script test_cb2_time_coarse = (0:18)'; test_cb2_heights_coarse = [0; 2.48; 4.14; 2.76; 5.65; 5.24; 3.45; 6.345; 5.24; 10.07; 6.90; 9.93; 10.76; 9.52; 16.55; 20.14; 13.24; 17.93; 17.38]; test_cb2_time = (0:1/(30/fps):18)'; test_cb2_heights = interp1(test_cb2_time_coarse, test_cb2_heights_coarse, test_cb2_time, 'spline'); % Using a B-number of 1.69 from test cb2 predicted_time_coarse = (0:18)'; predicted_flameheights_coarse = [2;2.03389108370960;2.52009766647539;3.05836286841823;3.64868668953811;4.29106912983505;4.98551018930903;5.73200986796006;6.53056816578814;7.38118508279327;8.28386061897545;9.23859477433467;10.2453875488709;11.3042389425843;12.4151489554746;13.5781175875421;14.7931448387865;16.0602307092080;17.3793751988066]; predicted_time = (0:1/(30/fps):18)'; predicted_flameheights = interp1(predicted_time_coarse, predicted_flameheights_coarse, predicted_time, 'spline'); % Large Scale predictions ls_pred_time_coarse = (0:99)'; ls_pred_coarse = [0.150000000000000;0.185812849798796;0.211317918633652;0.238462701016695;0.267247196947925;0.297671406427343;0.329735329454949;0.363438966030741;0.398782316154721;0.435765379826889;0.474388157047244;0.514650647815786;0.556552852132516;0.600094769997433;0.645276401410537;0.692097746371829;0.740558804881308;0.790659576938975;0.842400062544829;0.895780261698870;0.950800174401099;1.00745980065152;1.06575914045012;1.12569819379691;1.18727696069189;1.25049544113505;1.31535363512641;1.38185154266595;1.44998916375368;1.51976649838959;1.59118354657369;1.66424030830598;1.73893678358646;1.81527297241513;1.89324887479198;1.97286449071702;2.05411982019025;2.13701486321166;2.22154961978126;2.30772408989905;2.39553827356503;2.48499217077919;2.57608578154154;2.66881910585208;2.76319214371081;2.85920489511772;2.95685736007282;3.05614953857611;3.15708143062759;3.25965303622725;3.36386435537510;3.46971538807114;3.57720613431537;3.68633659410778;3.79710676744838;3.90951665433717;4.02356625477414;4.13925556875930;4.25658459629265;4.37555333737419;4.49616179200392;4.61840996018183;4.74229784190793;4.86782543718221;4.99499274600469;5.12379976837535;5.25424650429420;5.38633295376123;5.52005911677646;5.65542499333987;5.79243058345147;5.93107588711125;6.07136090431923;6.21328563507539;6.35685007937974;6.50205423723227;6.64889810863299;6.79738169358190;6.94750499207900;7.09926800412429;7.25267072971776;7.40771316885942;7.56439532154927;7.72271718778730;7.88267876757352;8.04428006090793;8.20752106779053;8.37240178822131;8.53892222220028;8.70708236972744;8.87688223080279;9.04832180542632;9.22140109359805;9.39612009531795;9.57247881058605;9.75047723940233;9.93011538176680;10.1113932376795;10.2943108071403;10.4788680901493]; ls_pred_time = (0:1/(30/fps):100)'; ls_pred = interp1(ls_pred_time_coarse, ls_pred_coarse, ls_pred_time, 'spline'); % UL exp. heights ul_exp_time_coarse = (0:90)'; ul_exp_coarse = [0.459765909999793,0.467612115299846,0.478105003541934,0.491244574726058,0.507030828852218,0.525463765920414,0.546543385930646,0.570269688882914,0.596642674777218,0.625662343613558,0.657328695391933,0.691641730112345,0.728601447774792,0.768207848379275,0.810460931925795,0.855360698414350,0.902907147844941,0.953100280217568,1.00594009553223,1.06142659378893,1.11955977498766,1.18033963912843,1.24376618621124,1.30983941623608,1.37855932920296,1.44992592511188,1.52393920396283,1.60059916575581,1.67990581049083,1.76185913816789,1.84645914878699,1.93370584234812,2.02359921885128,2.11613927829648,2.21132602068372,2.30915944601299,2.40963955428430,2.51276634549765,2.61853981965303,2.72695997675045,2.83802681678990,2.95174033977139,3.06810054569491,3.18710743456047,3.30876100636807,3.43306126111770,3.56000819880937,3.68960181944308,3.82184212301882,3.95672910953659,4.09426277899640,4.23444313139825,4.37727016674214,4.52274388502806,4.67086428625601,4.82163137042600,4.97504513753803,5.13110558759209,5.28981272058819,5.45116653652633,5.61516703540650,5.78181421722871,5.95110808199295,6.12304862969923,6.29763586034754,6.47486977393789,6.65475037047028,6.83727764994470,7.02245161236116,7.21027225771965,7.40073958602019,7.59385359726275,7.78961429144735,7.98802166857399,8.18907572864267,8.39277647165338,8.59912389760612,8.80811800650090,9.01975879833772,9.23404627311657,9.45098043083747,9.67056127150039,9.89278879510535,10.1176630016523,10.3451838911414,10.5753514635725,10.8081657189456,11.0436266572607,11.2817342785179,11.5224885827171,11.7658895698583]; ul_exp_time = (0:1/(30/fps):91)'; ul_exp = interp1(ul_exp_time_coarse, ul_exp_coarse, ul_exp_time, 'spline'); n = 1; edges = []; xcoeff = polyfit(test_cb2_time, test_cb2_heights, 2); yfit = polyval(xcoeff, test_cb2_time); j = 1; for i = nframes singleFrame = read(vid, i); % Grab a single frame from the movie I = imcrop(singleFrame, cropArea); % Crop the image to just the cone fig = figure; image(I); hold on set(gca,'handlevisibility','off', 'visible','off') axes('position',[0.13,0.11,0.775,0.815]) set(gca,'visible','off') plot(ls_pred_time(1:j), ls_pred(1:j),'g--', 'LineWidth', 1.8); hold all plot(ul_exp_time(1:j), ul_exp(1:j), 'c','LineWidth', 1.8); text(1, 1.5, 'Actual', 'FontSize', 18, 'Color', 'c', 'FontWeight', 'Bold') text(20, 0.6, 'Predicted', 'FontSize', 18, 'Color', 'g', 'FontWeight', 'Bold') set(gca, 'xlim',[0.0 90]); set(gca, 'ylim',[0.0 10]); set(gca,'Color','None'); tit = title('Actual vs. Predicted Flame Heights - UL Test'); set(gca,'FontSize',18,'FontWeight','bold'); xlabel('Time (s)'); ylabel('Flame Height (m)'); set(tit,'FontSize',22,'FontWeight','bold'); filename = (['Frames/mov_', num2str(n) '.jpg']); print('-djpeg','-r100',filename) close if vidCheck == 1 vidOut(n).cdata = singleFrame; vidOut(n).colormap = []; end if showEdges == 1 close all; figure; subplot(1,3,1), imshow(I), title('Flame Original'); subplot(1,3,2), imshow(edges), title('Flame Edges RGB'); subplot(1,3,3), imshow(I4), title('Combined RG edges'); pause(1); end n = n + 1; j = j + 1; end % actualHeight = pixelHeight / 7.25; % Convert pixels to cm % figure; plot(actualHeight,'bo'); set(gca,'XTick',0:30/fps:endTime); set(gca,'XTickLabel',0:1:60);