Identify the walls, floor and the ceiling and paint each one separately

4 vues (au cours des 30 derniers jours)
zahra esp
zahra esp le 31 Juil 2019
Hello.
I intend to write code that detect the walls, floor and the ceiling and paint each one separately.
this is my code and I detected H,V lines using Hough transform from snapshot of webcam video.
function app2()
% Set-up webcam video input
vid = videoinput('winvideo', 1);
%% Set parameters for video
% Acquire only one frame each time
set(vid,'FramesPerTrigger',1);
% Go on forever until stopped
set(vid,'TriggerRepeat',Inf);
% % Get a grayscale image
% set(vid,'ReturnedColorSpace','grayscale');
triggerconfig(vid, 'Manual');
%% set up timer object
TimerData = timer('TimerFcn', {@FrameRateDisplay,vid},...
'Period',1,'ExecutionMode',...
'fixedRate','BusyMode','drop');
% Start video and timer object
start(vid);
start(TimerData);
flushdata(vid); % to clear memory
% Clear everything
stop(TimerData);
delete(TimerData);
stop(vid);
delete(vid);
imaqreset;
% This function is called by the timer to display one frame of the figure
function FrameRateDisplay(~,~,vid)
% persistent IM;
% trigger(vid);
% I=getdata(vid,1,'uint8');
NumberFrameDisplayPerSecond=5;
while(vid.FramesAcquired<=NumberFrameDisplayPerSecond)
I = getsnapshot(vid);
IM = rgb2gray(I);
%% Inhancement Image
IM = imbilatfilt(IM,...
'degreeOfSmoothing',0.01*diff(getrangefromclass(IM)).^2,...
'spatialSigma',1);
IM = edge(IM,'canny');
dilatedImage = imdilate(IM,strel('disk',1));
IM = bwmorph(dilatedImage,'open');
%% Perform Hough Transform
% [H, theta, rho]=hough(IM);
[H, theta, rho] = hough(IM,'Theta',-90:90:89,'RhoResolution',2);
%% Find Hough Peaks
% Threshold = 0.4*max(H(:));
% p = houghpeaks(H,10,'Threshold',Threshold);
p = houghpeaks(H,10);
%% Find Lines
FillGap = 10;
MinLength = 20;
lines = houghlines(IM,theta,rho,p,...
'FillGap',FillGap,...
'MinLength',MinLength);
%% Show Result
figure;
imshow(IM)
hold on;
for k=1:numel(lines)
Color = [0 1 0];
Start = lines(k).point1;
End = lines(k).point2;
plot([Start(1) End(1)],[Start(2) End(2)],...
'-','LineWidth',1,'MarkerSize',8,'Color',Color);
end
end
now, I want to know
1) how to improve H,V lines detection? (for example the walls detection)
2) how to color walls?

Réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by