In a parking how to i find an empty parking slot

댓글 수: 1

Cedric
Cedric 2014년 6월 2일
If you have images, please attach them to your post (staple icon).

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2014년 6월 2일

0 개 추천

Huang, C.C.[Ching-Chun], Tai, Y.S., Wang, S.J.[Sheng-Jyh],
Vacant Parking Space Detection Based on Plane-Based Bayesian Hierarchical Framework,
CirSysVideo(23), No. 9, 2013, pp. 1598-1610.
IEEE via DOI 1309

댓글 수: 3

<<
>> In the following code I have to get a msgbox which should tell me that a car is removed for it's slot when i remove it ?
Code:-
%source = videoinput('winvideo',1);%clear all
% source = aviread('C:\Video\Source\traffic\san_fran_traffic_30sec_QVGA'); source = videoinput('winvideo',1); thresh = 25; im=getsnapshot(source); %(Remove this) bg = im; % read in 1st frame as background frame(change this) %bg = imread('original.jpg'); bg_bw = rgb2gray(bg); % convert background to greyscale %fg1 = bg_bw;
% ----------------------- set frame size variables ----------------------- %fr_size = size(bg); width = size(bg_bw,2); height = size(bg_bw,1); fg = zeros(height, width);
% --------------------- process frames -----------------------------------
for i = 2:100
fr = getsnapshot(source); % read in frame
fr_bw = rgb2gray(fr); % convert frame to grayscale
fr_diff = abs(double(fr_bw) - double(bg_bw)); % cast operands as double to avoid negative overflow
for j=1:width % if fr_diff > thresh pixel in foreground
for k=1:height
if ((fr_diff(k,j) > thresh))
fg(k,j) = 1;
else
fg(k,j) = 0;
end
end
end
%bg_bw = fr_bw;
figure(1),subplot(2,1,1),imshow(fr)
%subplot(3,1,2),imshow(fr_bw)
subplot(2,1,2),imshow(fg)
M(i-1) = im2frame(uint8(fg),gray); % put frames into movie
if(bg_bw==fr_bw)
else
textIn = ['Car has left the parking lot'];
ha = actxserver('SAPI.SpVoice');
invoke(ha,'speak',textIn);
h = msgbox('Car has left the parking lot');
end
end
% movie2avi(M,'frame_difference_output', 'fps', 30); % save movie as avi
Image Analyst
Image Analyst 2014년 6월 2일
I can't run the code. I don't have the m-file, the fig-file, or the avi file. Why not step through with the debugger and see what lines of code get executed and what the variable values are?
Nadeem Mohd
Nadeem Mohd 2019년 2월 22일
source = videoinput('winvideo',1); thresh = 25; im=getsnapshot(source); %(Remove this) bg = im;
% read in 1st frame as background frame(change this) %
bg = imread('C:\Users\Aatif\Desktop\Thesis\A2.PNG');
bg_bw = rgb2gray(bg);
% convert background to greyscale %fg1 = bg_bw;
% ----------------------- set frame size variables ----------------------- %fr_size = size(bg);
width = size(bg_bw,2); height = size(bg_bw,1); fg = zeros(height, width);
% --------------------- process frames -----------------------------------
for i = 2:100
fr = getsnapshot(source); % read in frame
fr_bw = rgb2gray(fr); % convert frame to grayscale
fr_diff = abs(double(fr_bw) - double(bg_bw)); % cast operands as double to avoid negative overflow
for j=1:width % if fr_diff > thresh pixel in foreground
for k=1:height
if ((fr_diff(k,j) > thresh))
fg(k,j) = 1;
else
fg(k,j) = 0;
end
end
end
%bg_bw = fr_bw;
figure(1),subplot(2,1,1),imshow(fr)
%subplot(3,1,2),imshow(fr_bw)
subplot(2,1,2),imshow(fg)
M(i-1) = im2frame(uint8(fg),gray); % put frames into movie
if ((bg_bw) ~= (fr_bw))
textIn = ('Car has left the parking lot');
ha = actxserver('SAPI.SpVoice');
invoke(ha,'speak',textIn);
h = msgbox('Car has left the parking lot');
% else
%textIn = ('Car is in the parking lot');
% ha = actxserver('SAPI.SpVoice');
%invoke(ha,'speak',textIn);
%h = msgbox('Car is in the the parking lot');
end
end
i can get the if out put
i mean its nt reading the if statement
it just gives the else out put

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2014년 6월 2일

댓글:

2019년 2월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by