Hi Jordan,
I looked at the video and these are my suggestions.
The key elements of your system will be a loop that executes every "m" seconds:
1. Recognition: I am not sure if they are acquiring the images of the box or simply scanning the bar code. The recognition system definitely keeps detecting if the object is present and is also most probably responsible for the delay in the rendering.
If I had to do this in MATLAB, I would use either Instrument Control Toolbox or Image Acquisition Toolbox to acquire the data.
I am still not sure how they are capturing the orientation of the box. If that can be figured out, translating that to a 3D coordinate system mentioned in 3 is achievable.
If it is 3D or even 2D, consider using functions from the Image Processing Toolbox.
2. Database search and matching: I will only answer this for image data which would be a difficult problem to solve as 3D object recognition is not easy. If it is a bar code, then the answer is trivial. I would first start writing this algorithm to do the matches fast!
3. Rendering: Simulink 3D Animation will work just fine for this. Once the recognition is done, you can DYNAMICALLY create and delete objects from a library file that you have created. The VRML node that you will need is the PROTO node. The uniqueness of this node is that you can create a library of objects and then dynamically call them during execution from within MATLAB.
I have created a small example to explain the dynamic behavior in VRML. Follow the instructions carefully and you should be able to see the effect. I use a random variable as my signal generator for my dynamic rendering: if it is >0.5, I display a sphere or else a pyramid.
The first step is to copy paste the following code in Notepad and save it as world.wrl:
#VRML V2.0 utf8
#Created with V-Realm Builder v2.0
#Integrated Data Systems Inc.
#www.ids-net.com
SpotLight {
direction 0 0 -1
location 0 4.2 0
}
DEF transform Transform {
translation 0.577873 -0.395051 -4.21423e-008
scale 0.4 0.4 0.4
children DEF TextNode Shape {
appearance Appearance {
material Material {
}
}
geometry DEF TextString Text {
string "A"
fontStyle FontStyle {
family "SANS"
style "BOLDITALIC"
}
}
}
}
The second step would be to copy the following code into the MATLAB editor and then execute it. Make sure that world.wrl is in the current working directory:
% get the path to the wrl file with marker PROTOs. This exists in MATLAB
% installation directories
pathtomarkers = which('vr_markers.wrl');
% If you do >>edit(pathtomarkers), you should be able to view the nodes in
% the MATLAB editor. Alternatively, navigate to the folder and open it with
% VRealm Builder
world = vrworld('world.wrl', 'new');
open(world);
fig = vrfigure(world);
% use the tetrahedron shape
MarkerName1 = 'Marker_Sphere';
MarkerName2= 'Marker_Pyramid';
% create an EXTERNPROTO with specified marker
try
addexternproto(world, pathtomarkers, MarkerName1);
addexternproto(world, pathtomarkers, MarkerName2);
catch ME
% if required PROTO is already contained don't throw an exception
if ~strcmpi(ME.identifier, 'VR:protoexists')
throwAsCaller(ME);
end
end
% Initialize loop variable i for sake of demo
i=0;
while (i<10)
a=rand(1);
TextNode=vrnode(world, 'TextString');
setfield(TextNode,'string',num2str(a));
if a>0.5
newMarker = vrnode(world, sprintf('%s_%d', 'Marker', i), MarkerName1);
newMarker.markerScale=[1 1 1];
else
newMarker = vrnode(world, sprintf('%s_%d', 'Marker', i), MarkerName2);
newMarker.markerScale=[3 3 3];
newMarker.markerColor=[0 0 1];
end
vrdrawnow;
i=i+1;
pause(1)
delete(newMarker)
end
close all force;
This should show how to do this. Take a look at vrmarkers.wrl file contained in
which('vr_markers.wrl')
to see how the library of dynamic (PROTO) objects are created. Remember that during this creation, you need to define markerColor and markerScale as the nodes that reference these nodes. You may have to do this manually by editing the WRL file as a text file.
More information on PROTO declarations can be found here:
http://graphcomp.com/info/specs/sgi/vrml/spec/part1/concepts.html#Prototypes
Hope this helps.
Thanks,
Saurabh