c# - Frame Capture using Matrox Commands -
i'm working on project have set fps of video stream (as 10) camera , grab frame every 5th frame. i'm working on program has been half written else. thing is, have used matrox framegrabber dlls. there matrox frame grabber on device. cant find commands framegrab in c#. found following code c++.
mil_id mdispalloc(systemid, dispnum, dispformat, initflag, displayidptr)
where
mil_id systemid; system identifier long dispnum; display number char *dispformat; display format name or file name long initflag; initialization flag mil_id *displayidptr; storage location display identifier
the above command allocates display. can please me write program in c#. also, experience in matrox dlls please give me idea on how approach frame capture , fps set up. thanks.
this new matrox framegrabber. first thing should add matrox dll reference. aware there 2 matrox versions out- matrox 9 , matrox 10. depending on version of matrox installed in user system dll should added. (this can checked looking "mil_path" in system directories. then, declare variables used in matrox grabbing.
some of mine below:
public static mil_id milapplication = mil.m_null; // application identifier. public static mil_id milsystem = mil.m_null; // system identifier. public static mil_id mildisplay = mil.m_null; // display identifier. public static mil_id mildigitizer = mil.m_null; // digitizer identifier. public static mil_id milimage = mil.m_null; // image identifier. public static mil_id milrecord = mil.m_null; // 8 bit pointer video recording. public mil_int milint = mil.m_null; public mil_int nbpixelsptr = mil.m_null; mil_id milimagedisp = mil.m_null; mil_id[] milgrabbufferlist = new mil_id[buffering_size_max];
then run following code
string milsystemdet = ""; milsystemdet = environment.getenvironmentvariable("mil_path"); if (milsystemdet != null) { string dcffilepath = ""; filedialog openfile = new openfiledialog(); openfile.filter = "file formats(*.dcf)|*.dcf;"; if (openfile.showdialog() == dialogresult.ok) { dcffilepath = openfile.filename; mil.mdigalloc(milsystem, mil.m_default, dcffilepath, mil.m_default, ref mildigitizer); mil.mbufalloc2d(milsystem, mil.mdiginquire(mildigitizer, mil.m_size_x, mil.m_null), mil.mdiginquire(mildigitizer, mil.m_size_y, mil.m_null), 8 + mil.m_unsigned, mil.m_image + mil.m_disp + mil.m_grab, ref milimage); mil.mdispalloc(milsystem, mil.m_default, ("m_default"), mil.m_default, ref mildisplay); mil.mdighalt(mildigitizer);
when want start capture, run following
mil.mbufclear(milimage, 0); mil.mdiggrabcontinuous(mildigitizer, milimage); mil.mdispcontrol(mildisplay, mil.m_view_mode, mil.m_auto_scale); mil.mdispcontrol(mildisplay, mil.m_scale_display, mil.m_enable);
to copy current image buffer, use
mil.mbufget(milimage, mybuffer);
where mybuffer ushort buffer size equal total number of pixels in image.
to save current image file, use
mil.mbufsave(address,milimage);
if dont have .dcf file can default 1 matrox installation cd free. or install matrox viewer , in program files can have one. image parameters such width, height , bit depth got dcf file. if want, can allocate them in mbufalloc2d function above.
i'll try check answer periodically. if has questions ask me. ill try answer them best of knowledge.