如何显示结果

39视图(30天)
THUONG NGUYEN VAN
THUONG NGUYEN VAN 2013年5月16日
回答: 的孩子叫Gogoi2017年1月10日
亲爱的,我有一个问题。我将在另一个窗口中显示结果。例如当代码运行会出现一个窗口显示位置的红色X (X, y)。如果我想显示Y = 2 * X (e.t.c)在第二个窗口。我怎么能这样做呢?
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %项目名称:红色的对象检测和跟踪% %作者:丹Bose % %版本:1.05% %描述:如何在实时视频探测和跟踪红色的物体% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %初始化redThresh = 0.25;红色%阈值检测vidDevice = imaq。VideoDevice (“winvideo”1“YUY2_640x480”,…%获得输入视频ROI, [1 1 640 480],……“ReturnedColorSpace”、“rgb”);vidInfo = imaqhwinfo (vidDevice);%获得输入视频属性hblob =愿景。BlobAnalysis (AreaOutputPort,假的,…%设置blob分析处理CentroidOutputPort,真的,…“BoundingBoxOutputPort”,真正的,…“MinimumBlobArea”, 800年,…“MaximumBlobArea”, 3000年,… 'MaximumCount', 10); hshapeinsRedBox = vision.ShapeInserter('BorderColor', 'Custom', ... % Set Red box handling 'CustomBorderColor', [1 0 0], ... 'Fill', true, ... 'FillColor', 'Custom', ... 'CustomFillColor', [1 0 0], ... 'Opacity', 0.4); htextins = vision.TextInserter('Text', 'Number of Red Object: %2d', ... % Set text for number of blobs 'Location', [7 2], ... 'Color', [1 0 0], ... // red color 'FontSize', 12); htextinsCent = vision.TextInserter('Text', '+ X:%4d, Y:%4d', ... % set text for centroid 'LocationSource', 'Input port', ... 'Color', [1 1 0], ... // yellow color 'FontSize', 14); hVideoIn = vision.VideoPlayer('Name', 'Final Video', ... % Output video player 'Position', [100 100 vidInfo.MaxWidth+20 vidInfo.MaxHeight+30]); nFrame = 0; % Frame number initialization
% %处理循环而(nFrame < 20) rgbFrame =步骤(vidDevice);%获得单帧rgbFrame = flipdim (rgbFrame 2);%获得显示镜像diffFrame = imsubtract (rgbFrame (:,: 1), rgb2gray (rgbFrame));%得到图像的红色分量diffFrame = medfilt2 (diffFrame [3 3]);%利用中值滤波器过滤掉噪音binFrame = im2bw (diffFrame redThresh);%将图像转换为二进制图像与红色对象作为白色[重心,bbox] =步骤(hblob binFrame);%的质心和边界框blob质心= uint16(重心);采取进一步措施rgbFrame %重心转换为整数(1:20,1:165:)= 0;%穿上黑色区域输出流vidIn =步骤(hshapeinsRedBox, rgbFrame bbox);% Instert对象= 1:1的红盒子:长度(bbox(: 1) %写相应的质心centX =重心(对象,1); centY = centroid(object,2); vidIn = step(htextinsCent, vidIn, [centX centY], [centX-6 centY-9]); end vidIn = step(htextins, vidIn, uint8(length(bbox(:,1)))); % Count the number of blobs step(hVideoIn, vidIn); % Output video stream nFrame = nFrame+1; end %% Clearing Memory release(hVideoIn); % Release all memory and buffer used release(vidDevice); % clear all; clc;
提前谢谢。

答案(2)

大卫·桑切斯
大卫·桑切斯 2013年5月16日
请使用{}代码选项,将有助于在告诉代码注释。
你试过
图(2)
之前显示第二个图?

的孩子叫Gogoi
的孩子叫Gogoi 2017年1月10日
使用
disp(长度(bbox (: 1));
就在while循环的结束。通过存储这个值到一个变量,您可以使用这个值为任何目的像转移arduino,然后借助液晶显示…、

类别

找到更多的在图像处理和计算机视觉帮助中心文件交换

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!