Home
Link to the user and technical guide
Contents
1. 1 mxIsClass output uint16 amp amp ULNG mxGetM output Width Page 37 Technical Guide June 2000 amp amp ULNG mxGetN output Height amp amp PixelDepth 2 mxIsClass output uint32 amp amp ULNG mxGetM output Width amp amp ULNG mxGetN output Height amp amp PixelDepth 4 p mxGetPr output Grab an image from the framegrabber result OlFgAcquireFrameToHost int d Frameld p Height Width PixelDepth switch result case OLC_STS_NORMAL mexPrintf Image has been grabbed n mexPutArray output caller OlFgDestroyFrame int d FrameId break case OLC STS INVALIDFRAMEHANDLE mexPrintf Invalid Framehandle n mexErrMsgTxt Unable to grab an image n return case OLC STS BUFSIZ mexPrintf Buffersize is too small n mexErrMsgTxt Unable to grab an image n return case OLC STS NULL mexPrintf Pointer supplied is NULL n mexErrMsgTxt Unable to grab an image n return default mexPrintf Unknown error n mexErrMsgTxt Unable to grab an image n return The full source code can be found in the src directory of the Matlab Interface For DT Mach Framegrabbers Development Kit 10 5 Getfg c This functions returns a value of the parameter you requested You can update the device info structure by using this function with as the only input argument your device info str
2. O INC INC52 INC57 INCCO outdir OUTDIR disp Compiling openfg com strcat SOURCE openfg c mex com O INC INC52 INC57 INCCO LIB outdir OUTDIR disp Compiling closefg com strcat SOURCE closefg c mex com O INC INC52 INC57 INCCO LIB outdir OUTDIR disp Compiling mainfg com strcat SOURCE mainfg c mex com O INC INC52 INC57 INCCO outdir OUTDIR code example 2 Source buildall m Page 30 Technical Guide June 2000 10 Source Codes In this chapter we describe the differences between the old FGI 1998 and the new FGI 2000 We also explain some part of the changed source code 10 1 Code optimization First we will give an explanation of the Open Layer calls and the error return codes The FGI MEX functions make use of the frame grabber Open Layer functions these function calls will normally return an ok code If the function does not succeed it will return an error code In the MEX files a switch statement catches this return code If it was an error message Matlab will display an appropriate message in the Matlab Command Window The error handling in the MEX files is done by the MEX function mexErrMsgTxt This function will destroy all existing matrices made by the MEX file and it will return control to the Matlab environment Another way of exception handling is the MEX function called mexWarnMsgTxt This function will
3. OLC STS RANGE destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 03 mexPrintf Difference between whitelevel and blacklevel too large n mexErrMsgTxt Unable to grab an image n return OLC_STS_FRAMETOP destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf Frame top exceeds active line count n mexErrMsgTxt Unable to grab an image n return OLC STS FRAMEWIDTH destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf Frame width not multiple of 4 or exceeds active pixel count Wn mexErrMsgTxt Unable to grab an image n return OLC STS FRAMEHEIGHT destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf Frame height will cause digitalisation to exceed active pixel mexErrMsgTxt Unable to grab an image n return OLC STS HSYNCSEARCHPOS destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf H sync search position precedes H sync insert position n mexErrMsgTxt Unable to grab an image n return OLC STS VSYNCSEARCHPOS destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf V sync search position precedes V sync insert position n mexErrMsgTxt Unable to grab an image n return OLC STS INTERLACEDHGTGRAN destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker mexPrintf Frame
4. VSyncSearchPos VSynclInsertPos SyncValue BlackLevel WhiteLevel For an explanation of these parameters see appendix table 1 See appendix table 2 for the allowance availability to get a parameter from the selected frame grabber Output If the input isn t valid or the frame grabber can t get the parameter value of the chosen parameter name some error message will be shown to the user If everything s ok it will return the parameter value parvalue of the chosen parameter name of the device Example To get the black level that will be stored in the variable bl and assuming that the variable m stores the device info of the current frame grabber type bl getfg m BlackLevel 6 1 5 Set a parameter of the DT frame grabber device DLL name setfg dll Syntax setfg devinfo parname parvalue or setfg devinfo Description This function will let the user set a parameter of a DT frame grabber device Setfg m lists all the possible variables Input The device information structure devinfo of the opened frame grabber device the parameter name parname of the parameter that has to be set and the parameter value parvalue of that parameter Remarks It will be verified if the first input argument is a valid device information structure and if the second input argument is a parameter name If it s valid it will try to get the device id from the device information structure To get t
5. he time in seconds required for an action to occur before the operation times out 1 The currently used hardware filter he frame type you want to acquire when grabbing an image 1 d he first line of video relative to the active video area to digitize 1 d he first pixel of video relative to the active video area to digitize 1 The number of pixels per line of video to digitize 1 d he number of lines per field of video or noninterlaced frame to digitize he increment between adjacently sampled pixels in pixels he increment between adjacently sampled lines in lines he total pixels per line i e the no of pixels in a single horizontal line of video he period between the horizontal sync signal and the start of the active video signal he start position indicating the beginning of an area in ixels where the Framegrabber clamps the video signal as a ixel value offset from the beginning of the horizontal sync 1 d he end position indicating the beginning of an area in pixels here the Framegrabber clamps the video signal as a pixel value ffset from the beginning of the horizontal sync o he beginning of the active video signal on the line as a pixel value offset from the beginning of the horizontal sync 1 1 he number of pixels per line in pixels in the active video area 1 The number of lines in a single field of video where a field is defined as a area between t
6. KKK KKK KKK KK KKK KKK KKK KK KKK KKK KKK ck Ck Ck KKK KKK OR KR KK DR RR RR RA Filename grabfg c SC Authors D J Oei A Kapoerchan XX Date 10 July 1998 FA Last update by original authors 17 August 1998 RAT Modified by R Heil C L Wauters 17 April 2000 ER Last update by R Heil C L Wauters 01 June 2000 Xx Modified by L I Oei M A E Bakker Page 42 Technical Guide June 2000 Updates source cleaned up and properly indented 2002 07 02 EK destroy frame on errorexit 2002 07 03 PER improved error messages after acquire frame 2002 07 04 OR KR KK RK kk k Ck kk Ck k kc k Ck kCk Ck Ck kCk Ck kc k Ck k kc OK k k Ck k kc k Ck k k Kk k kc k k ko k ck kok ck kokok ck kok ck RA This C file contains the source code to grab an image xo ERRAR k Ck k k CK k kc k Ck kk k Ck k k Ck k k Kk Ck k e k kc k k k ck k kok ck kok ck ck kok ck ke ke ke x kx x Syntax imgmatrix grabfg devinfo x LEX moviematrix grabfg devinfo imgmatrix imgmatrix moviematrix grabfg devinfo KF ZE grabfg devinfo imgmatrix los grabfg devinfo imgmatrix moviematrix grabfg devinfo imgmatrix moviematrix scaling factor OR KR KK KR RR k Ck k k Ck kk k Ck kc kc k kk k Ck k kc k Ck kc k Ck kck k kok ck k kok k ck k ck kokok ck ko ke ke ke kA x x d include lt mex h gt include lt stdlib h gt include windows h finclude olwintyp h include olimgapi
7. ck Sk ck ck KK Framesize info Get the default vertical frame inc result OlFgQueryInputControlValue Deviceld InputSource OLC FG CTL VER FRAME INC amp VerFrameInc DEF checkError result vertical frame inc KKK ck ck ck ck ck ck KKK KKK KKK ck ck ck ck ck ck ck ck ck KKK ck kk ck ck ck ck ck ck ck ck ck ck ck AE ck ck kk ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck kk ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck kk code example 6 Call DEF checkError check c In the old switch see code example 3 the case of OLC STS NORMAL breaks and the MEX function continues execution The other cases return because of the mexErrMsgTxt function call and exit directly the MEX function returning the control to Matlab The same functionality is obtained in check c figurel illustrates the new situation Page 33 Technical Guide June 2000 OLC_STS_NORMAL OLC_STS_NULL OLC_STS_CONTROL OLC_STS_INPUTSOURCE OLC_STS_NONOLMSG default Continue Mexfunction Exit Mexfunction figurel Error handling DEF checkError schematically Page 34 Technical Guide June 2000 The main issue of code example 4 is that in the case of OLC_STS_CONTROL a variable in this example FirstActivePixel 1 will be set and the MEX function continues The new function call in openfg will assign the value of the variable in the case of OLC_STS_CONTROL The other states except OLC STS NORMAL return and exit the MEX function d
8. ck ck ko ck sk Sk Sk ck ck KEK code example 3 Switch openfg Page 31 Technical Guide June 2000 In the openfg source code we found a variant of code example 3 In this version the value of a variable will be set when the SDK returns an OLC_STS_CONTROL state in this example FirstActivePixel 1 This means that the setting is not supported Important in this switch is that the OLC_STS_NORMAL and the OLC_STS_CONTROL state break This means that the MEX file still continues because there was no return statement like the other cases The variant of code example 3 in openfg will be shown ck ck ck ck ck ck KKK KKK KK KKK KKK KKK KKK KKK KKK KKK KKK KKK ck ck ck KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK ck ck ck ck ck ck ck ko ck KKK KK kk Videosize info Get the default value of the First Active Pixel result OlFgQueryInputControlValue DeviceId inputSource OLC FG CTL FIRST ACTIVE PIXEL amp FirstActivePixel switch result case OLC_STS_NORMAL break case OLC_STS_NULL mexPrintf Pointer supplied is NULL n mexErrMsgTxt Unable to get the First Active Pixel n return case OLC_STS_CONTROL mexPrintf Undefined input control n mexWarnMsgTxt Unable to get the First Active Pixel n FirstActivePixel 1 break case OLC STS INPUTSOURCE mexPrintf Illegal inputsource supplied n mexErrMsgTxt Unable to get the First Active Pixel n return case O
9. contents of the appropriate directory Page 28 Technical Guide June 2000 9 Compiling and Linking We made an M file to have a possibility for compiling and linking the MEX source files easily In the first part of the M file we define the default locations for some include files and libraries At the time we wrote this document the following directories were standard General include files y software dt fgsdk32 include DT3152 include files y software dt fgsdk32 include dt3 152 DT3157 include files y software dt fgsdk32 include dt3 157 ColorSDK include files y software dt fgsdk32 include colorsdk Open Layer Libraries y software dt fgsk32 lib olimg32 lib and olfg32 lib If you run the M file it will first ask you for the sourcedir this is the directory were the MEX source files exist After that you will have to give the output directory this is the directory were the Dynamic Link Libraries are placed after compilation and linkage Below you will find the source code of buildall m oo oe M file for compiling and linking the FGI source files oo jo sDate 01 06 2000 amp Copyright c 2000 R Heil C L Wauters SSYNTAX buildall o oe oo DESCRIPTION File for easily compiling and linking the FGI source files oe oo INPUT The user is asked to input the source directory and output directory oe oo EXAMPLE buildall oo oe INC Iy software dt fgsdk
10. device Remarks It will be verified if the input is a string If it s valid string the function will return the device information structure of the device Output If the input isn t valid some error message will be shown to the user If everything s ok the function will return a device information structure of the opened frame grabber device Example To regain the handle to the frame grabber type in the Matlab Command Window m gethandlefg DT3155 Page 24 User Manual June 2000 7 Troubleshooting Question If I set a parameter why does the devinfo structure that was retrieved when opening the device not display the new value Answer When you set a parameter you have to update the structure by yourself if you want Use getfg devinfo to do that Question If I execute a function nothing happens and I have to wait for about 10 seconds until I can continue with running functions in the Matlab Command Window Answer The timeout of the frame grabber is set at an initial value of 10 seconds So the device will try to execute its functions for 10 seconds After these 10 seconds it will stop and returns to the Matlab function You can make this time out shorter by changing the time out parameter with the setfg function Question If I grab an image and show this in Matlab with the image function it won t be shown correctly i e it is transposed How can I correct this Answer If an image is grabbed in M
11. device list the other functions should then be able to communicate with this main function for retrieving and storing global data This main function will be accessible from the Matlab interface it is even possible to manipulate the open device list if necessary The openfg dynamic link library has five functions for manipulating the open devices list These functions are e Add adds a device to the open device list this function is mainly used in the openfg function Syntax mainfg add deviceName lt string gt deviceHandle lt integer gt Return value lt none gt e Remove removes a device from the open device list It is used in the closefg function Syntax mainfg remove deviceName lt string gt Return value lt none gt e Check is able to check if a device is open or not This function could be used for example in openfg to check if the device is already open or not Syntax mainfg check deviceName lt string gt Return value Yes or No e Get returns the device handle for the given device name Syntax mainfg get deviceName lt string gt Return value device handle lt integer gt e Print built in for testing purposes it will show a listing of the open devices Syntax mainfg print Return value it will print the open devices list We will give an example how the mainfg stores the alias name and the device handle deviceld in the main structure For t
12. display a warning message in the Matlab Command Window but the MEX file will keep control and Matlab will continue executing the MEX file We discovered that in a lot of the Matlab functions there were same kinds of case statements An example from openfg KKK ck KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KK KKK kk kkkkkk kk KK ck ck ck ck ck ck ck ck ck KKK KK KK Framesize info Get the default vertical frame inc result OlFgQueryInputControlValue Deviceld InputSource OLC FG CTL VER FRAME INC amp VerFramelInc switch result case OLC_STS_NORMAL break case OLC_STS_NULL mexPrintf Pointer supplied is NULL n mexErrMsgTxt Unable to get the vertical frame inc n return case OLC STS CONTROL mexPrintf Undefined input control n mexErrMsgTxt Unable to get the vertical frame inc n return case OLC STS INPUTSOURCE mexPrintf Illegal inputsource supplied n mexErrMsgTxt Unable to get the vertical frame inc n return case OLC_STS_NONOLMSG mexPrintf Unsupported or unknown message passed n mexErrMsgTxt Unable to get the vertical frame inc n return default mexPrintf Unknown error n mexErrMsgTxt Unable to get the vertical frame inc n return ck ck ck ck ck ck KKK KKK KKK kk ck ck ck ck ck ck ck ck ck ck KKK KKK ck ck ck KKK KKK ck ck ck KKK ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck
13. h include olfgapi h include Dtcolors h Added by M Bakker 2002 07 03 18 25 this subroutine calls OlFgDestroyFrame to release resources that were not properly released when another error was encountered during the grabbing 7 void destroyFrameOnErrorExit OLT_IMG_DEV_ID Deviceld OLT FG FRAME ID Frameld OLT_APISTATUS result result OlFgDestroyFrame DeviceId FrameId switch result case OLC_STS_NORMAL break case OLC_STS_BUSY mexPrintf Still busy with acquisition n mexPrintf Failed to destroy allocated resources while recovering from the break case OLC_STS_INVALIDFRAMEHANDLE mexPrintf Invalid frame handle n mexPrintf Failed to destroy allocated resources while break case OLC_STS_FRAMENOTALLOCATED mexPrintf Frame not allocated n mexPrintf Failed to destroy allocated resources while break case OLC_STS_NONOLMSG mexPrintf Unsupported or unknown message passed to the device mexPrintf Failed to destroy allocated resources while recovering from break case OLC_STS_FRAMEISMAPPED mexPrintf Cannot destroy a frame that is still mapped n mexPrintf Failed to destroy allocated resources while recovering from break default mexPrintf Unknown error n mexPrintf Failed to destroy allocated resources while recovering from the error break return case OLC_STS_BUSY destroyFrameOnErrorExit OLT IMG DEV ID DeviceId Frameld M Bakker 2002 07 03 mexPrintf Acquis
14. 32 include INC52 Iy software dt fgsdk32 include dt3152 INC57 Iy software dt fgsdk32 include dt3157 INCCO Iy software dt fgsdk32 include colorsdk LIB y software dt fgsdk32 lib olimg32 lib y software dt fgsdk32 lib olfg32 lib disp SSOURCE input Enter the source directory example g sourcedir gt s SOURCE Src SOUTDIR input Enter the output directory example g matlab gt s OUTDIR Bin SOURCE strcat SOURCE disp disp Building FGI source files disp disp Compiling setfg com strcat SOURCE setfg c Page 29 Technical Guide June 2000 mex com O INC INC52 INC57 INCCO LIB outdir OUTDIR disp Compiling getfg com strcat SOURCE getfg c mex com O INC INC52 INC57 INCCO LIB outdir OUTDIR disp Compiling loadfg com strcat SOURCE loadfg c mex com O INC INC52 INC57 INCCO LIB outdir OUTDIR disp Compiling resetfg com strcat SOURCE resetfg c mex com O INC INC52 INC57 INCCO LIB outdir OUTDIR disp Compiling grabfg com strcat SOURCE grabfg c mex com O INC INC52 INC57 INCCO LIB outdir OUTDIR disp Compiling isopenfg com strcat SOURCE isopenfg c mex com O INC INC52 INC57 INCCO outdir OUTDIR disp Compiling gethandlefg com strcat SOURCE gethandlefg c mex com
15. E destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker mexPrintf Invalid Framehandle n mexErrMsgTxt Unable to grab an image n return OLC STS CLAMP destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 03 mexPrintf Clamp start exceeds clamp end n mexErrMsgTxt Unable to grab an image n return OLC_STS_VERTICALINC dest royFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf Vertical increment not equal to 1 n mexErrMsgTxt Unable to grab an image n return OLC STS FIRSTACTPIX destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf First active pixel exceeds backporch start or clamp start n mexErrMsgTxt Unable to grab an image n return OLC_STS_ACTPIXCOUNT dest royFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf Active line area is not between backporch start and total pixels per mexErrMsgTxt Unable to grab an image n return OLC STS ACTLINECOUNT destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf Active line count exceeds total lines per field in mexErrMsgTxt Unable to grab an image n return OLC STS FRAMELEFT destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker mexPrintf Frame left exceeds active pixel count n mexErrMsgTxt Unable to grab an image n return
16. LC STS NONOLMSG mexPrintf Unsupported or unknown message passed n mexErrMsgTxt Unable to get the First Active Pixel n return default mexPrintf Unknown error n mexErrMsgTxt Unable to get the First Active Pixel n return KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK ck ck ck ck ck ck ck ck ck ck ck ko KKK ck ck KK code example 4 Variant switch openfg We noticed in the old FGI source that the return statements after the mexErrMsgTxt are obsolete because the Matlab environment regains control after a mexErrorMsgTxt So it will never execute the return code To increase the readability of the code we decided to make an overall C file check c where the case statement will be executed with the proper parameter The error message which will be shown in the Matlab Command Window will be Unable to get the lt parameter gt For example Unable to get the FrameType A part of check c will be shown ck ck ck ck ck ck ck ck 0k 0k 0k 0k RR RR O RR RR RR A void DEF checkError OLT APISTATUS result char error 30 char errorStr 80 strcpy errorStr Unable to get the Page 32 Technical Guide June 2000 strncat errorStr error 30 switch result case OLC_STS_NORMAL break case OLC_STS_NULL mexPrintf Pointer supplied is NULL n mexErrMsgTxt errorStr case OLC_STS_CONTROL mexPr
17. Matlab Interface For Data Translation Mach Frame grabbers User Manual amp Technical Guide Last updated July 2002 D J Oei A Kapoerchan 1998 Prague Czech Technical University Czech Republic Modified by R Heil C L Wauters June 2000 Modified by M A E Bakker L I Oei July 2002 User Manual June 2000 Matlab Interface For Data Translation Mach Frame grabbers User Manual amp Technical Guide DJ Oei D J Oei twi tudelft nl A Kapoerchan A Kapoerchan twi tudelft nl August 18 1998 Modified by R Heil R Heil Qtwi tudelft nl C L Wauters C L Wauters twi tudelft nl June 2000 Modified by M A E Bakker maarten panic et tudelft nl L I Oei L I Oei twi tudelft nl July 2002 D J Oei A Kapoerchan 1998 Prague Czech Technical University Czech Republic Modified by R Heil C L Wauters June 2000 Modified by M A E Bakker L I Oei July 2002 Page 1 User Manual June 2000 Page 2 User Manual June 2000 Contents PARTE User Manual i alari 5 l Imntrodu tion conicnaiate E 6 1 1 General descriptions nenorime e a a instant 6 1 2 Brick Matlab description anasa NEE 6 1 3 Hardware requimerments i e doce edge e Ee ia 6 2 About Frame grabbers siennes ae 7 3 Matlab E 10 4 How to use this interface sicccisecsscesnsestscdstessscsvconecssntesvacsesevusebstenesconeseecoayeass 12 5 The data EN 14 6 The EGLIUNCHONS ora 16 6 1 Basie functions as A lola 16 6 1 1 Open a DT frame grabber devic
18. alization file InputSource TimeOut BlackLevel WhiteLevel TotalPixPerLine BackPorchStart ClampStart ClampEnd FirstActivePixel TotalLinesPerFld FirstActiveLine ActiveLineCount FrameLeft FrameTop FrameWidth FrameHeight HorFramelnc VerFramelInc InputFilter FrameType VideoType Page 40 Technical Guide June 2000 If one of these features is not supported it will just be ignored In the case that it is supported but if an illegal argument is given it will throw a warning message The oadfg function will continue and tries to set the other variables Page 41 Technical Guide June 2000 11 Changes July 2002 In July 2002 some small bugfixes were aplied in the process of studying the FGI to build a new FGI for different frame grabber models 11 1 The clear all bug When typing clear all or clear mex from within Matlab the open device data on frame grabbers that were still open was lost Every time this occurred Matlab had to be closed and restarted to be able make use of the FGI functions again The solution to this was found in using the mexLock function from within fgmain The implementation of a separate fgmain function in the 2000 version made this easy solution possible Below is a part of the source code of fgmain to show the changes kk ck ck ck ck ck KKK KKK KKK KKK KK KKK KKK KKK KKK KKK KKK ck ck Ck KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK Ck Ck KKK KKK void mexFunction i
19. ameHeight HorFramelnc VerFramelnc TotPix BackPorch ClampStart ClampEnd FirstPix PixCount TotalLines FirstLine LineCount Page 14 User Manual VideoType SyncTresHold SyncSource LineLo2Hi FieldLo2Hi SyncSentinel HSyncSearchPos HSyncInsertPos VSyncSearchPos VSyncInsertPos SyncMaster BlackLevel WhiteLevel For an explanation of these fields see Table 1 June 2000 Page 15 User Manual June 2000 6 The FGI functions 6 1 Basic functions The user of this interface can do the following with the basic functions e Openor re open a DT frame grabber device e Close a DT framegrabber device e Grab an image from the DT frame grabber device e Geta parameter of the DT frame grabber device e Set a parameter of the DT frame grabber device These functions are DLL s that can be executed in the Matlab workspace by just typing the DLL name with if necessary some input arguments 6 1 1 Open a DT frame grabber device DLL name openfg dll Syntax devinfo openfg alias Description This function will let the user open a DT frame grabber device The user has to give the frame grabbers alias as input argument The user already knows this alias If the device is already open a warning will be printed and the devinfo structure will be returned Input The alias alias of the frame grabber device Remarks It will be verified if the input is a valid string If it s valid it will try to open the frame grabber d
20. atlab it will be stored column wise into a Matlab matrix The image will be shown transposed if you just type image img where img is the matrix where you stored the image To correct this type image img So the transposed image will be transposed again and it will be correctly shown in Matlab Question If I use loadfg devinfo setting ini the values didn t change at all when calling getfg devinfo What happened Answer You have to type in the full pathname and filename Page 25 June 2000 PART II Technical Guide Page 26 Technical Guide June 2000 7 Introduction The technical guide is mainly meant for developers who want to enhance or make changes to this Matlab interface In this guide we will describe what we ve included in the Matlab interface for DT Mach Frame grabbers Development Kit D J Oei and A Kapoerchan have written the original technical guide in 1998 This technical guide has been updated en partly rewritten by R Heil and C L Wauters June 2000 and by M A E Bakker and L I Oei July 2002 after bug fixing the Matlab FGI source code Some knowledge about frame grabbers is required to understand some source code that is shown in this guide The FG SDK manual should help you to understand the source code The latest revision of FGI was tested using Matlab 5 3 the environment and compiler of MS Visual C 6 0 was used for building the program For a complete explanation of the changes made in 2000
21. ayer are the boards Because DT Open Layers uses the Windows Dynamic Link Library DLL feature for its function libraries and device drivers you can generally update or replace your board without recompiling Because it is device independent you must query the DT Open Layer to find out what it can and can t do With this information you can tell the user that some action is allowed or not There are basic functions described in the FG SDK manual With these functions you are able to write your own code to control the frame grabber The capability of the frame grabber The basic thing is to get the device open do your work and close the device It isn t that easy You must first identify a DT Open Layer device before any work can be done So what are the most basic things that all DT open Layer devices will be able to do Page 7 User Manual June 2000 The basic steps are e Get the number of DT Open Layers compliant devices in the system Get the device information like alias Open each device Determine the capabilities for each opened device Determine the controls for each supported device capability Program the supported controls as necessary Use the device and close it when finished You can write an easy demo Because all the function are given you are able to make your own demo work The names they are using are very long but the function s name gives a general idea about its functionality Memory usage DT Open Lay
22. ble indicating whether the frame grabber has been opened or not e gethandlefg Returns the handle of the opened frame grabber device as a device information structure We created one internal function mainfg June 2000 This function will be used internally by the other function For further explanation see the technical guide All the functions will be explained in chapter 6 after the description of the used types and structures The functions can be executed in the Matlab Command Window With each function there s a M File included with the same name of the function By typing for example help openfg information about that function will be shown in the Command Window of Matlab The 19 files 10 DLL s amp 9 M files should be put together in one directory Then if you re in the Matlab Command Window you should go to that specific directory before you can execute these files An other way to run these is to use the Matlab Command addpath path This command will add the specified path where these functions are stored in the Matlab Search Path Definition so you can execute the functions from any directory you want Page 12 User Manual June 2000 We will open the frame grabber DT3155 and grab 50 images set the black level and the white level see table 1 for description of these 2 parameters and show these 50 images in Matlab You can create a M File to do this The M File would look like this kkkkkkkkkkkkkkkkkkkkkkkk
23. e idea about the working of the frame grabber Some actions you can do with acquire e Itis possible to grab an image synchronically or a synchronically in host and device memory It is also possible to grab multiple frames synchronically or a synchronically but only in device memory e Ask to find out how the job is ready or not e Ask for input capabilities and set them e Ask for settings of the video source and some other things e Cancel a job acquisition of a frame e How should the frame be triggered Camera We use the PULNIX cameras The camera s control consists of digital output signals or generating camera control pulses The commands you can issue are e Let the pulse generator give a pulse e You can ask for the camera s control capabilities and characteristics of the frame and the device driver e You can set the digital output masks for the camera Five types of DT Open Layer Devices There are five types of DT Open Layer devices which we had to work with Data Translation 3152 DT3152 B W variable scan frame grabber Accommodates also analog cameras producing non TV formats Data Translation 3153 DT3153 Color frame grabber for PAL and NTSC format Data Translation 3155 DT3155 B W TV format frame grabber CCIR and RS 170 Data Translation 3157 DT3157 Frame grabber for digital cameras Data Translation 3133 DT3133 Color Frame grabber for digital cameras Page 9 User Manual June 2000 3 Ma
24. ers devices use two memory types volatile and non volatile Volatile memory is a pre defined memory area that can be changed Non volatile memory is a pre defined memory area too but the difference is that the user can only change it No one else may change it The reason why volatile memory is available is that you might need a lot of memory and the best way is then to overwrite your original memory area Another reason is the use of non standard input devices Then to allow the format or dimensions of the memory to be altered for any given acquisition Once the format of the data is altered the data is no longer valid There are 2 ways to store an image store it in the host memory or in the device memory Host memory is the available physical memory in your system Device memory is a contiguous block of host memory that is allocated to the device driver during system start up The amount you want to allocate is done when you install the drivers To explain what can be done with memory just a raw idea Allocate memory for a frame to store in And of course destroy the allocated memory Ask information about frame Ask for memory capabilities Some pixel works write read Page 8 User Manual June 2000 It is also important to know how the frame is grabbed You must also know a few things before grabbing some words e Video Signal e Active Video Area e Frame How these things work are good to know It will give you an insid
25. es oio o nde Heine mn ir de 16 6 1 2 Close a DT frame grabber device ritrae ria 17 6 1 3 Grab an image from the DT frame grabber device sss 17 6 1 4 Get a parameter from the DT frame grabber device 19 6 1 5 Set a parameter of the DT frame grabber device sss 20 6 2 Advanced TUNIC OBS EE 22 6 2 1 Reset a DT frame grabber device ela 22 6 2 2 Load settings for a camera from a file i 23 6 2 3 Check the status of a DT framegrabber device sess 24 6 2 4 Returning the handle of a DT frame grabber device 24 7 Troubleshooting E 25 PART IE Techncal Guide iaia rea 26 7 Introduction Ronald ri 27 8 The necessary programs and files rsrrrrrrerrcreeereneseseeeceneesesecesecnnene 28 9 Compiling and Limkmg aiar 29 10 SOUL CE CodeS tram nintendo 31 10 1 Code ODIHHZdblOE eege ee 31 10 2 fer 36 10 3 TEEN 37 10 4 EE 37 10 5 Cell EE 38 10 6 Stalla talea 38 10 7 Reset ira 39 10 8 IR ee 39 10 9 implementation Inr 2A S 39 11 Changes TL er LR 42 11 1 Th clear all bus icaro lia riti 42 11 2 Improverients 1n srabfo ornano ie tera 42 11 3 Comments on openfg cir Ire 45 12 ADPDENdICES cuocere Eed dE ER EE RO ae 47 Page 3 User Manual June 2000 Appendices e Table 1 Description of the parameters of the device info structure e Table 2 Possible values of the parame
26. evel 500000 InputFilter AcNone FrameType FrameOdd VideoType Composite Channel 1 BlackLevel 4000 WhiteLevel 500000 InputFilter AcNone FrameType FrameEven VideoType Composite Channel 2 BlackLevel 4000 WhiteLevel 500000 InputFilter AcNone FrameType FrameEven VideoType Composite Page 23 User Manual June 2000 6 2 3 Check the status of a DT framegrabber device DLL name isopenfg dll Syntax isopenfg alias Description This function will let the user check whether the frame grabber device has been opened or not It will return an integer Input The alias alias of the frame grabber device Remarks It will be verified if the input is a string If it s valid the function will return a double 1 when open O when closed Output If the input isn t valid some error message will be shown to the user If everything s ok the function will return an integer indicating the status of frame grabber device If the function returns 1 the frame grabber has been opened otherwise the function returns zero Example To check if a frame grabber has been opened or not type in the Matlab Command Window isopenfg DT3155 6 2 4 Returning the handle of a DT frame grabber device DLL name gethandlefg dll Syntax gethandlefg alias Description This function will return the handle of the frame grabber device when you lost the handle to the device Input The alias alias of the frame grabber
27. evice with that specific alias If more than one frame grabber is installed in the computer it is necessary to give unique aliases to these devices see Table 1 If the frame grabber is already open it will give a warning message and return the handle of the device Output If the input isn t valid or the frame grabber device can t be opened for some reason some error message will be shown to the user If everything s ok this function will return a structure with the device information devinfo of the opened frame grabber device Example To open the frame grabber with alias DT3152 and store the device info structure in the variable m type in the Matlab Command Window Page 16 User Manual June 2000 m openfg DT3152 6 1 2 Close a DT frame grabber device DLL name closefg dll Syntax closefg devinfo or closefg alias Description This function will let the user close an opened DT frame grabber device The user has to give the frame grabbers device information structure as input argument Executing the openfg function has retrieved this device information structure Input The device information structure devinfo or the alias of an opened frame grabber Remarks It will be verified if the input is a valid device information structure If it s valid it will try to get the deviceid from the device information structure Output If the input isn t valid or the frame grabber can t be closed for some reason s
28. gTxt Unable to grab an image n return 11 3 Comments on openfg In the 2000 version some Dutch comments are present if this version is ever to be updated again by non Dutch programmers some translations may come in handy LET OP ER IS GEEN STS_CONTROL CODE ZIE ONDERAAN attention there is no STS CONTROL code see below LH LET OP ER IS GEEN CONTROL CODI attention there is no CONTROL code Page 45 Technical Guide June 2000 Page 46 Technical Guide 12 Appendices Table 1 Description of the parameters of the device info structure Parname DeviceName Deviceld InputChannel PixelDepth TimeOut InputFilter FrameType FrameTop FrameLeft FrameWidth FrameHeight HorFrameInc VerFrameInc TotalPixPerLine BackPorchStart ClampStart ClampEnd FirstActivePixel ActivePixelCount TotalLinesPerFld FirstActiveLine ActiveLineCount VideoType CsyncTresh CSyncSource LineOnLoToHi FieldOnLoToHi Description he name you assigned to the board when you configured the board s device driver he device identification of the opened Framegrabber device 1 The currently selected video input channel he pixeldepth of the frame of the Framegrabber board
29. he libraries instead of linking all device drivers to the compiled MEX files If it is necessary to use one of the specific device driver functions the dynamic link library will be automatically loaded In this new situation it isn t necessary to install all the other frame grabber device drivers only the device driver of the installed frame grabber board is required The following example source code shows us how to handle this dynamic loading KKK ck ck KKK KKK KKK KKK KKK KKK KKK KK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK ck ck ck ck ck ck ck ck ck ck ck ko KKK KKK DllHandle LoadLibrary DT315732 DLL if DllHandle Dt3157EnableSyncMasterMode GetProcAddress DllHandle Dt3157EnableSyncMasterMode KKK KKK KKK 0k 0k 0k KKK KKK KKK KKK KKK KKK KKK KK KKK KKK ck ck ck KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK ck ck ck ck ck ck ck ck ck ck ck ck KKK KK code example 10 Dynamically loading openfg First we open the dynamic link library DLL by calling the LoadLibrary function if it succeeds the handle will be stored in the DilHandle variable With GetProcAddress it is then possible to get a pointer to the required function for example Dt3157EnableSyncMasterMode After this initialization you can use the dynamically loaded function in the same way as a normal function 10 9 Implementation Ini files Because the old oadfg function 1998 didn t work at all we have decided to make a new loadfg function At t
30. he updated device info structure when you have set a parameter use get fg devinfo Setfg m gives a listing of all possible values The parameter name parname can be e InputChannel e PixelDepth Page 20 User Manual For an explanation of these parameters see Table 1 See Table 2 for the possible parvalues and allowance availability to set a parameter of the TimeOut InputFilter FrameT ype FrameSize FrameTop FrameLeft FrameWidth FrameHeight HorFramelnc VerFrameInc VideoSize TotalPixPerLine BackPorchStart ClampStart ClampEnd FirstActivePixel ActivePixelCount TotalLinesPerFld FirstActiveLine ActiveLineCount ClockFreq ExtOnLoToHr VideoType CSyncTresh CSyneSource LineOnLoToHr FieldOnLoToHi SyncSentinel HSyncSearchPos HSyncInsertPos VSyneSearchPos VSynclInsertPos SyncMaster Sync Value BlackLevel WhiteLevel ExposureMode Exposure Value CameraType DigitallO DigitallOConfig selected frame grabber June 2000 Page 21 User Manual June 2000 Output If the input isn t valid or the frame grabber can t be set with the chosen parameter value some error message will be shown to the user If everything s ok it will set the chosen parameter of the frame grabber device to the ch
31. height granularity is illegal n mexErrMsgTxt Unable to grab an image n return OLC_STS_INTERLACEDTOPGRAN destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker mexPrintf Frame top granularity is illegal n mexErrMsgTxt Unable to grab an image n return OLC_STS_WHITELEVEL dest royFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf White level cannot be set n mexErrMsgTxt Unable to grab an image n return OLC STS NONOLMSG dest royFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf Unsupported or unknown message passed to the device driver in mexErrMsgTxt Unable to grab an image n return OLC STS MODECONFLICT destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf Mode conflict n mexErrMsgTxt Unable to grab an image n Page 44 Technical Guide June 2000 return case OLC_STS_BUFSIZ destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 mexPrintf Buffersize is too small n mexErrMsgTxt Unable to grab an image n return case OLC_STS_NULL destroyFrameOnErrorExit OLT IMG DEV ID DeviceId Frameld M Bakker mexPrintf Pointer supplied is NULL n mexErrMsgTxt Unable to grab an image n return default destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 03 mexPrintf Unknown error n mexErrMs
32. his example we assume that there are three PCI frame grabber cards are installed in the computer The DT3133 frame grabber card has got three aliases DT3133 1 DT3133 2 and DT3133 3 mainfg print result Deva ce nits 0 gt DLS Lb il Device nr 1 gt DT3152 2 Device nr 2 gt DT3133 1 3 Device nr 3 gt DT3133 2 4 Page 36 Technical Guide June 2000 code example 8 Mainfg print Before using the get remove or add task it is necessary to use checkDevice first to verify if the device is open or not In the following paragraph we will explain how we use the mainfg function 10 3 CheckDevice Because most functions are using the check task we have decided to make the checkDevice function This function will accept an mxArray that must contain the device name It will return true if the device is in the open devices list otherwise it will return false KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck KK KK bool checkDevice mxArray name mxArray rhs 2 lhs 1 int buflen char buffer Create rhs for checking deviceName rhs 0 mxCreateString check rhs 1 name 0 mexCallMATLAB 1 lhs 2 rhs mainfg Read the answer Yes or No buflen mxGetM lhs 0 mxGetN lhs 0 sizeof mxChar 1 buffer mxCalloc buflen sizeof char mxGetString lhs 0 buffer bufle
33. his moment it is only possible to set the common settings we didn t implement some extensions because of the extra programming overload But it is possible to easily extend the oadfg function in the future for some frame grabber extensions Loadfg uses a camera initialization file ini this file will have this common form Acquire Setup Parameters Alias DT3155 nput Source 0 TimeOut 10 Channel 0 BlackLevel 4000 WhiteLevel 500000 nputFilter AcNone FrameType Frame0dd Page 39 Technical Guide VideoType Composite nputFi nputFi Channel 1 BlackLevel 4000 WhiteLevel 500000 nputFilter AcNone FrameType FrameEven VideoType Composite Channel 2 BlackLevel 4000 WhiteLevel 500000 lter AcNone FrameType FrameEven VideoType Composite Channel 3 BlackLevel 4000 WhiteLevel 500000 lter AcNone FrameType FrameEven VideoType Composite code example 11 Ini file example DT3155 June 2000 In the Acquire Setup Parameters section we will have to describe some settings common for all channels these settings are InputSource and TimeOut In the Channel sections we will put the settings for each of the existing channels In this case it is the DT3155 Frame Grabber with four channels so there are four sections named Channel 0 through Channel 3 Each section contains specific settings for that channel The following settings can be used in the camera initi
34. intf Undefined input control n mexErrMsgTxt errorStr case OLC STS INPUTSOURCE mexPrintf Illegal inputsource supplied n mexErrMsgTxt errorStr case OLC STS NONOLMSG mexPrintf Unsupported or unknown message passed n mexErrMsgTxt errorStr default mexPrintf Unknown error n mexErrMsgTxt errorStr void DEF_checkError_Control OLT_APISTATUS result char error 30 char errorStr 80 strcpy errorStr Unable to get the strncat errorStr error 30 switch result case OLC_STS_NORMAL break case OLC_STS_CONTROL break case OLC_STS_NULL mexPrintf Pointer supplied is NULL n mexErrMsgTxt errorStr case OLC_STS_INPUTSOURCE mexPrintf Illegal inputsource supplied n mexErrMsgTxt errorStr case OLC_STS_NONOLMSG mexPrintf Unsupported or unknown message passed n mexErrMsgTxt errorStr default mexPrintf Unknown error n mexErrMsgTxt errorStr PA ck ck ck ck ck ck ck 0k 0k AE RR RR RR RR RR A code example 5 Errorcheck functions check c In the new source code the case statement see code example 3 is replaced by a call to the DEF checkError check c function see code example 6 with the parameter vertical frame inc KEK ck ck ck ck ck ck A 0k KKK ke kk ck ck ck kk ck ck ck ck KKK kk ck ck ck ck KKK KKK KKK ck kk KKK ck ck ck KKK KKK ck ck ck ck ck ck KKK ck ck ck ck ck ck ck ck ck ck ck ck ck ck ko sk
35. irectly because of the mexErrMsgTxt function call OLC_STS_NORMAL OLC_STS_CONTROL OLC_STS_NULL Assign value to variable OLC_STS_INPUTSOURCE OLC_STS_NONOLMSG Exit Mexfunction Continue Mexfunction figure2 Error handling DEF_checkError_Control schematically The new function call in openfg will be instead of code example 4 KIKI ee BR REE cec dece KER RICK RRR Ak dck RE KEIR EK RRR EEK ERR RK EKER RR KICK RE RE KR E KER e ec nhe e ec ek ox EKER RRERRRERER Videosize info Get the default value of the First Active Pixel result OlFgQueryInputControlValue Deviceld InputSource OLC FG CTL FIRST ACTIVE PIXEL amp FirstActivePixel DEF checkError Control result First Active Pixel if result OLC STS CONTROL FirstActivePixel 1 ck ck ck ck ck ck ck ck KKK KKK KKK ck ck ck KKK KKK KKK kk ck ck ck ck KKK KKK ck ck ck ck ck kk ck ck KKK KKK KKK ck ck ck kk ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck Sk ck ck kk code example 7 New function call openfg Page 35 Technical Guide June 2000 10 2 MainFG To solve a few FGI problems we need a structure containing information about the open devices With this open devices list the functions are able to check whether a device can be opened closed etc One problem is that it is not easy to share a structure between the different dynamic link libraries The solution we proposed for this problem is to create a main function which will own the
36. ition section of the device still busy n mexErrMsgTxt Unable to grab an image n return case OLC STS SYSERROR destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 03 mexPrintf Unable to communicate with the device n mexErrMsgTxt Unable to grab an image n return case OLC STS TIMEOUT destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 07 03 mexPrintf Timeout waiting for acquisition n mexErrMsgTxt Unable to grab an image n return case OLC STS FIFO OVERFLOW destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 mexPrintf Too much activity on host bus during transfer n mexErrMsgTxt Unable to grab an image n return Page 43 Technical Guide case case case case case case case case case case case case case case case case case case case June 2000 OLC STS FIELD OVERFLOW destroyFrameOnErrorExit OLT IMG DEV ID DeviceId FrameId M Bakker 2002 mexPrintf Too much activity waiting on host bus during transfer n mexErrMsgTxt Unable to grab an image n return OLC STS INVALIDFRAMEHANDL
37. ix 4 4096 52 amp 57 We COTE ICT Wes zc EEE Page 49 Technical Guide ez mm E A E clampend 4 4095 52 pixcount 4 4096 52 amp 57 I LU EE ELI e rali SE REES EE a STTS Lun SA pevalue X X EINE ii 1000 20 000 000 Hz 52 KGI E X 57 Fixed 53 Lm IRE ee PI eee en qm peri e LAS EE EISES R estesi ER EL RE S E RES getfg dll setfg dll parname Possible Possibleparvalues TT Gaz IN IN O TT E ech On hsynesearchpos PX X XTX xX X EE ess Laren renne se E DA E TT ee PL KEE S blacklevel min 1066800 max 1075200 52 min 1275 max 306000 55 ERN GN whitelevel min 1066800 max 3625200 52 X X X X min 351100 max 1009000 55 GIE Ei Extra for dt3157 EE e see CIS in pi pe B ES Ee E June 2000 Page 50 Technical Guide June 2000 punc DE ee 16 16 Bit Input 12 12 Bit Input 10 10 Bit Input p BS G osse E EL Premete CITT ES uer SE SR OR T TR Numbers 52 53 55 amp 57 gt DT31 II Interlaced acq acquisition X available Page 51 Technical Guide June 2000 Structure of the FGI device structure C ran checkError SETFG_checkError DEF_checkError Control closefg Data Translation Frame Grabber SDK Page 52
38. kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk open framegrabber DT3155 m openfg DT3155 set the black level setfg m BlackLevel 10000 set the white level setfg m WhiteLevel 600000 grab 50 images and show these in Matlab for i 1 50 im grabfg m image im drawnow end close the framegrabber closefg m or closefg DT3155 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk code example 1 In the next two chapters the types structures and the functions will be explained After these chapters you should be able to use this interface Page 13 5 User Manual June 2000 The data types The following types and structures are used by this interface Alias String with the name of a frame grabber device Filename String with the full path and filename of the setting file Imgmatrix The grabbed image will be stored in a matrix called mxArray Moviematrix A row matrix in which an image in the Matlab movie format can be stored Parname String with the name of a parameter of the frame grabber device Parvalue Numeric value where the type depends on the parameter name Devinfo Matlab structure with a subset of the settings of the frame grabber device The other fields of this structure are Devld Alias InputChannel PixelDepth TimeOut InputFilter FrameType FrameTop FrameLeft Frame Width Fr
39. ling factor 8 The movie scaling factor has 2 as a default value Remarks It will be verified if the input is a valid device information structure If it s valid it will try to get the deviceid from the device information structure If the second input is given the function will check the size of the second input and checks if there s enough room to store the grabbed image If there s enough room the variable of type imgmatrix will be overwritten without creating a new matrix else a new matrix will be created and stored in that variable Output If the input isn t valid or the frame grabber isn t able to grab an image some error message will be shown to the user If everything s ok it will return the grabbed image stored in a Matlab matrix imgmatrix The image is stored in transposed way To show the image correctly in Matlab you can use the accent on the imgmatrix to correct it gt image imgmatrix Example There are two ways to use this function Both will be shown here Variable m is the device info structure which was returned from the function openfg 1 Just grab an image and store it in the variable img type im grabfg m To show this image in Matlab in the right way not transposed type image im 2 First create a matrix of the appropriate size and type where the image will be stored im uint8 zeros 768 576 Then grab the image grabfg m im Show the image in Matlab t
40. m type in the Matlab Command Window reset fg m Page 22 User Manual June 2000 6 2 2 Load settings for a camera from a file DLL name loadfg dll Syntax loadfg devinfo filename Description This function will let the user load settings from a file The user has to give the frame grabbers device information structure as input argument as well as the filename with full path Executing the openfg function has retrieved this device information structure Input The device information structure devinfo of an opened frame grabber device the filename with full path Remarks It will be verified if the input is a valid device information structure If it s valid it will try to get the deviceid from the device information structure Output If the input isn t valid some error message will be shown to the user If everything s ok it will load the settings from the file into the frame grabber To see the new settings use the getfg function Example To load the settings from the file pulnix ini with path c camfiles and assuming that the variable rn stores the device info of the current frame grabber type loadfg m c camfiles pulnix ini The structure of the setting file is like a standard Windows 95 ini file It looks like this The full example can be found in the camfiles directory of the FGI Dev Kit Acquire Setup Parameters Alias DT3155 Input Source 0 TimeOut 10 Channel 0 BlackLevel 4000 WhiteL
41. made for use by people of the Center of Machine Perception CMP which is a department of the faculty of Electrical Engineering of the Czech Technical University in Prague 1 2 Brief Matlab description Matlab is a mathematical program that is very popular at the universities all around the world You can compute many things with it and you can even make application interfaces with Matlab The interface is made with Mex files After compiling and linking these files Matlab creates DLL s Dynamic Link Libraries which can be executed within Matlab The language of these Mex files is C But Matlab itself has also some special Mex functions that can be used in these Mex files For further reference check the Matlab manuals and books 1 3 Hardware requirements The interface is developed under Matlab 5 3 1 The Mex compiler is used to create the DLL s At least Matlab 5 for W95 NT and a DT frame grabber is needed to work with this interface A camera connected to the frame grabber should be very useful too Page 6 User Manual June 2000 2 About Frame grabbers Frame grabbers are Open Layer Devices DT Open Layers is a set of open standards for developing integrated modular software under Microsoft Windows and hardware independent support One of the main advantages of DT Open Layers is that when you have written a program you can use it with new boards too There s no need to rewrite your code The reason for this is that the softwa
42. n Clear used memory mxDestroyArray rhs 0 mxDestroyArray lhs 0 return strcmp buffer Yes 0 KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK ck ck ck ck ck ck ck ck ck ck ko ck KKK KK KK code example 9 Function checkdevice Before calling MexCallMATLAB nr output output nr input input one has to create some mxArrays In this case we set the task to check by assigning the mxCreateString check to the first argument of mainfg The second argument for mainfg will contain the device name which we would like to check this is the device name which is given to the checkDevice function Now we are ready to call the MexCallMATLAB function it will return the mainfg output to lhs We are then able to read the answer string from hs 0 by using the mxGetString function Finally we compare this answer to Yes or No and we will return the Boolean equivalent of it 10 4 Grabfg c This function checks first if the inputted variable is already of the specified size and type If it is then this variable will be overwritten If it isn t a new image Matlab matrix will be created of the specified size frameheight amp framewidth and type to store the acquired image We will give a short part of this code here if mxIsClass output uint8 amp amp ULNG mxGetM output Width amp amp ULNG mxGetN output Height amp amp PixelDepth
43. nt nlhs mxArray plhs int nrhs const mxArray prhs int buflen int i double y char task char name bool found n n false Added by M Bakker 2002 06 24 12 35 Use mexLock to prevent clear all or clear mex from clearing mainfg dll from Matlab memory The deviceArray stays intact Wi mexLock kk ck ck ck ck ck ck KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KK KKK KKK Ck Ck KKK kx 11 2 Improvements in grabfg The original complaint was that when an error was encountered some of the device driver s resources were not properly released resulting in a new error message and the need to close and re open Matlab when the error occurred several times A subroutine was added to properly release resources A call to this subroutine is made every time before a call to mexErrMsgTxt in a place problems could occur To make the source more readable we had already changed the lay out of the source code After making the above mentioned changes we noticed the error messages after calling the OL SDK to acquire a frame were very undescriptive so we added several new ones While we were working on the source code and checking the documentation we noticed that not all six different syntaxes for calling grabfg were documented so we fixed that as well Below is some of the source code of grabfg to show the changes kk ck ck ck ck ck KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK
44. ome error message will be shown to the user If everything s ok it will close the opened frame grabber device Example 1 To close a frame grabber with its device id stored in the variable m type in the Matlab Command Window closefg m Example 2 To close a frame grabber with the alias DT3155 type in the Matlab Command Window closefg DT3155 6 1 3 Grab an image from the DT frame grabber device DLL name grabfg dll Syntax idmgmatrix grabfg devinfo moviematrix grabfe devinfo imgmatrix imgmatrix moviematrix grabfg devinfo grabfe devinfo imgmatrix grabfe devinfo imgmatrix moviematrix grabfe devinfo imgmatrix moviematrix scaling factor Description This function will let the user grab an image from an opened frame grabber device The user has to give the frame grabbers device information structure handle as input argument When used with the moviematrix argument a standard bitmap will be Page 17 User Manual June 2000 returned according to the matlab movie format The scaling factor can be used for scaling down this bitmap Input The device information structure devinfo of an opened frame grabber device and optionally the pre allocated image matrix imgmatrix a movie matrix moviematrix and a scaling factor for movies The movie matrix has size m 1 and consists of doubles Calculate m as follows m 388 img height scaling factor img width sca
45. osen parameter value Example To set the frame height to 400 pixels and assuming that the variable m stores the device info of the current frame grabber type setfg m frameheight 400 6 2 Advanced functions The user of this interface can do the following with the advanced functions e Reset a DT frame grabber device e Load settings for a camera from a file e Check whether the frame grabber has been opened e Recover the handle of the opened device when the handle has been lost These functions are DLL s that can be executed from the Matlab workspace by just typing the DLL name with if necessary some input arguments 6 2 1 Reset a DT frame grabber device DLL name resetfg dll Syntax resetfg devinfo Description This function will let the user reset an opened DT frame grabber device The user has to give the frame grabbers device information structure as input argument Executing the openfg function has retrieved this device information structure Input The device information structure devinfo of an opened frame grabber device Remarks It will be verified if the input is a valid device information structure If it s valid it will try to get the deviceid from the device information structure Output If the input isn t valid some error message will be shown to the user If everything s ok it will reset the opened frame grabber device Example To reset a frame grabber with its device id stored in the variable
46. ransposed image im Page 18 User Manual June 2000 6 1 4 Geta parameter from the DT frame grabber device DLL name getfg dll Syntax parvalue getfg devinfo parname Description This function will let the user get a parameter of DT frame grabber device Input he device information structure devinfo of the opened frame grabber device and the parameter name parname Remarks It will be verified if the first input argument is a valid device information structure and if the second input argument is a parameter name If it s valid it will try to get the device id from the device information structure The parameter name parname can be e DeviceName e Deviceld e InputChannel e PixelDepth e TimeOut e InputFilter e FrameType FrameSize the return value is a structure with frame size info FrameTop FrameLeft Frame Width FrameHeight HorFrameInc VerFrameInc VideoSize the return value is a structure with video size info TotalPixPerLine BackPorchStart e ClampStart ClampEnd FirstActivePixel ActivePixelCount TotalLinesPerFld FirstActiveLine ActiveLineCount e ClockFreq e ExtOnLoToHi e VideoType e CSyncTresh e CSyneSource Page 19 User Manual June 2000 e LineOnLoToHi e FieldOnLoToHi SyncSentinel HSyncSearchPos HSyncInsertPos
47. re uses similar device calls and memory management between modules Therefore it s easy to put some new function into an existing product You can add your new functions by simply adding a function library You can do this by including additional DT Open Layer compliant function libraries This makes it enormous flexible because you can combine as much software libraries and corresponding supported hardware as you like The functions can be written in a higher level language such as C and Visual Basic DT Open Layers uses 3 standard Layers First there s the Application Layer It represents the Windows application software for the end users The Application Layer is connected to the Function Library Layer This connection is called the Application Programming Interface API function calls that applications can use to interface with function libraries The function specific programmer s libraries DLL like DataAcq SDK and frame grabber SDK are used to assist the OEMs system integrators and developers The Function Library Layer is connected to the Device Interface Layer This connection is called the System Programming Interface SPI The Device Interface Layer DLL consisting of lower level device drivers called by the function libraries are used to assert control over specific devices It provides a device independent interface for the native OS So the common part of all frame grabbers is controllable Beneath the Device Interface L
48. s generated by the board to drive one which all other voltages are digitized to which all other voltages are digitized to Generates an exposure pulse to the camera if enabled Specifies the pulse duration and the logical polarity Specifies the current digital camera The digital input from the input ports The digital input output configuration June 2000 Page 48 Technical Guide June 2000 Table 2 Possible values of the parameters and their availability to set get getfg dll setfg dll inputchannel 0 1 2 3 52 0 1 2 53 X X X X X X X X p o e_N COO II ESEJE E RER E _ Cri Il Frame acq on next even field FrameEven Il Frame acq On next odd field FrameOdd Il Frame acq on next field FrameNext Single field acq on next even field FieldEven Single field acq on next odd field FieldOdd Single field acq on next field FieldNext Non Il Frame acq on next frame Nonlnterlaced frametop 0 4095 for 52 amp 57 0 575 50Hz amp 0 X X X 479 60Hz for DT3153 frameleft 0 4095 for 52 amp 57 0 767 50Hz amp 0 X X X 636 60Hz for DT3153 framewidth 4 4096 for 52 amp 57 4 768 50Hz amp 4 xX l Xl xX 640 60Hz for DT3153 frameheight 1 4095 for 52 amp 57 0 576 50Hz amp 0 X X 480 60Hz for DT3153 E ES RENE Set Ne EL So totp
49. ters and their availability to set get e Scheme Matlab interface for DT Open Layer Frame grabbers Page 4 PART I User Manual Page 5 User Manual June 2000 1 Introduction This document describes the Matlab interface for DT Open Layer Frame grabbers It will describe the functionality of this interface and under which conditions the interface has to work This document can be used as reference while using this interface 1 1 General description DT Open Layer Frame grabbers are used for video capturing You can connect several cameras to this frame grabber depending on the number of input channels With the frame grabber software development kit you can make your own program to grab an image with a connected camera for example You can even grab a sequence of images It then will be a live image More info about frame grabbers will be given in chapter 2 This grabbing of an image with a frame grabber will now be done via Matlab The aim of this document is to explain and describe a Matlab Interface for DT Open Layer Frame grabbers With this interface you can control an installed frame grabber within Matlab The interface will be split into several DLL s the executable for Mex files in Matlab The code is made mostly in C but some special Mex functions from Matlab are used too To control the frame grabber functions from the functional library of the frame grabber software development kit will be extensively used This interface is
50. the type of natural numbers It starts from 2147483648 to 2147483647 There is a limit of the size of the number When exiting this limit there will be an overflow and can give an incorrect answer e struct This is used to create a structure array in Matlab Meaning s struct field1 values1 field2 values2 This will create a structure array with fields and values Value ret are cell arrays with the same size or scalar cells So when called it will first fill the fieldname and then the value Page 10 User Manual June 2000 e mxArray Matlab uses arrays for many data types like including scalars vectors matrices strings cell arrays structures and objects All of these variables are stored as Matlab arrays When programming in C the Matlab array is declared of the type mx Array All MATLAB data is stored column wise Page 11 User Manual June 2000 4 How to use this interface The interface consists of 5 basic functions e openfg This will open the frame grabber device or re get the handle when already open e closefg Close an opened frame grabber device e grabfg Grab an image from the frame grabber e getfg Get a parameter from the frame grabber e setfg Set a parameter from of the frame grabber And there are 4 advanced functions available e resetfg Reset an opened frame grabber to its initial state e loadfg Load settings for the frame grabber from a file e isopenfg Returns a dou
51. tlab types The Matlab interface uses several Matlab types These types will be briefly explained in this chapter e strings The purpose of string being in MATLAB is for string handling It can be seen as a vector whose components are the numeric codes for the characters the first 127 codes are ASCID It also can be used to convert an array that contains numerical codes into a Matlab character array e double Purpose Convert to double precision Double x will give the double precision value for X If X is already a double precision array double has no effect The range of a double is from 1 7E 308 to 1 7E 308 e char Purpose Create character array string It will convert the array X that contains positive integers representing character codes into a array in Matlab the first 127 are ASCII There is also a bound When you want to convert a character array into its numerical code you can use double Or char C when C is a cell array of strings it will place each element of C into the rows of the character arrays e um When using 1 uint8 x x will be converted to an unsigned 8 bit integer As an example x can be double Uint8 ranges from 0 to 255 When converting and the answer is outside the specified range the answer is not defined When converting a type and the type is already uint8 then nothing will happen e int Int stands for integer So the compiler will know that the variable declared int is integer Integer type is
52. ucture variable See the source code in src 10 6 Setfg c This function sets a parameter value of a given parameter To get the updated frame grabber settings use the function getfg A part of the code else if stricmp FrameLeft ParName Want to set the frame left ParValueLeft ULNG mxGetScalar prhs 2 result OlFgSetInputControlValue OLT_IMG_DEV_ID d InputSource OLC_FG_CTL_FRAME_LEFT ParValueLeft amp OldParValueLeft SETFG checkError result frame left Explanation of the above code First the inputted parameter name will be compared with frameleft If it s equal it will get the inputted parameter value and this will be used too set the specified parameter of the frame grabber If it s set then no error message will be given else a specified error message will be displayed in Matlab See the complete source code in src Page 38 Technical Guide June 2000 10 7 Resetfg c This function resets the frame grabber to its nominal state To get the updated frame grabber settings use the function getfg See the source code in src 10 8 Dynamic libraries Problem Description The dynamic libraries for all frame grabbers are always required Usual situation is that a user only has one frame grabber card installed Only the library of the frame grabber which is attempted to be open shall be required To solve the problem in the 1998 version we had to dynamically load t
53. we refer to the FGI Report 2000 R Heil and C L Wauters In the next chapter we will explain the structure of the directories that are included in the Matlab interface for DT FG Development Kit After that we will discuss the compiling and linking of the MEX Files In the last chapter there will be some parts of the source codes explained so a global view of the interface code structure can be gained Page 27 Technical Guide June 2000 8 The necessary programs and files The Matlab interface for DT Mach Frame grabbers Development Kit is divided in several directories They will be described below bin camfiles compile demos docs sre DLL s and M files This directory includes the M files and DLL files of the Matlab interface for DT Mach Frame grabbers Example setting files This directory includes an example setting file for the Pulnix camera working on the frame grabber DT3152 Developer s files This directory includes the following files for developing and changing the Mex files Some hard drive letters in the files should be changed if necessary Some FGI demos This directory includes some demos to use with some frame grabbers User s amp Technical Guide This directory includes the specification and the User Manual amp technical guide of the FGI Source code of the FGI This directory includes the source code of the FGI In every directory a readme txt is included which will describe the
54. wo consecutive vertical sync signals he beginning of the active video signal within the field as a line offset from the beginning of the vertical sync he number of lines per field or noninterlaced frame in the active video area Specifies the video type Composite video or variable scan input The point at which the frame grabber acknowledges the sync signal The video input channel on the board that is used as the composite sync source Line horizontal sync on a low to high transition Field vertical sync on a low to high transition Page 47 Technical Guide SyncSentinel HSyncSearchPos HSyncInsertPos VSyncSearchPos HSyncInsertPos SyncMaster BlackLevel WhiteLevel Exposure ExposureValue CameraType DrgitalTo DigitallOConfig sync signals he position where to synchronize to he line location stay in sync with his uses the sync or more camera s he voltage below black he voltage above white his circuitry corrects for missing extraneous or low level he pixel location within a line at which the frame grabber begins to search for the horizontal sync the sync sentinel inserts a horizontal sync the video signal within a field at which the frame grabber begins to search for the vertical sync he position where the sync sentinel inserts a vertical sync to the video signal signal
Download Pdf Manuals
Related Search
Related Contents
KOHLER K-T14423-3-BGD Installation Guide INSTALLATION MANUAL Fan stop thermostat 取扱説明書 Nanoシリーズ Samsung 76V User Manual PhoneSuite Extension User`s Manual Copyright © All rights reserved.
Failed to retrieve file