MATLAB: Does the Image Acquisition Toolbox 1.7 (R14SP1) crash when using ‘grayscale’ for the ‘ReturnedColorSpace’ property

acquisitionassertioncrashgrayscaleimageImage Acquisition Toolboximaqreturnedcolorspacesegmentationsegvviolation

I am using the Image Acquisition Toolbox, and I would like to set the ‘ReturnedColorSpace’ device property to ‘grayscale’. For example, I might use the following code:
vid = videoinput('winvideo');
set(vid, 'ReturnedColorSpace', 'grayscale');
start(vid)
data = getdata(vid);
delete(vid)
However, MATLAB issues a segmentation violation, requiring me to restart. For example, I may receive a segmentation violation such as:
------------------------------------------------------------------------
Assertion detected at Fri Nov 19 14:02:43 2004
------------------------------------------------------------------------
Assertion failed: hdr->in_use != 0, at line 736 of file ".\memmgr\memcache.cpp".
Attempt to free previously freed memory
Stack Trace:
[0] bridge.dll:_mnSignalHandler(0xffffffff, 0, 0, 0x79c99b80) + 303 bytes
[1] bridge.dll:void __cdecl ThrowAssertion(void)(0x0337c3b8, 0x78775b98, 0x65737341, 0x6f697472) + 164 bytes
[2] bridge.dll:void __cdecl MATLABAssertFcn(char const *,char const *,int,char const *)(0x7874d4ec ": hdr->in_use != 0,", 0x7874d328 ".\memmgr\memcache.cpp", 736, 0x7874c590 "Attempt to free previously freed..") + 110 bytes
[3] libut.dll:_mw_free(0x0337c3c0 "?ioSetPutsFcn@@YAXP6AHPBDPAU_iob..", 0x00cde9bc "ÔéÍ", 0x78792a08, 0x0337c3c0 "?ioSetPutsFcn@@YAXP6AHPBDPAU_iob..") + 584 bytes
[4] libut.dll:_utFree(0x0337c3c0 "?ioSetPutsFcn@@YAXP6AHPBDPAU_iob..", 0x0337c3c0 "?ioSetPutsFcn@@YAXP6AHPBDPAU_iob..", 0x2033dcc4, 0x00cde9d4 "äéÍ") + 100 bytes

Best Answer

This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified that there is a bug in Image Acquisition Toolbox 1.7 (R14SP1) when setting the ‘ReturnedColorSpace’ device property to ‘grayscale’.
To work around this issue, try setting the ‘ReturnedColorSpace’ property to ‘YCbCr’. In doing so, the data returned will consist of 3 bands: Y, Cb, and Cr. The first band of the returned data, Y, can be used as the grayscale data.