Why does my image acquisition loop become unstable after a prolonged period of time when using the Image Acquisition Toolbox?
3 views (last 30 days)
Show older comments
I am using the following code to retrieve data from my image acquisition hardware:
vid = videoinput('winvideo');
for i = 1:3000
start(vid);
wait(vid);
data = getdata(vid);
end
However, I notice that my image acquisition session either freezes or crashes with the following segmentation violation:
------------------------------------------------------------------------
Segmentation violation detected at Tue Feb 07 21:47:39 2006
------------------------------------------------------------------------
Configuration:
MATLAB Version: 7.1.0.246 (R14) Service Pack 3
MATLAB License: DEMO
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 2)
Processor ID: x86 Family 15 Model 3 Stepping 4, GenuineIntel
Virtual Machine: Java 1.5.0 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
Default Charset: windows-1252
Register State:
EAX = 00000010 EBX = 0dcd0ff0
ECX = 00000002 EDX = 78c50003
ESI = 0dcd1000 EDI = 000cc8d0
EBP = 00cdc164 ESP = 00cdc12c
EIP = 58014abb FLG = 00010202
Stack Trace:
[0] kswdmcap.ax:0x58014abb(0x0da9ee1c, 16, 0, 640)
[1] mwdx.dll:private: class std::map<double,__int64,struct std::greater<double>,class std::allocator<struct std::pair<double const ,__int64> > > const & __thiscall mwdx::VideoCaptureGraph::queryFrameRates(void)(0, 262147, 0x030c01b4, 0x03789708) + 424 bytes
[2] 0x00000cc8(0x58015266, 0x580147d8, 0x5801483d, 0x5801489f)
[3] kswdmcap.ax:0x5801524c(0x8b08458b, 0x75fff840, 0x50088b0c, 0xc25d11ff)
[4] 0x1075ffec
<snip>
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
Since some hardware device drivers, such as winvideo, were not designed to support repetitive device initialization from within a loop, it is good practice to exclude a call to START from the body of a loop.
As a workaround, you can initialize the device using the START command from outside the loop, and then use manual triggers to retrieve data from within the loop. For example, the code above would change to the following:
vid = videoinput('winvideo');
triggerconfig(vid,'Manual');
set(vid,'TriggerRepeat',inf);
start(vid);
for i = 1:3000
trigger(vid);
wait(vid);
data = getdata(vid);
end
stop(vid);
delete(vid);
clear vid;
0 Comments
More Answers (0)
See Also
Categories
Find more on National Instruments Frame Grabbers 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!