Matlab slows down while plotting a figure.

6 Ansichten (letzte 30 Tage)
Aravind
Aravind am 26 Okt. 2014
Kommentiert: Jan am 3 Okt. 2017
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.
}
This is a video of the simulation, Simulation
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.

Antworten (1)

Jan
Jan am 27 Okt. 2014
Bearbeitet: Jan am 27 Okt. 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 Kommentare
Chang Liu
Chang Liu am 2 Okt. 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
Jan am 3 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by