Difference between image processing in a loop
显示 更早的评论

I'm currently doing object counting on a traffic light model. After I can count the vehicle, I'm trying to put the codes into a loop to get same results. The variables gotten in the loop is similar to the one that without the loop but I couldn't get the same results.

The area that it is counting is the road beside the vehicle while doing it in the loop.
bgd=snapshot(cam)
hfig = figure;
while isvalid(hfig)
img = snapshot(cam);
('segmentation and counting code')
end
pause(1)
end
Are there any solutions to this?
回答(1 个)
Image Analyst
2018-7-13
There is nothing wrong with the loop itself. The problem is with this:
('segmentation and counting code')
That code is not robust. Fix that.
8 个评论
Adrian Lim
2018-7-13
Image Analyst
2018-7-13
编辑:Image Analyst
2018-7-13
Sure.
But first make sure that it's well commented and you use descriptive variable names.
No one wants to look at 10 pages of alphabet soup. If it is, the line above would be my first improvement suggestion.
Adrian Lim
2018-7-13
Image Analyst
2018-7-13
The first part of the code is missing, like the part where you read your image or video into img.
Adrian Lim
2018-7-14
Image Analyst
2018-7-14
Sorry but my camera is not looking at your scene.
Adrian Lim
2018-7-14
Adrian Lim
2018-7-14
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!