opencv - EMGU crashes when trying to write out greyscale image to VideoWriter -


can tell me why emgu throws exception when trying write out greyscale image? here do:

gcam.startacquisition(); debug.writeline("recording...");

        //bitmap safeimage = new bitmap(xiimagewidth, xiimageheight,          //system.drawing.imaging.pixelformat.format8bppindexed);          bitmap safeimage = new bitmap(xiimagewidth, xiimageheight,                                                                system.drawing.imaging.pixelformat.format16bppgrayscale );          //emgu.cv.image<gray, byte> currentframe;         emgu.cv.image<gray, uint16> currentframe;          gcam.getimage(safeimage, xi_capture_timeout);          //currentframe = new image<gray, byte>(safeimage);         currentframe = new image<gray, uint16>(safeimage);         currentframe.save("testimage.bmp");          starttime = datetime.now;          if (emguvideowriter.ptr != intptr.zero)         {                 emguvideowriter.writeframe(currentframe);         } 

when use mono8 , image have no problem, if try go 16-bit exception:

a first chance exception of type 'system.argumentexception' occurred in system.drawing.dll exception caught while recording frame! ex=system.argumentexception: parameter not valid.    @ system.drawing.bitmap.getpixel(int32 x, int32 y)    @ emgu.cv.image`2.set_bitmap(bitmap value) in c:\emgu\emgucv-windows-x64 2.4.0.1717\emgu.cv\image.cs:line 2866    @ emgu.cv.image`2..ctor(bitmap bmp) in c:\emgu\emgucv-windows-x64 2.4.0.1717\emgu.cv\image.cs:line 213 

this has been driving me crazy don't see why cannot write out 16-bit images. hoping videowriter make life easier instead complicating matters. feel writing out raw bytes myself @ point!

i think may have found answer. line 2669 of image.cs (emgu source code) says this:

    /*     //pixelformat.format16bppgrayscale not supported in .net     else if (typeof(tcolor) == typeof(gray) && typeof(tdepth) == typeof(uint16))     {        return new bitmap(           size.width,           size.height,           step,           pixelformat.format16bppgrayscale;           scan0);     }*/ 

not supported! wish exception said this!


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -