Matlab slows down while plotting a figure.
7 views (last 30 days)
Show older comments
I'm coding an algorithm for lane detection,
This is the skeleton code I've used,
while ~isDone(video){
currentFrame = getFrame(video);
.
. % Do segmentation and lane detection
.
figure(1),imshow(currentFrame),hold on
figure(1),plot( theLinesThatWereDetected );
pause(.0001); % without pause the plot command wouldn't work like a streamer.
}
Problem : The output video gets slower and slower after displaying each frame, but as soon as I close the figure window it automatically restarts(as the code's running) and it gets faster(check video). Why is this happening, is there some memory build up that is happening to slow down the plotting? What can I do to fast things up other than manually closing figure window?
I know there is a video.ShapeInserter object available which is faster than the plotting method I've used . The reason I didn't use it is because the changing the thickness of lines in thee video.ShapeInserter object came only in the 2014 release and I'm using 2013 version. I wanted very distinct thick lines for my lane detection.
Kindly give me suggestions.
0 Comments
Answers (1)
Jan
on 27 Oct 2014
Edited: Jan
on 27 Oct 2014
Do you add a new plot in each iteration, e.g. triggered by a hold? Or do the plots repalce the former plots?
Anyway, it is cheaper to change the XData and YData of an existing LINE-object, which was ceated by plot(). A large number of objects in a figure slows down the processing meassively.
Search in the forum for "plot xdata" to find examples.
3 Comments
Chang Liu
on 2 Oct 2017
I'm faced the same problem, wondering if anyone can give me a clue here, I think the RAM is just rocketing with too many objects.
Jan
on 3 Oct 2017
The last statement of Aravind was: "But didn't work the way I wanted". I cannot guess, what was wanted and how it differs from the results.
Now you explain, that you have "the same problem". Please give us a chance to answer and post any details. What is your code, what do you observe and what is your question? The best would be to open a new thread.
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!