Info

This question is closed. Reopen it to edit or answer.

How to make a combination of real time video GUI?

1 view (last 30 days)
nurul najmah
nurul najmah on 21 Oct 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
clear all; %real time acquisition Vid=imaq.VideoDevice('winvideo', 1, 'RGB24_320x240'); Vid.ReturnedDataType='double';
%display in video player hvp=vision.VideoPlayer; hEdge = vision.EdgeDetector( ... 'Method', 'Sobel', ... 'ThresholdSource', 'Property', ... 'Threshold', 15/256, ... 'EdgeThinning', true);
WindowSize=[290 250]; hVideoOrig=video.VideoPlayer('WindowCaption','Original'); hVideoOrig.WindowPosition=[10 hVideoOrig.WindowPosition(2) WindowSize];
hVideoEdges=video.VideoPlayer('WindowCaption','Edges'); hVideoEdges.WindowPosition=[110 hVideoEdges.WindowPosition(2) WindowSize];
hVideoRGBEdges=video.VideoPlayer('WindowCaption','RGB_Edges'); hVideoRGBEdges.WindowPosition=[210 hVideoRGBEdges.WindowPosition(2) WindowSize];
hVideoFill=video.VideoPlayer('WindowCaption','Fill'); hVideoFill.WindowPosition=[310 hVideoFill.WindowPosition(2) WindowSize];
hVideoPoint=video.VideoPlayer('WindowCaption','Point Location'); hVideoPoint.WindowPosition=[410 hVideoPoint.WindowPosition(2) WindowSize];
%live streaming nFrames=0; while (nFrames<200) img1=step(Vid); %Read input image img2=rgb2gray(img1);%rgb to binary imgEg=step(hEdge,img2);%edge detection
img4=im2bw(img2);%gray to binary
imgDiffuse= imfuse(img1,img4,'blend','Scaling','joint');
imwrite(imgDiffuse,'my_blend_overlay.png');
imgOverlay= imread('my_blend_overlay.png');
% Go across columns of image looking for last white pixel in the column. [rows, columns] = size(img4); % Output fill from bottom image img5 = false(rows, columns); % Initialize % Go across columns of image looking for last white pixel in the column. for col = 1:columns thisColumn = img4(:, col); lastRow= find(thisColumn, 1,'last'); img5(lastRow:end, col) = true; end %morphological operation se = strel('disk',5); img6=imclose(img5,se); img7 = imerode(img6,strel('disk',5)); img8=imdilate(img7,strel('disk',5));
%point location row=find(sum(img8,2)==0,1,'last')+1; col=find(img8(row,:)~=0); row=row(ones(size(col))); Points=[row(:) col(:)]; imshow(img8); title('Highest Point Location') hold on plot(Points(:,2),Points(:,1),'rs','MarkerSize',10)
%path vision img9 = imfuse(img1,img8,'blend','Scaling','joint'); imwrite(img9,'my_blend_overlay.png'); img0= imread('my_blend_overlay.png'); hold on plot(Points(:,2),Points(:,1),'rs','MarkerSize',10) title('Free Area Path Motion');
nFrames=nFrames+1;
step(hVideoOrig,img1);%display original step(hVideoEdges,imgEg);%display edge step(hVideoRGBEdges,imgOverlay);%display fill step(hVideoFill,img8);%display fill step(hVideoPoint,img0);%display point location end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!