Difference between video-tracking code runs in MATLAB and Simulink.
1 回表示 (過去 30 日間)
古いコメントを表示
I tested a video-tracking code developed by myself that have as input: Camera Parameters, other constant values, the camera acquisited image and the feedback values such as if the object has been found (boolean value 1/0) and the position of the found markers (5 points on xy plane, matrix [5 2]). In the following i attached part of code.
I = snapshot(cam);
I = rgb2gray(I);
[rows, cols] = size(I);
tic
[objFound , Dots , Order , RV , T , minerror] = ModelTracking_mod_v4( ..., I ,..., objPrev, oldDots , ...);
toc
if (objFound > 0)
objPrev = 1;
oldDots = Dots;
else
objPrev = 0;
oldDots = [];
end
It works fine, and the elapsed time is about 0.2 seconds.
The problem is that I need to do the same thing on Simulink so I have decided to insert the same function "ModelTracking_mod_v4" within a Matlab-Function, I have attached the Simulink layout on bottom.
With the "From Video Device" block acquire the image, if the video-tracking find the object, so objFound =1, the Input oldDots are equal of the found dots positions precedently tracked (NewDots).
If the object is not found the objFound = 0 and oldDots = [0 0; 0 0; 0 0; 0 0; 0 0;]
The tracking still works but it runs very slowly (about 1.5 seconds) in comparion between the MATLAB Model.
As "block sample time" of From Video Device block i'm using 1 because using the default value 1/30 slows down execution even more.
What could cause this behaviour (long execution time) difference between the two different development environment?
Do I wrong something? Or are there any alternative way to do the same thing?
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!