Home
Imagenation PXR800 Frame Grabber User's Guide, Version 3, 8/03
Contents
1. 26Q ji The assumption here is that there is usually a Grab queued and waiting for a trigger AppIdle keeps track of the currently queued Grab operation with the static variable qidGrab If this variable is Q1_ INVALID no Grab has been queued Otherwise it s value is an ID for the grab operation 3 20 Programming the PXR800 Chapter 3 If there is a grab in progress the program uses TimedWaitFinished to wait for it to complete The TimedWaitFinished function gives the program the ability to release the CPU and wait for a queued operation but get control back after a certain amount of time if the operation doesn t finish promptly Here we wait at most 100 milliseconds for the grab to finish and if it isn t done in that time AppIdle returns The result is that while waiting for a trig ger the program polls for messages about 10 times per second fast enough to respond well to user input but slow enough to not use excessive CPU time If the Grab has completed qidGrab gets cleared to indicate that there is no longer a Grab in the queue and the grabbed image is displayed The ShowFrame function is provided as part of the full sample code and takes care of the details of displaying an image from a PXRFrame in a window If qidGrab is zero either a previous Grab has finished or this is the first time AppIdle has been called In either case the right thing to do is to start another Grab and return to the main loop The Grab com
2. ssssccssscccsssssssseeccceeeees 5 4 Figure 5 4 Signal Conditioning and Manipulation 5 9 Figure 5 5 Interlace OSC ooo cacs casicicasciesacececastnonctectbecensiatacenetassad 5 11 Figure 5 6 Offset and Fine Gain cccccssssseeeccceecccessssseeeeees 5 15 Figure 5 7 Real Time Control Model ccccsssssssssssssseseeees 5 18 Figure 5 8 HalfH Timing FUn ction ccsccccccssssssssssssseceeee 5 19 Figure 5 9 Real Time Control Model sccccccccsesssssseeeeee 5 24 Figure 5 10 Signal Timing Example ccccccccsssssssseeeees 5 26 Figure 5 11 PXR800 Data Flow and Control Paths 5 29 Chapter 6 Figure 6 1 GP Input SchematiC sesssoesesssocseessoocsessocesesssoesesseoe 6 2 Figure 6 2 GP Output Schematic cccscssssssssesssccssssssesesesssceseseaiass 6 3 Figure 6 3 Trigger Input Schematic oooooeseeessessocccessssessseceoe 6 4 Figure 6 4 26 Pin Connector Diagram ssssssseesssssccceessseesssscoee 6 5 Figure 6 5 Camera Connector PositionS ssesssossesssoeseessoeseese 6 7 vii viii Table of Contents List of Tables Chapter 2 Table 2 1 Operating System Specific Files ccccccssssseeeeees 2 4 Chapter 3 Table 3 1 Relationship of DLLs and BAS Files sseee00 3 6 Table 3 2 BAS Files for Visual Basic cccccsscsssssssssssssseeees 3 7 Chapter 5 Table 5 1 Camera
3. imagenation OpenLibrary pxrframe dll amp FrameLib sizeof PXRFRAMELIB These lines open the PXRFrame library and the PXR800 library Only after the libraries have been opened can functions from them be called Opening the libraries initializes the global structures that were created earlier so that they contain references to real functions Trying to call functions from a library before it is opened causes an invalid memory access and will crash the pro gram pFrame FrameLib AllocateBuffer 640 640 480 PBITS Y8 TRUE AllocateBuffer creates a frame structure Here the frame is 640 by 480 pixels and each pixel is 8 bits Note that because AllocateBuffer is a function of the PXRFrame library it is called as a member of the FrameLib structure hFG PXR AllocateFG GR NEXT AVAILABLE AllocateFG locates a PXR800 frame grabber and makes it available to the program Later functions will refer to this frame grabber by it s handle stored in hFG Like all PXR library functions AllocateFG is called as a member of the PXR structure PXR Grab hFG pFrame 0 GE_ON VSYNC FALSE SV EITHER FIELD FL FRAME IW WAIT The Grab function captures an image to a frame structure using a frame grab ber In addition to the frame grabber handle and the frame structure pointer Grab has several other parameters describing exactly how the image should be captured This call captures the next image fr
4. As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG icCamera is one of the cameras e CAMERAO e CAMERA1 e CAMERA2 e CAMERA3 Return Value Return is the sync mode e SYNC_HS VS e SYNC HC VC e SYNC HC VS e SYNC _ HLINE e SYNC_INVALID on error See Table 9 6 on page 9 27 Description The GetSyncMode function gets the source of the video sync signals for the specified camera Returns immediately Continued on the following page 9 26 PXR800 API Functions Chapter 9 GetSyncMode continued Sync Mode Description SYNC_HS VS Horizontal sync comes from the camera on the HS wire Vertical sync comes from the camera on the VS wire SYNC_HC_VS Horizontal sync is extracted from the composite video sig nal Vertical sync comes from the camera on the VS wire This is also the mode to use if the camera transmits a WEN pulse or trigger pulse instead of vertical sync connect the trigger or WEN pulse to the VS wire SYNC_HC_VC Horizontal and vertical syne are both extracted from the composite video signal This is the normal operating mode of most video cameras SYNC_HLINE See Also Horizontal and vertical sync come from the camera mixed on the HS wire This is the mode to use if the camera sends video on one wire and a composite sync signal on a second wire or if you are trying to genlock all parts of a system to a master composite sync signal Table 9 6 S
5. As Long Parameters pFrame is the address of a PXRFrame pvBuffer is the address of the target buffer dwColumn is the column number of the frame from which to copy the pixel dwRow is the row number of the frame from which to copy the pixel Return Value The return is non zero on success zero if failure Description The GetPixel function copies the pixel at dwColumn dwRow into pvBuffer where 0 0 is the upper left corner of the frame The buffer is assumed to be large enough to hold the pixel If the pixel won t fit in the memory pointed to by pvBuffer undefined behavior and data corruption might result The function will fail if the specified coordinate is outside the boundaries of the frame or if the frame can t be read 10 16 PXRFrame API Functions Chapter 10 GetRectangle DWORD GetRectangle PXRFRAME pFrame void pvBuffer DWORD dwColumn DWORD dwRow DWORD dwWidth DWORD dwHeight FRAMEVB GetRectangle ByVal pFrame As Long ByRef pvBuffer As Any ByVal dwColumn As Long ByVal dwRow As Long ByVal dwWidth As Long ByVal dwHeight As Long As Long Parameters pFrame is the address of a PXRFrame pvBuffer is the address of the target buffer dwColumn is the column number of the frame from which to copy the pixels dwRow is the row number of the frame from which to copy the pixels dwWidth is the width of the rectangle in the frame from which to copy the pixels dwHeight is th
6. Depending on your machine vision application requirements you may need to pick a video camera with some or all of the above special features In any case the PXR800 is designed to operate with the widest possible range of video formats camera types and camera features PXR800 Features for Machine Vision The PXR800 has a feature set that allows it to work easily with various machine vision cameras while controlling the image capture process in a wide range of machine vision applications Some of these key features are as fol lows e Low video noise that allows the PXR800 to faithfully capture images from high quality cameras and to provide those images with full 8 bit pixel accuracy for computer analysis e Low synchronization jitter allowing consistent measurement of horizontal position in images to subpixel accuracy e Support for cameras having a pixel clock output which allows further reduction in synchronization jitter e Programmable offset and gain control for accurate adjustment of video data dynamic range e Support for both interlaced and progressive scan video formats e Ability to synchronize to resettable cameras e Four programmable pulse generators that can be used to control camera exposure camera reset timing strobe light timing and other machine vision control tasks e Four trigger inputs to synchronize video capture timing and pulse generation to events elsewhere in the vision system Triggers can be o
7. If the library cannot be found or invalid parameters are provided zero is returned Refer to the example on the following page 8 2 Initializing and Exiting Libraries Chapter 8 imagenation_OpenLibrary continued Example short sGrabbers 0 PXR Pxr PXRFRAMELIB fLib BOOL bfLib FALSE sGrabbers imagenation OpenLibrary pxr800 dll amp Pxr sizeof PXR if sGrabbers gt 0 bfLib imagenation OpenLibary pxrframe dll amp fLib sizeof PXRFRAMELIB do some stuff with the libraries if bfLib imagenation CloseLibrary amp fLib bfLib FALSE if sGrabbers gt 0 imagenation CloseLibrary amp Pxr sGrabbers 0 8 3 Chapter 8 Initializing and Exiting Libraries imagenation_CloseLibrary void imagenation CloseLibrary void iface Parameters iface a pointer to the appropriate interface Return Value None Description The imagenation_CloseLibrary function closes the specified library and releases any resources that were opened with a corresponding call to imagenation_OpenLibrary The iface pointer must be a valid interface and must be the same that was provided in the corresponding call to imagenation OpenLibrary It is important to no longer access the functions contained in iface after the library is closed Doing so will result in an invalid function call and might result in a General Protection Fault 8 4 Initializing and Exiting Libraries Chapter 8
8. 255 dwLength is the number of LUT entries to retrieve valid range 1 256 pbLUT is an address to the array that will receive the LUT data It must be at least as long as dwLength Return Value Return is non zero if successful zero on failure Description The GetLUT function reads the specified section of the frame grabber s input lookup table LUT into the array pbLUT The section to be read is specified by dwFirstIndex and the number of entries desired is specified by dwLength The data is read into the start of pbLUT regardless of dwFirstIndex The array must have at least dwLength entries If the array is too short a system error might occur from a data overrun This function will not return until all queued operations have completed See Also SetLUT SetOffset GetOffset SetFineGain GetFineGain 9 15 Chapter 9 PXR800 API Functions GetNyquistFilter 9 16 IMG FILTER GetNyquistFilter FGHANDLE fgHandle PXRVB GetNyquistFilter ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value Returns the current Nyquist filter setting e IF NONE e IF HIGH FREQ ON e IF INVALID on error Description The GetNyquistFilter function returns the current setting of the Nyquist filter If it is IF NONE the filter is not activated If IF HIGH FREQ ON the high frequency component of the signal is filtered out This function will not return
9. 9 81 Chapter 9 PXR800 API Functions WaitFinished DWORD WaitFinished FGHANDLE fgHandle QUEVEID gilD PXRVB WaitFinished ByVal fgHandle As Long ByVal qiID As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG qiID is a QueuelID returned from a queueable function Return Value Returns one on success DW_ ERROR on failure Description The WaitFinished function waits for the completion of a queued request If qiID is QI ALLQUEUE this function will wait for the completion of all queued requests In some cases there may be queued operations that are waiting for conditions such as trigger events that might not occur In such cases using TimedWaitFinished allows the application to time out and return control to the user See Also TimedWaitFinished IsFinished WindowsEventFromQID Grab 9 82 PXR800 API Functions Chapter 9 WindowsEventFromQID HANDLE WindowsEventFromQID FGHANDLE fgHandle QUEUEID gilID PXRVB WindowsEventFromQID ByVal fgHandle As Long ByVal qiID As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG qiID is a QueuelID returned from a queueable function Return Value Returns a Windows event handle that can be used with Windows synchroniza tion events Description The WindowsEventFromQID function converts a PXR800 queueID toa Windows synchronization event This allows an application to use advance
10. an error occurred while the file was being read INVALID FRAME the frame pointer is invalid Description The ReadBin function reads a binary file into the specified frame If the frame is not large enough to hold the image the last bytes of the file are ignored The file is assumed to be in the same format written by WriteBin This for mat contains no information about the width height and pixel type of the image so ReadBin will only produce a properly formatted image if the frame s width height pitch and pixel type match those values for the frame that was originally written to the file 10 25 Chapter 10 PXRFrame API Functions ReadBMP 10 26 DWORD ReadBMP PXRFRAME pFrame char szFileName FRAMEVB ReadBMP ByVal pFrame As Long ByVal szFilename As String As Long Parameters pFrame is the address of a PXRFrame szFilename is the name of the file to read Return Value SUCCESS the file was read successfully FILE OPEN ERROR the file could not be opened BAD READ an error occurred while the file was being read INVALID FRAME the frame pointer is invalid Description The ReadBMP function reads a file in Windows BMP format into the specified frame If the frame is not large enough to hold the image the right and bottom edges of the image are discarded PXRFrame API Functions Chapter 10 ReadPNG DWORD ReadPNG PXRFRAME pFrame char szFileName FRAMEVB ReadPNG ByVal pFrame As L
11. dwhOlwidth gag dwROlHeight 454 SetAOl Reset Defaults Figure 4 1 The Frame Size Dialog Box Dialog Box Rules Although they may appear so at first glance the dialog boxes are not inconsis tent The Frame Size dialog box shown in Figure 4 1 is a good example of an apparent inconsistency among dialog box controls The values associated with 4 3 Chapter 4 The PXR Productivity Tool 4 4 each of the SetPixelClock radio buttons are sent to the PXR800 and generate feedback in the video window as soon as you click them they take effect immediately In contrast the four edit boxes in the SetVideoFrameSize group box are not sent to the PXR800 until you click the SetVideoFrameSizeQ but ton Our primary goal was to make the PXR Productivity Tool easy to use With that in mind we decided to use the following rules for constructing dialog box controls e If an API command has only one parameter the dialog sends changes to the PXR800 immediately without the extra step of clicking a button e If an API command has multiple parameters the dialog box requires the extra step of clicking a button to verify that the necessary parameters have all been set prior to sending the command to the PXR800 Most API commands that have only a single parameter are implemented as radio buttons When you click a radio button the command is sent to the PXR800 and you get immediate feedback However other API commands that have only a si
12. s not necessary to call InvalidateGrabberBuffer after these functions The functions that auto matically invalidate the PXR800 buffer are e SetContinuousBuffering e SetInterlaceMode e SetPixelClock e SetROI e SetTransferMode e SetVideoFrameSize Detailed Operating Information Chapter 5 Blocking Sometimes race conditions can occur when setting up RTC sequences and grab settings This happens for example when an event trig ger occurs part way through setting up for image capture Specifically suppose it s important that a strobe sequence fires only during image capture In setting up the PXR800 SetRTCTiming is called to set up the strobe pulse sequence This is followed by calling RTCStart to ask the strobes to fire in response to a trigger Then Grab is called to wait for the image If in the above example a trigger arrives in the short period where RTCStart has finished but Grab hasn t executed yet the trigger causes a strobe pulse to fire but will not trigger a grab operation To avoid race conditions such as described above the PXR800 RTC and grab qualification systems can be temporarily blocked from operation This pre vents triggering events from being accepted when the PXR800 is in an incon sistent state during setup sequences This blocking capability is provided by BlockGrabber The BlockGrabber function aborts any ongoing image qualification process and blocks new qualifications from starting image capture
13. As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwMask is the mask of the currently enabled trigger lines teEvent is the trigger event type e TE OFF e TE LOW e TE HIGH e TE RISING e TE FALLING Return Value Returns a non zero value on success zero on failure Description The SetTriggerEvent function sets the type of event that causes a trigger to be detected The trigger lines can be disabled or enabled by changing the bits in the dwTriggerMask e Bits 0 3 control triggers 0 3 respectively e A bit value of one enables the trigger e A bit value of zero disables the trigger If the trigger is disabled no events will be detected from it All four triggers use the same teEvent Returns immediately See Also GetTriggerEvent RTCStart GetRTCStart Grab 9 76 PXR800 API Functions Chapter 9 SetVideoFrameSize QUEUEID SetVideoFrameSize FGHANDLE fgHandle DWORD dwleftOffset DWORD dwTopOffset DWORD dwWidth DWORD dwHeight IMG WHEN iwWhen PXRVB SetVideoFrameSize ByVal fgHandle As Long 7 ByVal dwLeftOffset As Long ByVal dwTopOffset As Long ByVal dwWidth As Long ByVal dwHeight As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwLeftoffset is the left offset of the video frame valid range zero to CCIR_WIDTH_DEFAULT pixels dwTopOffset is the top offset of the video
14. Pixel clock signal from camera to PXR800 GP Output 0 GP Output 1 GP Output 2 General purpose digital data outputs The PXR800 drives these to ground or 5V under software control Exp1 Exp2 Exposure control pulses from PXR800 to camera Opto Trigger High Optically isolated trigger signal from external device to PXR800 Don t connect both TTL trigger and isolated trigger GP Output 3 General purpose digital data output Table 6 3 26 Pin Connector Pinouts Hardware Reference Chapter 6 Connector Positions CAMERA 0 CAMERA 2 One o o o oo o00000000 o o o o ooo e o o o o o oo o o o o ooo o e o o o o o oo o CAMERA 1 CAMERA 3 o0000000 o00000000 ie fe fe ie fe ie fe ie fe o o o o oo o o o oo oo oo ORO o o o o ooo PXR800 PXR801 CAMERA EXTENDER BOARD Figure 6 5 Camera Connector Positions Camera connector positions on the PXR800 and PXR801 Camera Extender Board 6 7 Chapter 6 Hardware Reference This page intentionally left blank 6 8 PXR800 API Structures Chapter 7 Chapter 7 PXR800 API Structures This chapter is an alphabetical reference for the Imagenation PXR800 API Structures IMG_IMAGEINFO and REALTIME For additional information on using the structures refer to Chapter 5 Detailed Operating Information on page 5 1 For reference information on initializing or exiting library func tions refer to
15. Return Value The return is non zero on success zero if failure Description The GetRow function copies a row of an image from a frame into a buffer The rows are numbered starting with zero at the top of the frame The buffer is assumed to be an array of the correct type to hold the row of pixels If the entire row won t fit in the memory pointed to by pvBuffer undefined behavior and data corruption might result The function will fail if the specified row is outside the boundaries of the frame or if the frame can t be read 10 19 Chapter 10 PXRFrame API Functions GetTimeStamp DWORD GetTimeStamp PXRFRAME pFrame IMG IMAGEINFO pTimeStamp FRAMEVB GetTimeStamp ByVal pFrame As Long ByRef pTimeStamp As IMG ImageInfo As Long Parameters pFrame is the address of a PXRFrame pTimeStamp is the address of an IMG_IMAGEINFO structure where the image informa tion for the frame will be copied Return Value The return value is non zero on success zero on failure Description GetTimeStamp copies the image information from a frame into the supplied structure If the frame was created with the bImageInfo flag set to FALSE there is no image information attached to the frame and GetTimeStamp will fail The image information for a frame that has not yet the image data from a grab contains undefined data After a Grab has completed to the frame the image information data describes when and how the image was capture
16. pulse or trigger pulse instead of vertical sync connect the WEN or trigger pulse to the VS wire SYNC_HC_VC Horizontal and vertical syne are both extracted from the composite video signal This is the normal operating mode for most video cameras SYNC_HLINE Horizontal and vertical sync come from the camera mixed on the HS wire This is the mode to use if the camera sends video on one wire and a composite sync signal on a sec ond wire or when you are trying to gen lock all parts of a system to a master composite sync signal DRIVE_HD VD The frame grabber transmits horizontal sync out the HS wire and vertical sync out the VS wire It assumes the video signal it is receiving is synchronized to the signals it is driv ing on HS and VS For correct operation do not try to use this mode with any camera that is set up to transmit its own external sync on HS or VS The timing of the drive signals depends on the camera format set by SetPixelClock and SetInterlaceMode DRIVE_HD VEXPO The frame grabber transmits horizontal sync on the HS wire and vertical sync on the VS wire The vertical sync timing is not chosen automatically but instead is pro grammed by setting up the Exp0 pulse generator and the RTC Exposure sequences from Exp0 will be sent out on the VS wire and the frame grabber will expect the video signal to be synchronized to the start of the RTC pulses Timing of the horizontal drive depends on the came
17. while providing square pixels When using a pixel clock from the camera SetPixelClock can be used to select either the rising or falling edge of the pixel clock to trigger sampling and digitizing of the analog video signal The size of the resulting raw image will depend on the incoming video format and the sample rate pixel clock selected e RS 170A 12 2727 MHz sampling 640 pixels by 486 lines e RS 170A 13 5 MHz sampling 720 pixels by 486 lines e CCIR 13 5 MHz sampling 720 pixels by 576 lines e CCIR 14 75 MHz sampling 768 pixels by 576 lines Set Video Frame Size Before video data can be captured the application program must tell the PXR800 what frame size to expect This is done with SetVideoFrameSize The height in lines dwHeight and width in pixels dwWidth of the video frame can be set to values from 1 to 2047 The left and top offset can be set to values from 0 to 2047 using the dwLeftOffset and dwTopOffset argu ments The width and height arguments define the valid region of the video image The dwLeftOffset and dwTopOffset values allow you to move the image within the video stream This ability to shift the valid region of the image is useful for avoiding blanking and sync periods and for compensating for non standard timing used by some cameras 5 7 Chapter 5 Detailed Operating Information 5 8 The dwLeftOffset value is the number of pixels between the start of hori zontal syne and the first pixel of real im
18. 5 10 9 61 SetOffset 5 13 5 14 9 62 SetPixelClock 5 5 5 21 9 63 SetROI 5 8 9 65 SetRTCTiming 5 13 5 18 5 24 5 25 5 39 7 6 9 67 SetSyncMode 5 5 5 19 5 24 9 69 SetSyncPolarity 5 24 9 71 SetTermination 5 9 9 73 SetTime 5 43 9 74 SetTransferMode 5 30 5 31 9 75 SetTriggerEvent 9 76 Index SetVideoFrameSize 5 5 5 7 5 8 9 11 9 77 TimedWaitFinished 5 35 9 79 Wait 5 40 9 80 WaitFinished 5 35 9 82 WindowsEventFromQID 3 3 5 36 9 83 WritelO 5 28 9 84 functions PXRFrame API 10 1 AllocateBuffer 5 41 5 42 7 4 10 2 CopyFrame 10 4 FrameBits 10 6 FrameBuffer 10 7 FrameFromPointer 3 3 5 43 10 8 FrameHeight 10 10 FramePitch 10 11 FrameType 10 12 FrameWidth 10 13 FreeFrame 10 14 GetColumn 10 15 GetPixel 10 16 GetRectangle 10 17 GetRow 10 19 GetTimeStamp 5 42 10 20 PutColumn 10 21 PutPixel 10 22 PutRectangle 10 23 PutRow 10 24 ReadBin 10 25 ReadBMP 10 26 ReadPNG 10 27 WriteBin 10 28 WriteBMP 10 29 WritePNG 10 30 functions Video Display Library IMG_VB_PaintDisplayWindow 3 6 11 2 IMG_VB_SizeDisplayWindow 3 6 11 3 Index 3 Index G gain 1 7 5 13 gain control 1 6 general purpose input output 1 7 5 28 GPI O see general purpose in put output grabs handling stalls 3 17 H H 5 19 HalfH timing function 5 19 handles 3 2 handling stalled grabs 3 17 hardware reference 6 1 horizontal resynchronization 5 5 horizontal sync pulse 5 5 I T O si
19. AllocateBuffer IMG_IMAGEINFO Structure on page 7 2 PXR800 API Functions Chapter 9 SetTransferMode DWORD SetTransferMode FGHANDLE fgHandle IMG TMODE tmMode PXRVB SetTransferMode ByVal fgHandle As Long ByVal tmMode As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG tmMode is the selected transfer mode TMODE INCREMENTAL TMODE BURST Return Value Return is non zero for success zero on failure Description The SetTransferMode function sets the transfer mode used to transfer images In TMODE INCREMENTAL mode the video data from the onboard video buffer is transferred to system memory as soon as the data is received Thus it is likely that target system memory will have all the video data before current video frame ends In TMODE_ BURST mode video data is transferred to system memory in a short burst after the end of the video frame Thus the data will not be available until a few milliseconds after the current video frame ends This function waits for the queue to empty and will invalidate any images stored in the PXR800 buffer memory See Also GetTransferMode SetContinuousBuffering GetContinuousBuffering 9 75 Chapter 9 PXR800 API Functions SetTriggerEvent DWORD SetTriggerEvent FGHANDLE fgHandle DWORD dwTriggerMask IMG TRIGGEREVENT teEvent PXRVB SetTriggerEvent ByVal fgHandle As Long ByVal dwTriggerMask As Long ByVal teEvent As Long
20. Exp0 can only be used to create a custom verti cal blank waveform in the HD_VEXPO mode This is useful for cameras that control exposure by changing the length of vertical sync Exp0 isn t available in sync modes other than DRIVE HD VEXPO Each strobe or exposure signal has a default polarity The default is the state assumed when the generator is idle A negative polarity is approximately 0 Volts and positive polarity is approximately 5 Volts The polarity can be programmed using SetRTCTiming Pulse sequences consist of up to eight segments Each segment can be up to about two hundred million HalfH periods and segments alternate between positive and negative polarity Additionally the first segment in the series can have either positive or negative polarity When the first segment s polarity 5 25 Chapter 5 Detailed Operating Information 5 26 matches the default polarity the first segment acts like a delay between the event and the pulse train Pulse lengths are programmed by setting up a real time structure and passing it to SetRTCTiming In doing this any unused segments at the end of the pulse train should be set to zero length As an example suppose a camera s exposure is controlled by pulses on two control wires The first pulse resets the camera and begins an exposure and the second pulse ends the exposure The camera also requires that a second reset pulse may not happen within the first 200 scan lines of the camer
21. FOrinalsS snscssctsccnssscenescnsnenrceneseasseneeneecenatee 5 6 Table 5 2 Synchronization Modes ssscccceeesssssssssssseseeeee 5 21 Table 5 3 SetPixelClock Timing Information sce06 5 22 Table 5 4 Line and Field Lengths cccsssssseeeseseseseeeeeeeees 5 27 Chapter 6 Table 6 1 Pre Wired Cables osssoooesssooseessooesesssocsesssoesesssoeseese 6 4 Table 6 2 DIN Commer snk cditasnnnnuduununnnuuunnuin 6 5 Table 6 3 26 Pin Connector Pinout cccsssssesessseeseesseseeeees 6 6 Chapter 9 Tape 9 1 Error Codes nei es 9 5 Table 9 2 Drive Mode Naines sscccsancccsascncssscasnsscccsdssncaascaveccsaveesoass 9 9 Table 9 3 Camera Format Information cccceesscecceessseee 9 11 Table 9 4 Pixel Clock Information ccccscseseeseeseseseseeeeees 9 19 Table 9 5 pesEvent and preRepeat Values secsssseeeeees 9 23 Table 9 6 Sync Mode Names sscicscccccccseccccssiscesvescecenecesesscessccaaene 9 27 Table 9 7 Dirive Mode Names ssisssicsiscscicnissssicucncscncncnescocscaeicacita 9 55 Table 9 8 Pixel Clock Information ssseeccseeccsessssseeeeees 9 64 Table 9 9 Sync Mode NaQieS c isccsscessssssssissssicssessassnssassiceseosase 9 70 Introduction Chapter 1 Chapter 1 Introduction The Imagenation PXR800 is a high precision frame grabber designed to cap ture monochrome images from analog sources It is designed to function as a compone
22. Long ByVal geStart As Long ByVal bSwitchToTrigger As Boolean ByVal svStart As Long ByVal flFields As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG pFrame is the handle to the frame grabber buffer that will receive the image dwSkipVSyncs is the number of vertical sync pulses to skip before capturing the image The frame grabber will begin skipping vertical syncs when the conditions described by geStart and svStart are met geStart e GE ON _VSYNC causes a grab where the image is qualified at the end of the next VSync e GE ON VSYNC_START causes a grab where the image is qualified at the start of the next VSync e GE ON VSYNC_AFTER_TRIGGER causes a grab on the next VSync that ends after a trigger event e GE ON VSYNC_START AFTER _TRIGGER causes a grab on the next VSync that begins after a trigger event Continued on the following page 9 36 PXR800 API Functions Chapter 9 Grab continued Parameters continued bSwitchToTrigger if TRUE will cause the grabber to switch to the camera that matches the trigger Otherwise the camera will not be changed svStart identifies which field is used to qualify the grab e SV_EVEN FIELD e SV_ODD FIELD e SV EITHER FIELD flFields identifies the number of fields to include in the image If the grabber is in progressive mode this value is ignored as the image will be one frame in lengt
23. PULSELEVEL plStartLevel IMG PULSELEVEL plDefaultLevel DWORD pdwTick 8 IMG_EXPSEQ CAMERAEVENT typedef struct DWORD dwDelay IMG SWITCH TYPE stSwitchType IMG CAMERA icCamera DWORD dwCameraMask CAMERAEVENT REALTIME typedef struct IMG EXPSEQ pExposures RT EOL CAME RARVENT ceCamerakvent REALTIME Members plStartLevel the signal level for the first time period of the pulse sequence After the first period the signal level will alternate for the remaining time periods Can be either PULSE LOW or PULSE HIGH plDefaultLevel the level the signal assumes when no pulse sequence is happening Can be either PULSE LOW or PULSE HIGH pdwTick the length of each pulse in the sequence in HalfH periods If fewer than eight periods are needed set the extra pdwTick values to zero The tick value for each pulse is a 28 bit number which means that the maximum pulse length is 268 435 455 ticks or a little over two hours Continues on the following page 7 5 Chapter 7 PXR800 API Structures 7 6 REALTIME Structure continued The CAMERAEVENT structure fields have the following meanings dwDelay the time delay between the trigger event and the moment the current cam era switches This is measured in HalfH periods and is a 28 bit number like the pdwtick values stSwitchType icCamera dwCameraMask how to decide which camera to switch to Possible choices are ST_TO NEXT the low four bits of dwCameraMask describ
24. So 2e EDU 4 OUTPUT ANALOG PROCESSING BUFFER QUALIFICATION MEMORY OFFSET amp GAIN PXR800 ve INTERFACE DRIVERS PC SYSTEM SYSTEM APPLICATION Simplified functional block diagram of the PXR800 For simplicity not all control links are shown here but most functions shown can be controlled via the application program Figure 1 2 PXR800 Functional Diagram The selected incoming video signal from the camera interface can be condi tioned by two analog functions The first of these is Nyquist filtering which is used to remove high frequency noise that might result in aliasing errors dur ing the signal digitizing process The second analog processing function is a gain control which can be set for unity gain or a gain factor of two Gain control may be necessary to boost low level video signals for more effective use of the digitizer s dynamic range Selection of Nyquist filtering on or off and analog gain is done under control of the application program From analog processing the video signal proceeds to the analog to digital converter ADC The ADC samples and digitizes the video signal Sampling is done according the frequency of the camera s pixel clock if the camera supplies one or it can be done according to the PXR800 s internal pixel clock Several PXR800 pixel clock rates are available and program selectable accord 1 6 Introduction Chapter 1 ing to specific needs for the incoming video
25. Visual Basic Functions This section describes the Visual Basic functions for initializing and exiting libraries Separate functions are provided for the PXRFrame library e FRAMEVB OpenLibrary e FRAMEVB CloseLibrary and for the PXR800 library e PXRVB_ OpenLibrary e PXRVB CloseLibrary 8 5 Chapter 8 Initializing and Exiting Libraries FRAMEVB_OpenLibrary FRAMEVB OpenLibrary ByVal i As Long ByVal s As Integer As Boolean Parameters i always zero s always zero Return Value True on success False on failuare Description The FRAMEVB OpenLibrary function opens a library to provide access to PXRFrame functions The function also opens any associated device driver files This library is a DLL The function fails returning False when the library cannot be found or the parameters are invalid 8 6 Initializing and Exiting Libraries Chapter 8 FRAMEVB_CloseLibrary FRAMEVB CloseLibrary ByVal i As Long Parameters i always zero Return Value None Description The FRAMEVB CloseLibrary function closes the PXRFrame library and releases any resources that were opened with the corresponding call to FRAMEVB OpenLibrary Programs must not access any library functions after the library is closed Doing so will result in an invalid function call and might cause a General Pro tection Fault 8 7 Chapter 8 Initializing and Exiting Libraries PXRVB_OpenLibrary PXRVB OpenLibrary ByVal i As Long ByVa
26. and horizontal sync separately They are connected to the PXR800 via the Vsyne and Hsync wires In SetSyncMode SYNC_HS VS selects this mode The signals can be similar to composite sync signals However the vertical sync signal is typically a single pulse rather than a complete composite vertical sync waveform The vertical syne will usually be 3H long 2 5 for CCIR but it might also be some other pulse such as a WEN signal Composite Sync on External Line Horizontal and vertical sync are combined on a separate line from the camera This composite sync signal can be identical to the standard sync signals or can be a simplified version The video signal on another wire might or might not contain embedded sync information In SetSyncMode SYNC_HLINE selects the Composite Sync on External Line mode External Sync Drive Synchronization can also be driven by the PXR800 In these modes which are selected via SetDriveMode the PXR800 generates horizontal and vertical sync pulses and sends them to the camera Two modes DRIVE_HD_VD and DRIVE HD VEXPO are supported Detailed Operating Information Chapter 5 Mode Name Description SYNC_HS VS Horizontal sync comes from the camera on the HS wire Vertical sync comes from the camera on the VS wire SYNC_HC_VS Horizontal sync is extracted from the composite video sig nal Vertical sync comes from the camera on the VS wire This is also the mode to use if the camera transmits a WEN
27. as Part of a Product Once you have developed an application for the PXR800 you might wish to install the PXR800 and your application software in many computers or you might wish to supply PXR800 frame grabbers with your application for other users to install There are two strategies for doing these installations e If you are installing small numbers of units use the PXR800 Installation Disk Install using the procedure in Installing the PXR800 Software from the Setup CD on page 2 1 installing only the runtime support and not the SDK or samples After the PXR800 software is installed install your application software using a separate installation procedure e If you need to install large numbers of units or if you are distributing your application for end users to install create an installation disk of your own that installs the PXR800 runtime along with your application When doing this consider which operating systems the target computer might be running and be sure to install the correct PXR800 drivers for each system Table 2 1 lists the required files for the PXR800 under various operating systems Operating System Driver File Other Support Files Windows NT 4 0 pxr800NT sys pxr800 dll pxrframe dll Windows 2000 and pxr800 sys pxr800 dll pxrframe dll Windows XP pxr800 inf Windows 98 Windows pxr800 sys pxr800 dll pxrframe dll 98 SE and Windows Me pxr800 inf Note Visual Basic programs that use the Video D
28. available this function returns a handle that must be used in the other library functions that refer to the frame grabber The frame grabber will be reset to a default state The application should call FreeFG on the grabber when it is no longer needed The AllocateFG function will fail if the frame grabber has already been allo cated by another process or if the PXR800 hardware and drives have not been properly installed See Also FreeFG ResetFG PXR800 API Functions Chapter 9 BlockGrabber QUEUEID BlockGrabber FGHANDLE fgHandle BOOL bBlock DWORD pdwDepth IMG WHEN iwWhen PXRVB BlockGrabber ByVal fgHandle As Long ByVal bBlock As Boolean ByVal pdwDepth As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG bBlock is TRUE to increase the block depth FALSE to decrease it pdwDepth holds the return value which is the new blocking depth The return in pdwDepth is written immediately but represents the block ing depth that will be in effect when the queued operation actually runs NULL is a valid parameter iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI_ INVALID on failure Description The BlockGrabber function can disable or block an
29. every other line from a full frame If a single field is grabbed the number of lines actually captured is half of the ROIHeight The captured lines will be placed in the upper half of the target buffer If the full ROIHeight is odd one field will be half height rounded up and the other will be half height rounded down Which field is taller depends on the value of ROITop This function will not return until all queued operations have completed See Also SetROI SetVideoFrameSize GetVideoFrameSize GetFieldLength Table 9 3 on page 9 11 9 21 Chapter 9 PXR800 API Functions GetRTCStart DWORD GetRTCStart FGHANDLE fgHandle IMG EVENT START peskEvent IMG REPEAT preRepeat IMG START VSYNC psvStart PXRVB GetRTCStart ByVal fgHandle As Long ByRef pesEvent As Long ByRef preRepeat As Long ByRef psvStart As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG pesEvent is the address to receive the code for the starting event e ES OFF RTC is not programmed to run or the last RP_SINGLE sequence has completed e ES NOW RTC was started with ES_NOW e ES ON _VSYNC RTC will start on the end of VSync e ES ON VSYNC_START RITC will start on the beginning of VSync e ES ON TRIGGER RTC will start on a trigger event e ES ON VSYNC_AFTER TRIGGER RTC will start on a trigger event that is followed by the end of Vsync ES ON VSYNC_START AFTER TRIGGER RTC will star
30. external trigger event might cause the program to capture a black image or wait forever trying to synchronize to the camera Many of the library functions called in this program can fail and unlike this example a good program will check the return values of all library functions For example if all frame grabbers are being used by other programs AllocateF6G will return INVALID GRABBER and hFG will not be a usable frame grabber handle Since this program does not check for this error it will pass the invalid handle to several other library functions causing them to fail as well 3 13 Chapter 3 Programming the PXR800 Camera Detection and Configuration 4 3 14 The PXR800 frame grabber can capture images from a wide variety of camera formats The application program generally needs to configure the frame grab ber to work with each particular camera format In some applications the camera to be used is known when the program is developed so the program can assume known settings Often however it is useful to detect what type of camera is installed when the program runs Usually the best way to detect what type of camera is attached is to call GetFieldLength which returns the number of scan lines in a video field from the camera This number can then be used to determine the format for the camera The sample code below detects the field length of the attached camera and sets up the frame grabber accordingly This function i
31. format RS 170A or CCIR PAL standards The digitizing is to 8 bits providing 256 digital levels of grayscale representation After the ADC the digitized video signal can be adjusted for offset and gain Offset allows the signal to be shifted up or down through the grayscale range similar to a brightness control Gain or fine gain multiplies the signal ampli tude for greater grayscale definition of fine detail in the image Both opera tions Offset and Gain are performed digitally on the digitized video signal and both operations are controlled via the application program LUT and ROI operations are performed next The LUT Cook up table can apply various pixel mapping operations such as gamma correction or image contrast adjustment The translations performed depend on the value loaded into the LUT by the application program ROI region of interest allows image capture to be confined to a selected region of the full video frame if so desired Again both the LUT and ROI operations are programmable and are set up under control of the application program The qualification operation occurs after the LUT and ROI operations Qualifi cation determines whether or not a video image is actually grabbed into the PXR800 Buffer Memory Whether or not an image is qualified depends on a variety of factors determined by requests for grabbing a specific field or frame or requests for grabbing images associated with specific triggers or events An e
32. image frame Interlaced video does represent motion of large objects more faithfully This is because in interlaced video the viewable region of the camera is scanned twice as often once for each of the two fields that make up a frame Unfortu nately minute examination of individual images from an interlaced camera requires either looking at a single field which has only half the scan lines or looking at a frame made from two fields exposed at slightly different times In the one case looking at one field you get only half the vertical resolution of a full frame In the other case looking at an interlaced frame edge detail may be smeared by motion occurring between exposures of each field A progres sive scan camera however exposes and transmits entire frames at the full res olution of the camera This provides maximum object resolution with good edge detail in a single image Sometimes it s necessary to capture an image representing a view from the camera at a precise instant in time Consider for example an assembly line where parts are moving past the camera at several meters per second The part will be in the camera s field of view for only a few milliseconds As a result a continuous video stream may not be able to provide a good image of the part because images are being exposed at intervals of only about 30 milli seconds The above problem can be resolved with an asynchronously resettable cam era An asynchronously res
33. mov ing object is exposed using a field interlaced camera The result is that under close observation the vertical edges of moving objects are depicted with a picket fence effect This is illustrated in Figure 5 5 OBJECT BEING CAPTURED OBJECT S a DIRECTION OF MOTION ODD FIELD LINES EVEN FIELD LINES SS K LINE INTERLACED VIDEO S e s IMAGE OF MOVING OBJECT Interlace offset occurs when a moving object is captured with a video camera that uses an interlaced field format RS170 or CCIR PAL The amount of interlace offset and how it appears on the object image depend on the speed and direction of the object s movement during video exposure Figure 5 5 Interlace Offset 5 11 Chapter 5 Detailed Operating Information 5 12 Interlace offset is an artifact of interlaced field capture of moving objects When an object is exposed by the video camera the odd field of alternate lines is scanned first vertical blanking occurs and then the even field of alter nate lines is scanned All the while the object is moving Thus the object is in one position when the odd field lines are scanned and is in another position when the even field lines are scanned When the two fields are interlaced into a frame the object appears to have regularly jittered edges as illustrated in Figure 5 5 on page 5 11 There are various solutions to the interlace offset problem Which solution or combination of solutions you
34. needed or wanted they can be cancelled with KillQueue When called KillQueue applies to the entire queue It cannot be selectively applied to individual operations in the queue Operations executing when KillQueue is called might be stopped prior to completion For example a Grab might stop after writing some image data to memory Similarly a SetLUT might be cancelled after changing only some of the LUT values Generally it s not possible to determine exactly how far a queued operation has progressed when it s cancelled Consequently your application program should assume that anything that can be changed by a queued operation will be in an unknown state after KillQueue Such possi bly questionable values should be reset by your program before continuing In extreme situations or if you just want to start over ResetFG can be used to clear the queue and to reset the entire PXR800 to its default values Calling IsFinished WaitFinished or TimedWaitFinished on a QUEUEID for an operation cancelled by KillQueue or ResetFG will cause a response that is the same as if the operation had actually completed The WindowsEventFromQID function allows you to handle Win32 events It returns a handle to a Win32 Event object This handle represents a queued operation The event is a manual reset event which becomes signaled when the operation completes Any of the Win32 functions that operate on synchro nization objects such as WaitForSingleObjec
35. pixel values Data in the file exactly match the format of the data in mem ory If the file already exists and bOverwrite is FALSE the function returns an error otherwise the contents of the file are overwritten This function opens and closes the file 10 28 PXRFrame API Functions Chapter 10 WriteBMP DWORD WriteBMP PXRFRAME pFrame char szFilename BOOL bOverwrite FRAMEVB WriteBMP ByVal pFrame As Long ByVal szFilename As String ByVal bOverwrite As Boolean As Long Parameters pFrame is the address of a PXRFrame szFilename is the name of the file to write bOverwrite is TRUE if the file can be overwritten if it already exists is FALSE if it cannot be overwritten Return Value SUCCESS the file was written successfully FILE EXISTS the file already exists but bOverwrite was FALSE FILE OPEN ERROR the file could not be opened BAD WRITE an error occurred while the file was being written INVALID FRAME the frame pointer is invalid Description The WriteBMP function writes the image in the frame into the specified file in the Windows BMP format If the file already exists and bOverwrite is FALSE the function returns an error otherwise the contents of the file are overwritten The function opens and closes the file 10 29 Chapter 10 PXRFrame API Functions WritePNG DWORD WritePNG PXRFRAME pFrame char szFilename BOOL bOverwrite FRAMEVB WritePNG ByVal pFrame As L
36. pro cessing of images sequences While a new image is being captured into one PXR800 buffer the previously captured image in the image sequence is being copied out of the other buffer to the PCI bus Coherency issues can arise when application programs change the proper ties of incoming images while continuous buffering is being used Changing gain or offset or performing other image processing midway through capture will result in the PXR800 buffer memory containing image pixels from prior to the change and after the change This coherency problem one portion of the image with one setting and the other portion with another setting is typically not a problem in single buffering mode The PXR800 API offers several fea tures designed to help you avoid potential coherency problems These fea tures are e Invalidating the buffer e Blocking e Waiting Invalidating the Buffer The InvalidateGrabberBuffer function dis cards the image currently being acquired into the PXR800 memory buffer This allows you to clear the PXR800 buffer of old image data captured prior to image changes or processing done by the application program The result is an empty buffer ready to accept new coherent image data Note that InvalidateGrabberBuffer applies only when the PXR800 is set for continuous buffering mode If the PXR800 is in single buffering mode InvalidateGrabberBuffer does nothing Also in continuous buffering if an image isn t currently being
37. sizeof PXRAPTI ameLib sizeof PXRFRAMELIB 480 PBITS Y8 TRUI PXR Grab hFG pFrame 0 GE ON VSYNC FALSE FL FRAME FrameLib WriteBMP IW WAIT pFrame TEST BMP TRUE MessageBox NULL Grab saved to TEST BMP PXR FreeFG hFG FrameLib FreeFram imagenation Close imagenation Close researc WSN IES The following section provides a line by line pFrame Library amp FrameLib Library amp PXR SV_EITHER FIELD f Done MB OK Be fi r explanation of the program 3 9 Chapter 3 Programming the PXR800 3 10 Line by Line Explanation include lt windows h gt Include windows h to get access to Windows user interface features such as MessageBox Strictly speaking this is not necessary because pxr800api h also includes windows h include pxr800api h include pxrframe h Include files to declare functions and constants for the PXR800 library and the PXRFrame library This must be done to access any of the library functions PXRFRAMELIB FrameLib The PXRFrame library functions can be called only by using a PXRFRAMELIB structure Here a global PXRFRAMELIB structure named FrameLib is cre ated which will be used for the rest of the program to call PXRFrame library functions Declaring FrameLib here only creates the structure the library can t be used until it is opened PXRAPI PXR Like the PXRFrame libra
38. specifications 6 2 overview of PXR800 features amp op eration 1 5 P PAL 5 2 ping pong 5 28 pixel clock 5 7 6 3 9 19 specifications 6 3 PNG format 5 43 programming the PXR800 3 1 C language programming 3 4 library interface 3 1 multithreaded programs 3 7 PXR Productivity Tool 4 1 Visual Basic programming 3 5 progressive scan 1 3 5 3 pulse generation 5 25 pulse lengths 5 26 pulse sequences 5 25 PXR Productivity Tool 4 1 PXR800 as part of a product 2 4 features for machine vision 1 4 hardware reference 6 1 Index installing 2 1 software installation 2 1 uninstalling 2 3 pxr800 bas 3 7 pxr800 dll 2 4 3 1 8 2 pxr800 sys 2 4 pxr800_display dll 2 4 3 5 3 7 pxr800api bas 3 7 pxr800NT sys 2 4 PXR801 Camera Extender Board 2 2 PXRFrame library 5 43 pxrframe bas 3 7 pxrframe dll 2 4 3 1 8 2 PXRFrames 3 3 5 41 Q qualification 1 7 QUEUEID 3 2 queuing 5 34 quick installation 2 1 R real time control 5 17 REALTIME data structure 7 5 region of interest ROD 1 7 5 1 5 8 repairing software 2 3 RGB expansion 5 42 ROI see region of interest RS 170A 5 2 RTC see real time control S SDK see software development kit selecting cameras 5 18 simple image capture program 3 8 single buffering 5 29 5 31 single buffered burst transfer mode 5 32 Index 5 Index single buffered incremental trans fer mode 5 31 software development kit SDK 3 1 software upgrading and repair 2 3 stall
39. the frame grabber returned by AllocateFG Return Value The return value is the current drive mode as set by SetDriveMode Description This function returns the currently selected drive mode Returns immediately Mode Name Description DRIVE DISABLED The frame grabber doesn t generate drive signals It will try to synchronize to the currently selected cam era using the mode specified by SetSyncMode DRIVE HD VD The frame grabber will generate drive signals on the HS and VS wires The timing of the drive signals depends on the camera format set by SetPixelClock and SetInterlaceMode DRIVE HD VEXPO The frame grabber will generate drive signals on the HS and VS wires The timing of horizontal drive depends of the camera format selected by SetPixelClock but the vertical timing is con trolled by the RTC using the ExpO pulse generator DRIVE INVALID See Also On error Table 9 2 Drive Mode Names SetDriveMode SetSyncMode GetSyncMode SetSyncPolarity GetSyncPolarity SetPixelClock SetInterlaceMode SetRTCTiming 9 9 Chapter 9 PXR800 API Functions GetFieldLength 9 10 DWORD GetFieldLength FGHANDLE fgHandle PXRVB GetFieldLength ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value The return value is the number of lines in the last video field as measured by the frame grabber DW_ ERROR on erro
40. the timing periods of the RTC The data is copied before SetRTCTiming returns so prtRealTime can be changed or freed before the queued operation fin ishes dwMask is a mask of the strobe lines that should be reprogrammed e EXPO TIMING MASK e EXP1 TIMING MASK e EXP2 TIMING MASK e STROBE TIMING MASK e CAMERA TIMING MASK iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI_ INVALID on failure Continued on the following page 9 67 Chapter 9 PXR800 API Functions SetRTCTiming continued Description The SetRTCTiming function sets the RTC values of the PXR800 grabber To start the real time sequence use RTCStart See Also GetRTCTiming RTCStart GetRTCStart MicsToHalfH REALTIME Structure on page 7 5 9 68 PXR800 API Functions Chapter 9 SetSyncMode DWORD SetSyncMode FGHANDLE fgHandle IMG CAMERA icCamera IMG SYNCMODE smMode PXRVB SetSyncMode ByVal fgHandle As Long ByVal icCamera As Long ByVal smMode As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG icCamera is one of the cameras e CAMERAO e CAMERA1 e CAMERA2 e CAMERA3 smMode is the sync mode e SYNC_HS VS e SYNC HC VC e SYNC HC VS e SYNC HLINE See Table 9 9 on page 9
41. using the following pinout information see Figure 6 4 below and Table 6 3 on page 6 6 Each of the four camera connectors use the same pinouts PIN 9 PIN 1 00 000000 PIN 18 00000000 fPIN10 6 066 PIN 26 PIN 19 Figure 6 4 26 Pin Connector Diagram 6 5 Chapter 6 Hardware Reference Video Description Analog video signal from camera Might contain com posite sync signals GP Input 0 GP Input 1 GP Input 2 GP Input 3 General purpose digital data inputs The PXR800 can read these and report the values HSync HDrive If drive mode enabled horizontal sync from PXR800 to camera If drive mode disabled horizontal sync from camera to PXR800 VSync VDrive If drive mode enabled vertical sync from PXR800 to camera If drive mode disabled vertical sync from cam era to PXR800 Ground for 12V 12 Volts Ground return for 12 Volt camera power 12 Volt power for camera Ground for Video Analog ground for video signal Ground Ground for pixel clock or control signals Ground Ground Ground TTL Trigger Opto Trigger Low Grounds for control signals TTL Trigger signal from external device to PXR800 Don t connect both TTL trigger and isolated trigger Current return for optically isolated trigger Ground Ground for control signals Strobe Strobe control pulse from PXR800 to camera or light ing Pixel Clock
42. 0 software Product CDs received after March 2003 have the PXR Productivity Tool embedded in the PXR800 installa tion application which also creates a Start menu shortcut for your conve nience 4 1 Chapter 4 The PXR Productivity Tool 4 2 Benefits of Using the PXR Productivity Tool Because the PXR Productivity Tool allows you to create and program any situ ation you choose without writing any code it represents a step beyond the samples provided with the PXR800 frame grabber While the samples illustrate how the frame grabber works and how to write your software application the PXR Productivity Tool lets you explore these issues through dialog boxes and eliminates the edit compile and run sequence PXR Productivity Tool Architecture The PXR Productivity Tool is a multi threaded application that gives you immediate and continuous feedback as you investigate the PXR800 API com mands The Tool lets you execute API commands through dialog boxes Ten dialog boxes including the Main Control window implement over 15 of the most important and useful API commands The PXR Productivity Tool has a display thread that gives you constant image feedback in a video window No time delay occurs between the actions you take and seeing the results The PXR Productivity Tool will let you configure the PXR800 for a particular cam era and situation and then save that configuration to a file for later use Dialog Box Design In designing
43. 12 See Also IMG VB SizeDisplayWindow 11 2 The Video Display Library Chapter 11 IMG_VB_SizeDisplayWindow IMG VB SizeDisplayWindow ByVal x As Long ByVal y As Long ByVal dx As Long ByVal dy As Long Parameters x is the X coordinate in pixels of the upper left region in the destination window y is the Y coordinate in pixels of the upper left region in the destination window dx is the width in pixels of the region in the destination window dy is the height in pixels of the region in the destination window Return Value None Description The IMG_VB_SizeDisplayWindow function specifies a rectangle in the cli ent area of a window to receive the pixels copied by a call to the IMG VB PaintDisplayWindow function See Also IMG VB PaintDisplayWindow 11 3 Chapter 11 The Video Display Library This page intentionally left blank 11 4 Index Numerics 12 volt power output 6 1 A acquisition sequencer 5 18 ADC see analog to digital converter aliasing 5 10 analog video processor 5 18 analog to digital converter ADC 1 6 anti aliasing 5 10 API see application programming interface application programming interface 1 7 3 1 data structures 7 1 PXR800 API functions 9 1 PXRFrame API functions 10 1 attaching cameras 2 2 B BAS files imaginfo bas 3 7 pxr800 bas 3 7 pxr800api bas 3 7 pxrframe bas 3 7 Bin format 5 43 blocking grabs 5 39 blur 5 12 BMP format 5 43 buff
44. 2 or 625 lines PCLOCK_NTSC_RECTANGLE 13 5 MHz 858 Clocks 262 1 2 or 525 lines PCLOCK_CCIR_RECTANGLE 13 5 MHz 864 Clocks 312 1 2 or 625 lines synced to rising None None edge of PCL synced to falling None None edge of PCL PCLOCK EXT PCLOCK EXT INVERTED The default line width and field length are used when the drive mode is not DRIVE_DISABLED see SetDriveMode In this mode the timing of horizontal and vertical drive pulses is based on the pixel clock setting The shorter field length is used in interlaced mode and the longer length is used in progressive mode see SetInterlaceMode The external pixel clock and vertical and horizontal drive cannot be used together so there is no default width or length in the modes that use an external pixel clock Table 9 8 Pixel Clock Information See Also GetPixelClock Table 9 3 on page 9 11 9 64 PXR800 API Functions Chapter 9 SetROI QUEUEID SetROI FGHANDLE fgHandle DWORD dwROILeft DWORD dwROITop DWORD dwROIWidth DWORD dwROIHeight IMG WHEN iwWhen PXRVB SetROI ByVal fgHandle As Long ByVal dwROILeft As Long ByVal dwROITop As Long ByVal dwROIWidth As Long ByVal dwROTHeight As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwROILeft is the left offset of the ROI valid range 0 2047 dwROITop is the top offset of the ROI valid range 0 2047 dwRO
45. 47 These top and left val ues determine where the top left corner of the ROI box is positioned in the video image When doing single field grabs the height of the captured image will be half of the ROI height If height is set to an odd value one field will be half rounded up and the other field will be half rounded down Which is which depends on whether dwROITop is even or odd It is possible to define ROI dimensions and positioning such that the specified ROI rectangle extends beyond the region of valid video as specified by SetVideoFrameSize If this is done ROI will automatically be set to a rect angle that fits in the valid video area For example if the right side of the ROI box extends beyond valid video the captured ROI will extend only to the end of valid video and not beyond Detailed Operating Information Chapter 5 Image Manipulation and Image Quality The PXR800 frame grabber supports a variety of image manipulation capabili ties at the video input Some of these capabilities are applied to the incoming analog video signal others are applied after the video signal is digitized Figure 5 4 provides a functional overview of these capabilities which include multiplexing up to four cameras Nyquist filtering gain range digitizing off set fine gain and a LUT Look Up Table for grayscale pixel translations CAMERA 0 CAMERA 1 re FILTER CAMERA 3 TO PXR800 OFFSET LUT BUFFER MEMORY Analog to Digital Inp
46. 70 Return Value The return is non zero for success zero on failure Description The SetSyncMode function sets the source of the video sync signals for the specified camera This function waits for the queue to empty Continued on the following page 9 69 Chapter 9 PXR800 API Functions SetSyncMode continued Sync Mode Description SYNC_HS VS Horizontal sync comes from the camera on the HS wire Vertical sync comes from the camera on the VS wire SYNC_HC_VS Horizontal sync is extracted from the composite video sig nal Vertical sync comes from the camera on the VS wire This is also the mode to use if the camera transmits a WEN pulse or trigger pulse instead of vertical sync connect the trigger or WEN pulse to the VS wire SYNC_HC_VC Horizontal and vertical syne are both extracted from the composite video signal This is the normal operating mode of most video cameras SYNC_HLINE See Also Horizontal and vertical sync come from the camera mixed on the HS wire This is the mode to use if the camera sends video on one wire and a composite sync signal on a second wire or if you are trying to genlock all parts of a system to a master composite sync signal Table 9 9 Sync Mode Names GetSyncMode GetDriveMode SetDriveMode SetSyncPolarity GetSyncPolarity Table 9 7 on page 9 55 9 70 PXR800 API Functions Chapter 9 SetSyncPolarity DWORD SetSyncPolarity FGHANDLE fgHandle IMG CAM
47. A video source is composed of 525 horizontal picture lines CCIR PAL sources have 625 lines per frame In the 2 1 interlaced format the video camera scans half of the lines first in odd number order 1 3 5 to produce the odd field of 262 5 lines Then the remaining half of the video lines are scanned in even number order 2 4 6 to produce the even field A complete video frame consists of the two fields interlaced together as shown in Figure 5 2 STARTS WITH HALF LINE ODD FIELD EVEN FIELD tll il ENDS WITH HALF LINE Interlaced video frames are composed of interlaced lines from an odd and an even field of lines Note that the odd field ends with a half line and the even field begins with a half line Figure 5 2 Interlaced Format In progressive scan systems the video lines are scanned in order from top to bottom to produce a complete frame as the video output By contrast inter laced systems output two fields that when combined by interlacing comprise a frame Consequently a progressive scan system only grabs frames while fields or frames can be selectively grabbed in an interlaced scan system In both progressive scan and interlaced systems a horizontal synchronization pulse separates the individual lines of video image information Horizontal retrace to the beginning of the next scan line occurs during this horizontal 5 3 Chapter 5 Detailed Operating Information 5 4 sync period Additionally vertic
48. API Functions SetinterlaceMode QUEUEID SetInterlaceMode FGHANDLE fgHandle IMG VIDEO FORMAT vfFormat IMG WHEN iwWhen PXRVB SetInterlaceMode ByVal fgHandle As Long ByVal vfFormat As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG vfiFormat is the video format FORMAT INTERLACED FORMAT PROGRESSIVE iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI_ INVALID on failure Description The SetInterlaceMode function tells the frame grabber which format to expect for images arriving from the camera The frame grabber does not innately know whether the image is interlaced or progressive scan because it can accept images from non standard cameras The application must tell the frame grabber which image format to expect from the camera This will invalidate any images stored in the PXR800 buffer memory See Also GetInterlaceMode SetVideoFrameSize GetVideoFrameSize Table 9 3 on page 9 11 9 58 PXR800 API Functions Chapter 9 SetLUT QUEUEID SetLUT FGHANDLE fgHandle DWORD dwFirstIndex DWORD dwLength BYTE pbLUT IMG WHEN iwWhen PXRVB SetLUT ByVal fgHandle As Long 7 ByVal dwFirstIndex As Long ByVal dwLength As Long ByRef pbLUT A
49. CR IME DA 506 dwlopOffset CCIR TOP DEFAULT 507 dwWidth CCHR WIDTH DEFAULT 508 dwHeight CCIR_HEIGHT DEFAULT 509 break 510 Salli RS170 NTSC non interlaced ge case 524 alee case 525 514 case 526 SAL pcClock PCLOCK NTSC SQUARE SiG vfFormat FORMAT PROGRESSIVE SIL dwLeftOffset RS170 LEFT DEFAULT 518 dwTopOffset RS170 TOP DEFAULT SiS dwWidth RS170 WIDTH DEFAULT SAO dwHeight RS170 HEIGHT DEFAULT 521 break 522 529 CCIR non interlaced 524 case 625 525 case 626 526 pcClock PCLOCK CCIR SQUARE 527 vfFormat FORMAT PROGRESSIVE 528 dwLeftOffset CCUR LEDE DEFAULT D218 dwlopOffset CCIR TOP DEFAULT DS dwWidth CCIR WIDTH DEFAULT 531 dwHeight CCIR_HEIGHT DEFAULT 5S2 break 533 3 15 Chapter 3 Programming the PXR800 pxr_grab c lines 534 550 534 535 536 S37 538 539 54 54 54 54 54 54 54 54 54 54 550 Ss Ke we sil fen Gal SS tee key Ie 3 16 dwiImageX dwWidth dwiImageY dwHeight need to set the pixel clock to the proper scan rate because the PXR is not capable of auto detecting the video type PXR SetPixelClock hFG pcClock IW WAIT set the interlace mode as determined abov PXR SetInterlaceMode hFG vfFormat IW WAIT now we need to set the correct video parameters for the video size this data needs to be correct in order to grab frames PXR SetVideoFrameSize hFG dwheftOffset dwTo
50. Chapter 8 Initializing and Exiting Libraries on page 8 1 For reference information on the PXR800 API functions refer to Chapter 9 PXR800 API Functions on page 9 1 For reference information on the PXR800 Frame Library refer to Chapter 10 PXRFrame API Functions on page 10 1 This reference is a general guide for using the structures in personal comput ers running the Microsoft Windows operating system versions 98 98 SE Me NT4 2000 or XP The structures work as written for C C and Visual Basic with the header files provided 7 1 Chapter 7 PXR800 API Structures IMG_IMAGEINFO Structure Toe IMG_IMAGEINFOTIMING typedef struct BYTE BYTE BYTE BYTE bHour24 bMinute bSecond bSecondHundredths IMG IMAGEINFOTIMING IMG_IMAGEINFOSTATUS typedef struct DWORD dwFieldInSecond DWORD dwFieldCount BYTE BYTE BYTE BYTE BYTE BYTE BYTE BYTE WORD WORD bFields bCamera bQualifyingTrigger bInputs bOutputs bPack0 bPack1 bPack2 wValidLinesFirstField wValidLinesSecondField DWORD dwQualifyCount BYTE pbDebug 32 IMG IMAGEINFOSTATUS IMG_IMAGEINFO typedef struct IMG IMAGEINFOTIMING Timing IMG IMAGEINFOSTATUS Status IMG IMAGEINFO Continues on the following page PXR800 API Structures Chapter 7 IMG_IMAGEINFO Structure continued Members bHour24 bMinute bSecond bSecondHundredths are the current time as reported by the frame grabb
51. Display DLL The Video Display Library requires no initialization For more information on the Video Display Library see Displaying Video in Visual Basic Applications on page 3 5 11 1 Chapter 11 The Video Display Library IMG_VB_PaintDisplayWindow IMG VB PaintDisplayWindow ByVal hDC As Long a ByVal PXR Frame As Long ByVal x As Long ByVal y As Long ByVal dx As Long ByVal dy As Long Parameters hDC is the device context for the window where the function displays the image copied from the source frame PXR_Frame is the address of the source frame from which to copy the pixels x is the X coordinate in pixels of the upper left region in the source frame y is the Y coordinate in pixels of the upper left region in the source frame dx is the width in pixels of the region in the source frame dy is the height in pixels of the region in the source frame Return Value None Description The IMG_VB_ PaintDisplayWindow function copies a rectangular area of pixels from the source frame specified by PXR_Frame scales the copied image to fit the rectangular area specified previously by the function IMG VB SizeDisplayWindow and draws the scaled image into the win dow specified by the device context hDC If the dimensions of the display rectangle are not specified by a call to IMG VB SizeDisplayWindow the IMG VB PaintDisplayWindow function uses the default dimensions x 0 y 0 dx 640 and dy 5
52. ERA icCamera IMG POLARITY poVDrive IMG POLARITY poHDrive PXRVB SetSyncPolarity ByVal fgHandle As Long ByVal icCamera As Long ByVal poVDrive As Long ByVal poHDrive As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG icCamera is one of the cameras e CAMERAO e CAMERA1 e CAMERA2 e CAMERA3 povDrive is the vertical sync polarity value e POLARITY POSITIVE e POLARITY NEGATIVE poHDrive is the horizontal sync polarity value e POLARITY POSITIVE e POLARITY NEGATIVE Return Value The return is non zero for success zero on failure Continued on the following page Chapter 9 PXR800 API Functions SetSyncPolarity continued Description The SetSyncPolarity function sets the expected polarity for incoming sync signals Use SetSyncMode to control the source of the sync signals If the sync mode is SYNC_HC_VS polarity for the horizontal signal is ignored If the sync mode is SYNC_HC_VC polarities for both vertical and horizontal sig nals are ignored Returns immediately See Also SetSyncMode GetSyncPolarity GetSyncMode 9 72 PXR800 API Functions Chapter 9 SetTermination DWORD SetTermination FGHANDLE fgHandle IMG CAMERA icCamera IMG TERMINATION itTermination PXRVB SetTermination ByVal fgHandle As Long ByVal icCamera As Long ByVal itTermination As Long As Long Parameters fgHandle is the handle to the frame grabber re
53. Frame in system memory Once an image is grabbed and transferred to system memory it can be pro cessed or analyzed further by application programs displayed on the system monitor archived printed transferred to other systems or operated on in any other manner desired The Next Step 1 8 The preceding overview of PXR800 features and operation has been brief and has covered only the basic highlights Much more detailed information and various application examples are provided throughout the remainder of this manual Installing the PXR800 Chapter 2 Chapter 2 Installing the PXR800 Quick Installation Installing the PXR800 Software from the Setup CD 1 Log on using an account with administrative privileges Qf you are using Windows 98 or Windows Me there is no separate administrator account and you can install as any user 2 Insert the Imagenation PXR800 Installation Disk into the CD Drive and run Setup 3 Follow the instructions provided by Setup to install the PXR800 drivers and development software Installing the PXR800 Card Caution Static electricity can damage the electronic components on the PXR800 board Before you remove the board from its antistatic pouch ground yourself by touching the computer s metal back panel 1 Turn off the computer and unplug it then remove the cover 2 Locate an unused PCI slot and remove the slot cover plate Save the screw 3 Insert the PXR800 into th
54. H amp VSYNC 0 3 H amp VDRIVE x4 CAMERA SELECT SetCamera SetRTCTiming Grab INTERNAL SYNC CONTROL CAMERA SELECT PULSE GENERATORS SetRTCTiming Exp0 PIXEL CLOCK fee Grab EVENT DETECT SetPixelClock fee RTCStart Grab This is a Real Time Control Model for the PXR800 with key software commands indicated in various functional blocks Figure 5 7 Real Time Control Model Camera Select Before image capture can occur a camera must be selected as the image source The source can be any one of up to four cameras connected to the PXR800 Selection of a camera source is normally done with SetCamera However cameras can also be selected by camera switching in the Grab function or by events from the Event Detector as determined by SetRTCTiming Only one camera at a time can be the image source for grabs VIDEO 0 3 in Figure 5 7 SetCamera can be used to explicitly switch to another camera Or switching can be done automatically in response to a trigger as specified by SetRTCTiming Triggers can be used to switch the camera to match the trigger to switch to the next camera in a list or to switch to a specific camera Detailed Operating Information Chapter 5 The timing of the switch relative to the triggering event can be programmed to HalfH H 2 accuracy where H is the horizontal line time interval from sync pulse to sync pulse see Figure 5 8 ACTIVE VIDEO LINES HORIZONTAL BLANKING ONE H
55. Handle is the handle to the frame grabber returned by AllocateFG Return Value Returns the current fine gain setting valid returns are 0 255 DW_E RROR on error Description The GetFineGain function returns the fine gain setting of the specified frame grabber Use SetFineGain to specify the fine gain e A fine gain of zero produces an image with no contrast e A fine gain of 128 is normal gain where the range from blanking level to white level is represented by a pixel value from zero to 255 e A fine gain of 255 is approximately twice normal contrast This function will not return until all queued operations have completed See Also SetFineGain GetGainRange SetGainRange 9 12 PXR800 API Functions Chapter 9 GetGainRange DWORD GetGainRange FGHANDLE fgHandle PXRVB GetGainRange ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value Returns the current gain range valid returns are 0 1 DW_ERROR on error Description The GetGainRange function returns the fine gain setting of the specified frame grabber Use SetGainRange to specify the gain e Ifthe gain range is zero the input video is assumed to be normal 1 Volt peak to peak e Ifthe gain range is one the input video is amplified by a factor of two before being digitized This allows full grayscale accuracy for signals of approximately 1 2 Volt peak to peak This function wi
56. IWidth is the width of the ROI valid range 4 2044 must be a multiple of 4 dwROIHeight is the height of the ROI valid range 1 2047 iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the Frame Grabber queue so it will be completed later Return Value Return is a handle to a queued request QI_ INVALID on failure Continued on the following page 9 65 Chapter 9 PXR800 API Functions SetROI continued Description The SetROT function sets the dimensions of the ROI and its position within the valid video If the rectangle requested extends outside the valid video area specified by SetVideoFrameSize the ROI will be set to a rectangle that fits in the valid video area When setting both ROI and video frame size be sure to perform SetVideoFrameSize first This will invalidate any images stored in the PXR800 buffer memory See Also GetROI SetVideoFrameSize GetVideoFrameSize Table 9 3 on page 9 11 9 66 PXR800 API Functions Chapter 9 SetRTCTiming QUEUEID SetRTCTiming FGHANDLE fgHandle REALTIME prtRealTime DWORD dwMask IMG WHEN iwWhen PXRVB SetRTCTiming ByVal fgHandle As Long ByRef prtRealTime As RealTime ByVal dwMask As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG prtRealTime is the address of a real time structure that provides
57. Imagenation PXR800 Frame Grabber User s Guide CYBEROPTICS O SEMICONDUCTOR ii General Information Every effort has been made to make this manual a comprehensive technical resource for the Imagenation PXR800 Frame Grabber Please take a few min utes to review the Table of Contents and thoroughly read Chapter 1 Introduction on page 1 1 If you experience any difficulties or have any questions please read the appropriate sections within this manual If you continue to have difficulties or questions please contact us via e mail or telephone Technical support is available Monday through Friday 8 00am to 5 00pm Pacific Time E mail CSsupport cyberoptics com Phone 503 495 2200 800 366 9131 US and Canada only Fax 503 495 2201 Check the Imagenation product website http www imagenation com for the most current version of this manual and for software updates Third party brands and names are the property of their respective owners Copyright 2001 2003 CyberOptics Semiconductor Inc All rights reserved CyberOptics Semiconductor Inc P O Box 276 Beaverton OR 97075 0276 P N MN 800 03 Table of Contents Table of Contents General Information esccssoesseesceesoecseessececeessoes ll Chapter 1 DOU CU OI E E A E T TA 1 1 Video and Machine Vision Systems cccccsssscecceessseeee 1 1 PXR800 Features for Machine Vision ccccccccsssseeeeee 1 4 O
58. NE after each call e ResetFG will also reset the error condition to PXR800_ERROR_NONE Description Returns immediately Error Codes Description PXR800 ERROR_NONE No error has occurred PXR800 ERROR INVALID PARAM One or more parameters passed to an ETER API function had invalid values PXR800 ERROR QUEUE FULL Too many queued operations are cur rently waiting to execute PXR800 ERROR SYSTEM ERROR Windows was unable to complete an I O operation Most likely this is caused by the system running low on memory or other system resources PXR800 ERROR INVALID FGHAN A fgHandle that doesn t refer to a DLE frame grabber owned by this process was used PXR800_ERROR_TIMEOUT TimedWaitFinished has returned because it s maximum time expired Table 9 1 Error Codes See Also ResetFG 9 5 Chapter 9 PXR800 API Functions 9 6 FreeFG void FreeFG FGHANDLE fgHand1le PXRVB FreeFG ByVal fgHandle As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value None Description The FreeFG function releases control of the frame grabber The fgHandle must have been provided by a call to AllocateFG Do not use fgHandle once FreeFG has been called Any pending operations such as queued grabs and real time sequences are cancelled by FreeF6G as if ResetFG had been called See Also AllocateFG ResetFG PXR800 API Functions Chapter 9 GetCamer
59. NVALID on failure Description The RTCStart function describes when the RTC sequences are to start and how often they are to be repeated All of the RTC lines start from a single event e With ES NOW the events can be started at once e With RP_STOP the real time control will stop at the end of the current sequence requires ES_OFF e If ES NOW is combined with RP_CONTINUOUS the RTC sequence repeats continuously with one HalfH period of delay between when the sequence ends and when it restarts e Use ResetRTC to abort a sequence before it is completed If the camera provides progressive scan images SetInterlaceMode the fields will always be considered even fields See also GetRTCTiming GetRTCStart ResetRTC SetRTCTiming 9 50 PXR800 API Functions Chapter 9 SetCamera QUEUEID SetCamera FGHANDLE fgHandle IMG CAMERA icCamera IMG WHEN iwWhen PXRVB SetCamera ByVal fgHandle As Long ByVal icCamera ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG icCamera is one of the cameras e CAMERAO e CAMERAL1 e CAMERA e CAMERA3 iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI_ INVALID on failure Continued on the following page 9 51 Chap
60. ORIZONTAL TIME INTERVAL H H 63 5ys for RS 170A H 64 0 us for CCIR PAL Many PXR800 timing functions are based on HalfH which is defined as half of the horizontal line interval H The actual time value for H and thus HalfH depends on the video standard of the image being captured Figure 5 8 HalfH Timing Function The image source camera can also be switched automatically by a triggered Grab Grabs can only switch to the camera matching the trigger If both Grab and SetRTCTiming specify a switch both switches will occur The order of the switching depends on the delay values specified for the switching events Sync Control and Sync Modes The PXR800 has a single video synchronization system that always generates line and frame timing for the other blocks shown in Figure 5 7 Depending on the SetSyncMode and SetDriveMode settings the PXR800 synchro nizes to the currently selected incoming video or it can generate its own tim ing internally The PXR800 can maintain a different sync mode for each attached camera As a result the behavior of Syne Control can change when ever camera selection changes Timing generated by Sync Control is used to digitize the video signal to pro duce the HalfH clock for the Pulse Generators and to synthesize vertical and horizontal drive signals H amp V Drive x4 in Figure 5 7 H in HalfH is the incoming video signal s horizontal line interval horizontal sync plus video line The v
61. The offset is digitally added to the pixel data before fine gain is applied An offset of zero makes the video blanking level roughly a zero pixel value See Also GetOffset SetFineGain GetFineGain 9 62 PXR800 API Functions Chapter 9 SetPixelClock QUEUEID SetPixelClock FGHANDLE fgHandle IMG PIXEL CLOCK pcClock IMG WHEN iwWhen PXRVB SetPixelClock ByVal fgHandle As Long ByVal pcClock As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG pcClock is the current pixel clock e PCLOCK CCIR SQUARE e PCLOCK NTSC SQUARE e PCLOCK CCIR RECTANGLE e PCLOCK NTSC RECTANGLE e PCLOCK EXT INVERTED e PCLOCK EXT See Table 9 8 on page 9 64 iwWhen describes when this function should occur IW WAIT wait for all other queued requests to complete IW _QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI_ INVALID on failure Description The SetPixel1Clock function sets the pixel clock of the specified frame grabber This will invalidate any images stored in the PXR800 buffer memory Continued on the following page 9 63 Chapter 9 PXR800 API Functions SetPixelClock continued Default Default Pixel Clock Name Frequency Line Width Field Length PCLOCK_NTSC_SQUARE 12 2727MHz 780 Clocks 262 1 2 or 525 lines PCLOCK_ CCIR_SQUARE 14 75 MHz 944 Clocks 312 1
62. This will cause the PXR800 to capture one image and skip the next two each time the algorithm runs The result will be a steady image capture rate of ten frames per second An advantage of the above approach is that the Wait function allows the application to explicitly skip one or more images from the current camera without relying on tuned time delays Wait will qualify an image exactly the same as a Grab would with the same settings Then instead of transferring the image to system memory Wait pauses the queue for the duration of the image so that image data is not saved While Wait does cause the PXR800 queue to wait until the end of the image this doesn t necessarily mean that the application will wait Whether or not the application waits depends on whether Wait is called by IW_QUEUED or IW WAIT Detailed Operating Information Chapter 5 If IW_QUEUED is used the queue pauses until one image has passed but the application keeps running In this case IsFinished can be used to see if the PXR800 is done skipping the image If IW_WATIT is used Wait returns at the end of the image being skipped The application program is stopped until the image being waited for is complete Captured Images As an image is captured by the PXR800 it is sent over the PCI bus for storage in system memory Your application program can then retrieve the image from system memory for archiving analysis display or any other desired opera tion Ima
63. a IMG CAMERA GetCamera FGHANDLE fgHandle PXRVB GetCamera ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value The return value is the currently selected camera CAMERAO CAMERA1 CAMERA2 CAMERA3 CAMERA INVALID on failure Description The GetCamera function returns the currently active camera input of the specified frame grabber The current camera input can be changed with SetCamera Grab and SetRTCTiming GetCamera does not return until all queued operations have completed See Also SetCamera Grab SetRTCTiming 9 7 Chapter 9 PXR800 API Functions GetContinuousBuffering IMG BUFFERING GetContinuousBuffering FGHANDLE fgHandle PXRVB GetContinuousBuffering ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value The return value is the current image buffering method e BU SINGLE e BU CONTINUOUS e BU INVALID on error Description The GetContinuousBuffering function returns the current buffering method The buffering method can be changed with SetContinuousBuffering Returns immediately See Also SetContinuousBuffering BlockGrabber InvalidateGrabberBuffer 9 8 GetDriveMode PXR800 API Functions Chapter 9 IMG DRIVEMODE GetDriveMode FGHANDLE fgHandle PXRVB GetDriveMode ByVal fgHandle As Long As Long Parameters fgHandle is the handle to
64. a s exposure cycle The application requires that the camera expose an image ten scan line times after the frame grabber receives a trigger with an exposure time of ten scan lines The signal timing for this system would look something like that shown in Figure 5 10 Trig BR lt NO TRIGGERS ACCEPTED gt lt ___ __ gt 200 HSyncs 10 HSyncs gt 10HSyncs Figure 5 10 Signal Timing Example The requirement that the camera not be reset for the first 200 lines can be met by making sure that the exposure pulse sequences end with a pulse segment of inactive polarity that is long enough to make sure the length of the entire sequence is 200 lines In this case Exp1 would be programmed with three segments e an inactive segment of length ten lines e an active segment for the pulse e another inactive segment representing the remainder of the 200 lines The pulse generator will not abandon a sequence in progress if a new trigger comes in so the length of the sequence acts as a hold off period for trigger detection The following code could be used to program this exposure sequence Note that the time values are twice the line counts because they are measured in HalfH periods Detailed Operating Information Chapter 5 SetExp FGHANDLE fgHandle REALTIME rt memset amp rt 0 sizeof rt it Bp RY RES tT PXR SetRTCTiming fgHandle amp rt rt pExposures RTC_EXP1 plStartLevel PULSE LOW
65. a from the PXR800 buffer memory to the system memory Grab operations are removed from the queue only when the System End finishes transferring image data to the system memory Thus the queue is somewhat synchronized to the System End The System End is also loosely synchronized to the video How loosely it is synchronized depends on the data transfer mode of the PXR800 Two data transfer modes available to the System End for moving data from the PXR800 buffer memory to system memory incremental mode and burst mode They are selected with SetTransferMode In incremental mode when a Grab occurs the System End moves data from PXR800 buffer memory as soon as possible Typically in incremental mode Grab completes within a few microseconds of the last data for the image arriving from the camera However if the PCI bus or system memory is busy with other tasks Grab completion might be delayed because the PXR800 will not be able to move data into system memory fast enough In burst mode the System End doesn t begin to transfer the data for a Grab until the entire image is captured into PXR800 buffer memory After the entire image is captured data is transferred as rapidly as possible to system memory In burst mode Grab typically completes a few milliseconds after the last image data arrives from the camera For most continuous video cameras the time for Grab completion is somewhat after the start of image data for the next frame Detail
66. age data on a line The exact value might depend on whether Nyquist filtering is enabled and might also differ slightly between camera models of the same video format For progressive scan cameras dwTopOffset is the number of lines between vertical sync and the first line of real image data In interlaced systems dwTopOffset is the total number of lines from both fields between vertical sync and real image data Adjusting the top offset value by one line causes a line to be added to or removed from vertical blanking for either the even or odd field This allows control of the start of valid data down to a single line of the frame even though the frame is composed of two fields ROI Details SetROI defines the dimensions for the ROI and sets the position of the ROI box within the valid video If SetVideoFrameSize hasn t been used prior to SetROI valid video is the normal region of active video as defined by automatic syncing of the PXR800 to the incoming video signal If you want to define the valid video region using SetVideoFrameSize you should do so prior to using SetROT To set the ROI box size use the SetROT height and width parameters dwROTHeight and dwROIWidth The value for ROI height is in lines and can range from 1 to 2047 ROI width is in pixels and must be an integer multi ple of 4 in the range of 4 to 2044 The ROI box position is set by top and left parameters dwROTTop and dwROILeft Valid top and left values are 0 to 20
67. al synchronization pulses are provided at the end of each field in interlaced systems and at the end of each frame in pro gressive scan systems Details of this are shown in Figure 5 3 ACTIVE VIDEO START ODD FIELD ac LINE 21 FIRST 20 FIELD lt INES BLANKED HORIZONTAL VERTICAL BLANKING SYNC PULSE amp SYNC INFORMATION th LINE th LINE J END ODD FIELD lt START EVEN FIELD VIDEO SIGNAL DIAGRAMS NOT TO SCALE Video signal diagrams showing relationships of the odd field top to the even field bottom in RS170 interlaced video format CCIR relationships are similar but with different timing and line counts These are not drawn to scale Figure 5 3 Video Signal Diagrams The video signal is a continuous stream of active video horizontal sync and vertical blanking Figure 5 3 shows two segments of the stream aligned to depict relationships between the two fields of a video frame Notice in the top portion of Figure 5 3 that the odd field starts just after a full line of active video and the field progresses immediately with a vertical blanking interval This vertical blanking interval blanks out the first 20 field lines in an RS 170A system thus the first active line in the odd field is line 21 Active lines continue in the odd field with each line separated by a horizontal blanking region containing a horizontal sync pulse Detailed Operating Information Chapter 5 Notice in the bottom portion of Figure 5 3 that t
68. all the short term total error in the video data is less than 0 5 LSB at a fine gain of 128 and gain range of zero including all noise and nonlinearity but not including quantization error LUT Look Up Table The PXR800 contains a 256 x 8 LUT whose values can be set either by soft ware or to a set of default values Depending on the values loaded into the LUT various video signal pixel translations can be performed by the LUT Per forming gamma correction or adjusting contrast are some of the possible uses for the LUT LUT manipulations being a hardware function generally occur much faster than trying to accomplish the same result with an application pro gram Briefly the LUT works as follows After a pixel is digitized it is represented by a numerical value for the brightness of the pixel s location in the image The LUT uses the pixel s value as an index into a table to locate a new value that is assigned to the pixel before it is stored Basically the LUT is an 8 bit to 8 bit mapping function that applies to all pixels in the image An analysis technique called thresholding is a typical usage for the LUT Sup pose for example you have an image consisting of lighter objects on a dark background An application program would have an easier job locating the objects if all of the background had a numerical value of zero Then locating objects would simply be a matter of searching for non zero pixels To accom Detailed Operati
69. alue of H varies depending on the video format with H 63 5 psec for RS 170A and H 64 usec for CCIR PAL see Figure 5 8 5 19 Chapter 5 Detailed Operating Information 5 20 The H and V drive signals see Figure 5 7 on page 5 18 share wires in the camera cable with the H and V sync from the camera SetDriveMode deter mines whether these wires represent sync coming from the camera or drive signals to the camera from the PXR800 The synchronization modes that can be encountered are composite sync in video vertical sync and or horizontal sync on an external line and composite sync on an external line These modes are described in more detail below and in Table 5 2 on page 5 21 Composite Sync in Video The synchronization information is embedded in the video signal s horizontal and vertical blanking intervals In SetSyncMode SYNC_HC_VC selects this mode Vertical Sync on External Line Horizontal sync information is embedded in the incoming video signal and vertical sync is transmitted from the camera to the PXR800 on the Vsync Vdrive wire The vertical sync signal can be a standard vertical sync waveform or it can be another pulse such as WEN WEN is a very short pulse that marks a specific line in the vertical blanking interval Typically WEN works only for progressive scan or single field operation In SetSyncMode SYNC_HC_VS selects this mode Vertical and Horizontal Sync on External Lines The camera transmits vertical sync
70. ame Frequency Line Width Length PCLOCK_NTSC_SQUARE 12 2727MHz 780 Clocks 262 1 2 or 525 lines PCLOCK_CCIR_SQUARE 14 75 MHz 944 Clocks 312 1 2 or 625 lines PCLOCK_NTSC_RECTANGLE 13 5 MHz 858 Clocks 262 1 2 or 525 lines PCLOCK CCIR RECTANGLE 13 5 MHz 864 Clocks 312 1 2 or 625 lines synced to rising None None iia i edge of PCL PCLOCK EXT INVERTED synced to fall None None ing edge of PCL 5 22 Table 5 3 SetPixelClock Timing Information In Table 5 3 the default line width and default field length are used when the synchronization mode is DRIVE_HD_ VD see SetDriveMode In this mode the timing of horizontal and vertical drive pulses is based on the pixel clock setting The shorter field length is used in interlaced mode and the longer length is used in progressive mode see SetInterlaceMode The external pixel clock and vertical and horizontal drive cannot be used together so there is no default width or length in the modes that use an external pixel clock Detailed Operating Information Chapter 5 Image Grabs The Image Qualifier determines which images can be grabbed and turned into digitized video This in turn is determined by the application program which can ask for acquisition of a particular field or frame Additionally the application can further qualify grabs based on triggers or events The following image types can be acquired Next field progressive or interlace Next even field Ne
71. ameType PXRFRAME pFrame FRAMEVB FrameType ByVal pFrame As Long As Long Parameters pFrame is the address of a PXRFrame Return Value A code representing the pixel type of the image zero if failure Description The FrameType function returns the pixel type of the frame e PB ITS Y8 monochrome 8bpp image e PBITS RGB16 16 bpp color image e PBITS RGB24 24 bpp color image e PBITS RGB32 32 bpp color image PXRFrame API Functions Chapter 10 FrameWidth DWORD FrameWidth PXRFRAME pFrame FRAMEVB FrameWidth ByVal pFrame As Long As Long Parameters pFrame is the address of a PXRFrame Return Value The number of pixels in a line zero if failure Description The FrameWidth function returns the width in pixels of the frame This value might be less than was stated by AllocateBuffer or FrameFromPointer because the width is always rounded down to a multi ple of four pixels 10 13 Chapter 10 PXRFrame API Functions FreeFrame void FreeFrame PXRFRAME pFrame FRAMEVB FreeFrame ByVal pFrame As Long Parameters pFrame is the address of a PXRFrame Return Value None Description The FreeFrame function releases the memory used by the PXRFrame This frame could have been created by either AllocateBuffer or FrameFromPointer Once the frame is freed the application should not refer to it again Other wise a system error can occur It is recommended that KillQueue be cal
72. amera Extender Board If you need to use more than two cameras with the PXR800 you will need the Camera Extender Board This device plugs into the PXR800 and provides two additional 26 pin connectors for attaching up to two additional cameras The PXR801 Camera Extender Board is available as an option from Imagenation Camera Cables You will need a cable to connect a camera to the PXR800 Imagenation pro vides a few styles of cables that can be used to connect many cameras In some cases you may wish to design your own cable For PXR800 connector pin assignments and cable design advice see Cables and Connectors on page 6 4 Installing the PXR800 Chapter 2 Uninstalling the PXR800 Uninstalling the Development Software If you have installed the development software SDK samples or documen tation using the PXR800 Installation Disk they can be uninstalled using the Add Remove Programs control panel applet Run Add Remove Programs select Imagenation PXR800 and select Add Remove The Setup program will run in maintenance mode giving you the option of modifying repairing or uninstalling the PXR800 files Note If you have changed or added any files in the PXR800 directories those directories may not be removed completely This will happen if you have changed or rebuilt the sample code in place or created a Visual C project in any of these directories If any of the directories are not removed by an uninstall and you ar
73. an be set to specific values by using WritelO and their state can be read with ReadIO Changes made to the output lines with WriteIO can take effect immediately or the changes can be synchronized to the queue However output line changes cannot be synchronized with RTC events The GPI O lines are intended for use in communicating with other hardware when signal timing isn t critical They can also be used to manage camera con trol tasks where the camera settings don t need to be changed very often Data Flow 5 28 Figure 5 11 on page 5 29 provides an overview of data flow in the PXR800 This includes setup control and IO paths Note that the PCI bus provides interfacing to the computer system and that the Application and System Mem ory blocks reside in the computer system in which the PXR800 is installed Camera End and System End The PXR800 can be thought of as having two functional segments each with separate timing These segments are the Camera End and the System End Both are loosely tied together by the PXR800 memory buffer The attributes and relationships of these two segments are described below The Camera End RTC and decisions about which video images qualify for capture happen at the Camera End Throughout the Camera End tries to stay exactly synchronized with the timing of the currently selected camera When image qualification occurs the Camera End writes video data into PXR800 memory as the video data is capt
74. andard 8 bit data Detailed Operating Information Chapter 5 255 255 m MAA NEN w Z a a a D D AAA AAAA A o O 0 0 a ORIGINAL SIGNAL b NEGATIVE OFFSET 255 F 2 0 0 c FINE GAIN ADJUSTED Offset and Fine Gain can be used to improve grayscale resolution as shown here where the original signal a is given negative offset b and then fine gain adjusted c so that it covers most of the available grayscale Figure 5 6 Offset and Fine Gain 5 15 Chapter 5 Detailed Operating Information 5 16 The gain and fine gain adjustments interact differently with the offset adjust ment because of the order in which they are applied gain first then offset and then fine gain The effect of offset is multiplied by fine gain but not by gain This is apparent from the following equation for gain and offset as applied by the PXR800 Pour R Pin O G 128 Where Pout the signal data after all gain and offset adjustment Pj the analog signal prior to gain adjustment R gain range 1 or 2 O offset 128 to 127 G fine gain 0 to 255 Noise amplitude scales linearly with fine gain It is 0 5 LSB when fine gain is set to 128 and gain range is zero x 1 amplification Also the linearity of grayscale values is best when fine gain is 128 Other values of fine gain can add nonlinearity of up to 0 5 LSB in addition to the 0 5 LSB of quantizing error resulting from 8 bit digitizing Over
75. are the gen eral purpose outputs the other four bits are zero Continues on the following page 7 3 Chapter 7 PXR800 API Structures IMG_IMAGEINFO Structure continued Members continued bPack0O bPackl bPack2 unused padding These values are always zero wValidLinesFirstField number of lines captured in the first field to arrive from the camera wValidLinesSecondField number of lines captured in the second field to arrive from the camera or zero if only one field was captured dwQualifyCount the number of fields that have been accepted for capture by the RTC since the last time the frame grabber was reset pbDebug 32 unused Description The IMG_IMAGEINFO structure contains information about when and how an image was acquired including timecode data The IMG_IMAGEINFOTIMING structure is a subset of IMG_IMAGEINFO containing timecode information The full IMG_IMAGEINFO structure is attached to an image if space for the data was included when the destination frame was allocated The IMG _IMAGEINFOTIMING subset can also be read from the frame grabber directly without attaching it to any particular image This data is attached to any image that was allocated using the bImageInfo flag to the AllocateBuffer function The data is placed in the image buffer immediately following the pixel data at offset height pitch 7 4 PXR800 API Structures Chapter 7 REALTIME Structure IMG EXPSEQ typedef struct IMG
76. begins streaming into the buffer beginning with the first full image after the trigger Two Grab commands can be used to capture two successive images How ever this can occur only if the second Grab command executes during the vertical blanking interval following the first image Grab This can be done reliably by queuing the Grab commands ahead of time The same thing can be done without queuing if the application program can start the second grab very quickly 5 29 Chapter 5 Detailed Operating Information 5 30 In continuous buffering the Camera End captures all qualified images into the PXR800 buffer memory This occurs whether a Grab has occurred or not Because image data is already being captured into the PXR800 buffer memory a Grab can be issued some time after the start of image data and the com plete image will be captured This ability to issue a Grab up to and well past mid image offers significantly more flexibility in application programming Complete images can still be cap tured even when the Grab doesn t get issued until well after the start of the image As a result the queued Grab operations necessary in single buffering are typically not needed in the continuous buffering mode However you do need to keep in mind the data coherency issues that might occur in the buffer during continuous buffering see Coherency Issues on page 5 37 The System End During an image capture the System End transfers dat
77. cccssssecccesssecceesceees 3 1 The Library Interface sscssscccceecccccsssssssscceeeeecceeeeeeees 3 1 Handles and ID Values sicssssssssssssssncsscasnsecasssascinvesssecasesssasexenes 3 2 Programming Language Specifics ssooossseesssssoocesesssssse 3 4 Programing in Casasin ian AA ee E E E 3 4 Programming in Visual Basic rererere 3 5 Writing Multithreaded ProgramS 0000000000000000000000000000 3 7 A Simple Image Capture Program sssssceeeeessssseeeeees 3 8 Line by Line Explanation eseserseerrreererrrerirrrsererrers 3 10 Compiling the Program cscstrecdsanincatacsienieussun stcasineitenseetaotints 3 13 Running the Program sss ssssssssssseisserstressrrtrserreressrrrrrsrrrern 3 13 Camera Detection and Configuration sseeseeeeeeeeeeeeeeee 3 14 Handling Stalled Grabs ccccccssssccccccsssseccccssscecceeees 3 17 Doing Triggered Grab and Display ssssseeeeeeeeeeees 3 18 Chapter 4 The PAR Produciivity TG ccsssccecctsseccspstsnccccsrerepocesdoncnenrceneses 4 1 Installing the PXR Productivity Tool ccccccssssssseeeees 4 1 Benefits of Using the PXR Productivity Tool 6 4 2 PXR Productivity Tool Architecture cccccccssssssseeeees 4 2 Dia log Box Design ae enter arnt ree ree ie eer ee et ree 4 2 Diallo Box RUES an E en tae 4 3 Saving PXR800 Configurations with the PXR Productivity Koo EAE T E E 4 5 Saving The Cu
78. cepts a millisecond timeout value If the operation being waited on does not finish within the requested number of milliseconds TimedWaitFinished will return and allow the program to take additional action An example of how a Grab with timeout can be writ ten is as follows BOOL SafeGrab FGHANDLE fgHandle PXRFRAME pFrame DWORD dwMs QUE U AND Galle qid PXR Grab fgHandle pFrame 0 GE_ON VSYNC FALSE SV_EITHER FIELD FL FRAME IW_QUEUED if qid QI INVALID return FALSE if PXR TimedWaitFinished fgHandle qid dwMs 1 PXR KillQueue fgHandle return FALSE return TRUE This function takes a frame grabber handle a PXRFrame and a timeout as parameters If the Grab is successful it returns TRUE If the Grab fails for any reason including stalling for more than the requested time it returns FALSE The Grab function has several parameters relating to triggers and timing which are set to reasonable values for a simple image capture For applica tions that need specific triggering and synchronization these parameters can be changed If the Grab stalls TimedWaitFinished will return zero At this point the stalled Grab is still in the queue and must be removed The KillQueue function accomplishes this by removing all currently queued operations including the stalled Grab 3 17 Chapter 3 Programming the PXR800 Doing Trigg
79. cified by SetSyncMode DRIVE_HD VD The frame grabber will generate drive signals on the HS and VS wires The timing of the drive signals depends on the camera format set by SetPixelClock and SetInterlaceMode DRIVE_HD_VEXPO The frame grabber will generate drive signals on the HS and VS wires The timing of horizontal drive depends of the camera format selected by SetPixelClock but the vertical timing is controlled by the RTC using the Exp0 pulse generator DRIVE_INVALID See Also GetDriveMode Se GetSyncPolarity SetRTCTiming On error Table 9 7 Drive Mode Names tSyncMode GetSyncMode SetSyncPolarity SetPixelClock SetInterlaceMode 9 55 Chapter 9 PXR800 API Functions SetFineGain QUEUEID SetFineGain FGHANDLE fgHandle DWORD dwGain IMG WHEN iwWhen PXRVB SetFineGain ByVal fgHandle As Long 7 ByVal dwGain As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwGain sets the fine gain setting valid range 0 255 iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI INVALID on failure Description The fine gain value of the SetFineGain function is a linear scaling factor e A fine gain of zero produces an image
80. clude the cor rect BAS files in your project For ease and simplicity the sample programs always include all five BAS files Table 3 1 shows the relationship between the BAS files and their respective DLLs Related BAS Files PXR800 DLL PXR800API BAS PXR800 BAS IMAGEINFO BAS needed only if you are referenc ing the date time structure PXRFRAME BAS IMAGEINFO BAS needed only if you are referenc ing the date time structure PXR800_Display DLL PXR800_Display BAS Table 3 1 Relationship of DLLs and BAS Files 3 6 Programming the PXR800 Chapter 3 Table 3 2 identifies the contents of each BAS header file Description PXR800API BAS Data structures and definitions for PXR800 API calls PXR800 BAS Definition of constants PXRFRAME BAS Data structures and definitions for Frame Library calls IMAGEINFO BAS Two data structures for using the date and time information PXR800_Display BAS Two definitions for the video display calls Table 3 2 BAS Files for Visual Basic Accessing frame data Visual Basic doesn t use pointers so you must use the functions GetPixel GetColumn GetRectangle and GetRow to access the data in a frame Visual Basic includes a Byte type which is equivalent to the unsigned char type that the DLLs expect for buffers To pass a buffer to the DLL just pass the first element of your declared Byte array by providing element 0 or element 0 0 For example to get a
81. ction returns the current time of the grabber Due to latency issues the time to communicate with the board and get information from it the time returned might have changed from when the request was made The time and other timing values can be changed with SetTime Returns immediately The time data will also be returned as part of the auxiliary data stored in a PXRFRAME during a Grab if the frame was allocated with space for the data See Also SetTime AllocateBuffer IMG_IMAGEINFO Structure on page 7 2 9 31 Chapter 9 PXR800 API Functions GetTransferMode IMG TMODE GetTransferMode FGHANDLE fgHandle PXRVB GetTransferMode ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value Return is the selected transfer mode e TMODE INCREMENTAL e TMODE BURST e TMODE INVALID on error Description The GetTransferMode function returns the transfer mode used to transfer images In TMODE_INCREMENTAL mode the video data from the onboard video buffer is transferred to system memory as soon as the data is received Thus it is likely that target system memory will have all the video data before the cur rent video frame ends In TMODE_ BURST mode video data is transferred to system memory in a short burst after the end of the video frame Thus the data will not be available until a few milliseconds after the current video frame ends Returns immediately S
82. curate too because it supplies only six bits of real resolution per pixel Still if your appli cation requires RGB image data capturing directly to an RGB frame will be faster than using software to translate from 8 bit to RGB Image Information A PXRFrame can be allocated with extra space for holding additional image information such as a time stamp This is done by setting the bImageInfo flag in AllocateBuffer When an image is grabbed to a PXRFrame with the extra image information space data about the captured image is automatically recorded in the PXRFrame This additional data is stored in the IMG_IMAGEINFO structure and can be retrieved using GetTimeStamp from the PXRFrame library Detailed Operating Information Chapter 5 The additional image information stored in IMG_IMAGEINFO includes e Image time stamp e Count of total number of fields received e Number of fields received per second e Number of lines captured in each field e Starting field of the image e Which camera the image came from e Which trigger caused image capture e The state of all I O lines at the time of image capture The time stamp information is in hours minutes seconds and hundredth of seconds It is the time at which the image was grabbed and the time values are from the PXR800 clock which is not synchronized to the video Note The time in the PXR800 clock is cleared whenever power is lost or the system is powered down If the application
83. d See Also IMG_IMAGEINFO Structure on page 7 2 Grab 10 20 PXRFrame API Functions Chapter 10 PutColumn DWORD PutColumn void pvBuf PXRFRAME pFrame DWORD dwColumn FRAMEVB PutColumn ByRef pvBuf As Any ByVal pFrame As Long ByVal dwColumn As Long As Long Parameters pvBuffer is the address of the source buffer pFrame is the address of a PXRFrame dwColumn is the column number of the frame to which to copy the pixels Return Value The return is non zero on success zero if failure Description The PutColumn function copies a column of data into the PXRFrame The columns are numbered starting with zero at the left of the frame The buffer is assumed to be an array of the correct type to hold the column of pixels If buffer does not contain enough data undefined behavior and data corruption might result The function will fail if the specified column is outside the boundaries of the frame or if the frame can t be read 10 21 Chapter 10 PXRFrame API Functions PutPixel DWORD PutPixel void pvPixel PXRFRAME pFrame DWORD dwColumn DWORD dwRow FRAMEVB PutPixel ByRef pvPixel As Any ByVal pFrame As Long ByVal dwColumn As Long ByVal dwRow As Long As Long Parameters pvPixel is the address of the pixel to be copied pFrame is the address of a PXRFrame dwColumn is the column number of the frame into which to copy the pixel dwRow is the row number of the frame into which t
84. d programming techniques to synchronize image acquisition and board configu ration with program execution The event handle should not be closed by this application See Also TimedWaitFinished WaitFinished IsFinished 9 83 Chapter 9 PXR800 API Functions WritelO QUEUEID WriteIO FGHANDLE fgHandle DWORD dwData DWORD dwMask IMG WHEN2 iwWhen PXRVB WritelIO ByVal fgHandle As Long ByVal dwData As Long ByVal dwMask As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwData is the state of the bits 3 0 to be changed dwMask is the mask of which bits 3 0 to change iwWhen describes when this function should occur e IW2 WAIT wait for all other queued requests to complete e IW2 NOW write the I O lines immediately asynchronous to queued operations e IW2 QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI _ INVALID on failure Description The WriteTIo function changes the state of the general purpose output lines The dwMask identifies which output lines to change e If bit 0 is set the state of output line zero will change The same is true through bit 3 and output line 3 e If the bit in the dwMask is not set the state of the line will not be changed If a bit is to change it will take on the value of the corresponding bit in dwData Contin
85. d valid image data This number depends on the pixel clock frequency as well as on the camera s horizontal blank timing The best value for this parameter is likely to vary by a few pixels between camera models and might also vary somewhat because of analog effects such as delay in the Nyquist filter and other filtering that occurs in the cable E The PXR800 captures full video lines The half lines at the top and bottom of fields are therefore captured as half black lines and half active video These numbers exclude the half lines from the video frame Table 5 1 Camera Formats 5 6 Detailed Operating Information Chapter 5 The Pixel Clock Field or frame grabs are done on a line by line basis Each line is sampled at regular time intervals based on a pixel clock and the samples are digitized to 8 bits which corresponds to 256 levels of gray One of two pixel clock sources can be selected under software control The clock source can be from the camera if the camera provides a pixel clock out put Or the clock source can be the crystal controlled pixel clock internal to the PXR800 If the camera used as the video source does not have a pixel clock output the PXR800 pixel clock must be used The recommended software selectable sampling frequencies are e RS 170A standard 12 2727 MHz e CCIRG6O1 digital video 13 5 MHz e CCIR monochrome 14 75 MHz These sample rates will maintain the frame aspect ratio of the video source
86. designed to help you become a more produc tive software developer faster It reduces your learning curve by letting you investigate the API through dialog boxes rather than source code It shortens the edit compile run sequence to click and watch The best way to learn to use the Productivity Tool is to use it The only items you need are a PXR800 a camera and a cable The tool is intuitive and can be learned quickly and easily This chapter presents the following concepts and proce dures for using the PXR Productivity Tool e Installing the PXR Productivity Tool e The benefits of using the PXR Productivity Tool e What the PXR Productivity Tool can and cannot do to support your programming efforts e How to interpret and use the feedback generated by the windows and other controls e How to save and load a PXR800 frame grabber configuration Installing the PXR Productivity Tool The PXR Productivity Tool was developed and released after the first ship ments of the PXR800 so it might not be available on the product CD you orig inally received You can download the PXR Productivity Tool along with updated drivers samples and documentation from the Imagenation website www imagenation com The self extracting executable from the website does not create a Start menu shortcut for the application for easy retrieval make sure you place the PXR Productivity Tool in the same directory where you installed the rest of the PXR80
87. dules the threads This will result in an image that may be either the old size or the new size Individual operations will be exe cuted in the order they are received by the frame grabber library independent of which thread requested the operation A Simple Image Capture Program 3 8 The program on the following page grabs an image using the PXR800 frame grabber and saves the image as a BMP file This program is extremely simple and does only the minimum initialization necessary to use the frame grabber By default the frame grabber is set up to work with interlaced RS 170 cam eras so this program works best with an RS 170 or NTSC camera Me wo 3 ep Wn ss Tey hoy a Gl Co ky i e amp 21 22 23 24 25 26 Zl 28 29 30 Syl 32 33 34 35 36 include lt windows h gt include pxr800api include pxrframe h PXRFRAMELIB FrameLib PXRAPI PXR FGHANDLE hFG PXRFRAME pFrame N int WINAPI WinMain char Programming the PXR800 Chapter 3 h r UDDA HINSTANCE hInstance HINSTANCE hPrevInstance szCmdLine int iCmdShow T Error checking has been removed for clarity A real program should check the return codes for all of these functions and respond to errors imagenation OpenLibrary pxr800 d11 amp PXR imagenation OpenLibrary pxrframe dll amp Fr pFrame FrameLib AllocateBuffer 640 640 hFG PXR AllocateFG GR NEXT AVAILABLE
88. e 128 to 127 with a default value of zero for no offset The programmed offset value is dig itally added to the pixel data prior to fine gain adjustment In essence SetOffset allows you to move the video signal around in the grayscale range similar to a brightness control This is particularly important if the camera you are using doesn t let you compensate for low or high lighting conditions It is also useful in situations where you need to adjust dynamically for changing conditions In such cases it is often easier and more economical to program the adjustments with the PXR800 rather than adding programma ble controls for the camera SetFineGain provides linear scaling of the digitized video signal The avail able range is zero to 255 Applying a value of zero produces an image with no contrast full black 128 produces normal contrast 100 gain and 255 pro duces an image of approximately twice normal contrast 200 gain Figure 5 6 on page 5 15 illustrates the effects of using the Offset and Fine Gain features together to enhance the dynamic range of video signals Fine gain is a digital multiplication that occurs after the video signal is digi tized and after any offset has been applied The multiply is a 10 bit operation This provides two extra lower bits of precision over the 8 bit signal data reso lution Because of the extra lower bits of resolution gains of more than 100 actually produce higher image precision than st
89. e associated with the video signal s vertical sync information orm CLOCK 0 3 VIDEO 0 3 H amp VSYNC 0 3 H amp VDRIVE x4 EXP1 2 x4 STROBE x4 TRIG 0 3 CAMERA SELECT CAMERA SetCamera SetRTCTiming Grab SELECT HalfH INTERNAL PULSE SYNC CONTROL CLOCK cate needa Expo GENERATORS 0 SetRTCTiming PIXEL CLOCK DIGITIZED Grab EVENT DETECT SetPixelClock VIDEO RTCStart Grab This is a Real Time Control Model for the PXR800 with key software commands indicated in various functional blocks Figure 5 9 Real Time Control Model The Event Detector block in the bottom right of Figure 5 9 detects pro cesses and routes events An event can be the beginning or end of vertical sync an external trigger or both together When an edge trigger and vertical sync are combined for an event the event happens at the vertical sync imme diately following the trigger edge Vertical sync events can be at the start or end of vertical sync Trigger events can be the rising edge falling edge trigger high or trigger low SetSyncMode SetSyncPolarity and SetRTCTiming allow you to con trol how sync events are defined RTCStart and Grab provide further con trol over how events triggers or event trigger combinations are detected and 5 24 Detailed Operating Information Chapter 5 used The RTCStart function selects what events can start pulse sequences and Grab selects which events will start a requested grab Note Any
90. e API Functions AllocateBuffer PXRFRAME AllocateBuffer DWORD dwWidth DWORD dwPitch DWORD dwHeight DWORD ptType BOOL bImagelInfo FRAMEVB AllocateBuffer ByVal dwwWidth As Long 7 ByVal dwPitch As Long ByVal dwHeight As Long ByVal ptType As Long ByVal bImageInfo As Boolean As Long Parameters dwWidth is the width of the image in pixels This must be a multiple of four pixels If it is not it will be rounded down to the nearest multiple of four pixels dwPitch is the width of the buffer in bytes This must be at least wide enough to hold the width of pixels or the frame object will not be created If dwPitch is zero the function will automatically compute the pitch value that matches the requested width dwHeight is the height of the image in rows ptType is the pixel type e PBITS Y8 e PBITS_ RGB16 e PBITS RGB24 e PBITS RGB32 bImageInfo is a flag to indicate whether space should be allocated to hold the time stamp data Continued on the following page 10 2 PXRFrame API Functions Chapter 10 AllocateBuffer continued Return Value A handle to a PXRFrame or NULL if failure Description The AllocateBuffer function creates a buffer into which images can be grabbed with the PXR800 library If bImageInfo is TRUE the buffer will be large enough to hold both the image and the time stamp information If FALSE the buffer will be large enough to hold only the image In the case o
91. e ES OFF RTC is not active Must be used with RP_STOP e ES NOW RTC will start immediately e ES ON _VSYNC RTC will start on the end of VSync e ES ON VSYNC_START RITC will start on the beginning of VSync e ES ON TRIGGER RTC will start on a trigger event e ES ON VSYNC_AFTER_ TRIGGER RTC will start on a trigger event that is followed by the end of Vsync e ES ON VSYNC_START AFTER TRIGGER RTC will start on a trigger event that is followed by the start of Vsync reRepeat is the code for how often to repeat the sequence e RP _SINGLE will fire the RTC sequence once e RP _CONTINUOUS RTC sequence will start whenever the event is detected e RP _STOP RTC sequence is not programmed to run Must be used with ES_OFF Continued on the following page 9 49 Chapter 9 PXR800 API Functions RTCStart continued Parameters continued svImageStart is the code to identify which field the RTC starts on e SV_EVEN_FIELD RTC only starts on an even field e SV_ODD_FIELD RTC only starts on an odd field e SV_EITHER FIELD RTC starts on either field iwWhen describes when this function should occur e IW2 WAIT wait for all other queued requests to complete e IW2 QUEUED add to the frame grabber queue so it will be completed later e IW2 NOW perform the operation immediately before any other operation in the queue Return Value Return is a handle to a queued request QID_ I
92. e PCI slot and seat it firmly Secure the PXR800 with the screw you saved 4 Attach a power connector from the computer s power supply to the Camera Power Connector on the PXR800 This step is necessary only if you need to power cameras from the frame grabber 24 Chapter 2 Installing the PXR800 22 5 If you are using the PXR801 Camera Extender Board install it by attaching the ribbon cable to the PXR800 and attaching the board to an unused slot in the case 6 Replace the computer s cover Attaching the Cameras Caution Connecting 12 Volt power or pixel clock signals while the computer is operating may damage your equipment Attach cameras that connect to the PXR800 power or pixel clock signals only when the computer is off You can connect up to two cameras to the PXR800 or up to four using the PXR801 Camera Extender Board Each camera must be connected using a cable which attaches to one of the PXR800 s 26 pin connectors For information on pre made cables see Pre Made Cables on page 6 4 contact Imagenation Frame Grabber Sales at 800 366 9131 Restarting the Computer Once the computer has restarted you can verify that the PXR800 and camera are installed correctly by running any of the sample programs such as PXR_Grab_RT1 from the Start menu Optional Equipment The following items are things you may need in addition to the PXR800 frame grabber to complete your application PXR801 C
93. e height of the rectangle in the frame from which to copy the pixels Return Value The return is non zero on success zero if failure Continued on the following page 10 17 Chapter 10 PXRFrame API Functions GetRectangle continued 10 18 Description The GetRectangle function copies a rectangle of an image from a frame into a buffer The upper left corner of the frame is 0 0 If the region is par tially outside of the boundaries of the frame the function will copy only the parts that are within the frame The buffer is assumed to be an array of the correct type to hold the rectangle of pixels If the entire rectangle won t fit in the memory pointed to by pvBuffer undefined behavior and data corrup tion might result If the rectangle extends outside the bounds of the PXRframe only the pixels from inside the frame are copied They will be packed together in the buffer with no space reserved for pixels requested from outside the frame The function will fail if the specified rectangle is outside the boundaries of the frame or if the frame can t be read PXRFrame API Functions Chapter 10 GetRow DWORD GetRow PXRFRAME pFrame void pvBuffer DWORD dwRow FRAMEVB GetRow ByVal pFrame As Long ByRef Buf As Any ByVal dwRow As Long As Long Parameters pFrame is the address of a PXRFrame pvBuffer is the address of the target buffer dwRow is the row number of the frame from which to copy the pixels
94. e mapping where the LUT is set up to the inverse of the palette look up table used by an 8 bit display so the image can be drawn faster e False color displays to emphasize low contrast structures in the image Real Time Control RTC The PCI bus master design of the PXR800 lets you achieve real time perfor mance for image captures to PC main memory The PXR800 can directly con trol image data transfers to main memory This is a plus for RTC because while the PXR800 is transferring data the main CPU is free to run other parts of your application program Data transfers can take advantage of the maximum 132 MB sec burst transfer rate of the PCI bus Although actual throughput is typically well below the maximum burst rate a properly designed system can support real time trans fer and display of video image data 5 17 Chapter 5 Detailed Operating Information 5 18 RTC is provided by the PXR800 Real Time Control Engine This component is responsible for determining which images are allowed into the PXR800 mem ory and for maintaining synchronization between the triggers strobes expo sure multiplexer and grab functions An Image Qualifier determines which data from the Analog Video Processor can be grabbed and an Acquisition Sequencer coordinates real time events strobes exposure etc with the grab process A functional overview of real time control is provided in Figure 5 7 sora CLOCK 0 3 VIDEO 0 3
95. e number of microseconds to convert Return Value Return is a conversion of time measured in microseconds to the appropriate number of HalfH units for the frame grabber zero on error Description The MicsToHalfH function returns the number of HalfH units that occupy the same amount of time as dwMicroseconds within one HalfH The value is only reliable once the grabber is synchronized with the camera Returns immediately See Also HalfHToMics SetRTCTiming GetRTCTiming 9 43 Chapter 9 PXR800 API Functions ReadiO 9 44 DWORD ReadIO FGHANDLE fgHandle PXRVB ReadIO ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value At return the bits are e 7 4 are set to match the general purpose input lines e 3 0 are set to match the general purpose output lines Description The ReadIO function returns a set of bits that match the state of the GPI O lines Returns immediately See Also WriteIO PXR800 API Functions Chapter 9 ReadProtection DWORD ReadProtection FGHANDLE fgHand1le PXRVB ReadProtection ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value Return is the value of the protection key zero on failure Description The ReadProtection function returns the hardware protection key of the frame grabber This will be 0x55 unless the frame grabber has b
96. e sure you don t need any files you have changed simply delete those directories Uninstalling the Drivers For Windows NT 4 0 the drivers can be uninstalled from the Add Remove Programs applet by removing the Runtime component For all other versions of Windows the driver must be uninstalled from the Device Manager To reach the Device Manager right click on My Computer and select Proper ties Find the entry for the PXR800 frame grabber device and delete it Upgrading or Repairing the Software After the PXR800 software is installed you may want to reinstall it A newer version may be available that you want to upgrade to or some of the files may have been accidentally deleted or corrupted To upgrade to a new version run the Setup program for the newer version It will detect the currently installed software and replace any files for which newer versions are available For all systems other than Windows NT 4 0 the drivers will not be automatically updated by Setup To upgrade the drivers right click on My Computer and select Properties to run the Device Man ager Find the entry for the PXR800 frame grabber device and select it Choose Update Driver and follow the directions To repair corrupted or missing files run the Add Remove Programs control panel applet Select repair All files that were installed by Setup will be rein stalled 2 3 Chapter 2 Installing the PXR800 Installing the PXR800
97. e that will be filled with the functions in the DLL that can be accessed by an application count the number of bytes in the structure referred to by iface Return Value If the interface is to a PXR800 API library the return value is the number of frame grabbers that can be accessed in the system If the interface is to a PXRFrame API library the return value is zero on failure non zero on success Description The imagenation_OpenLibrary function opens a library to provide access to PXR800 and PXRFrame functions This library is a DLL and any asso ciated device driver files The file is the name of the DLL It can be either a file name or a full pathname If it is just a file name the specified DLL must be in the computer s search path By default the DLL s for the PXR800 are installed into the Windows directory or in the Windows System directory Valid file names are PXR800 DLL or PXRFRAME DLL to open the librar ies for the PXR800 frame grabber or for the frame library respectively The iface variable is a pointer to a structure that will be filled with pointers to the library s functions For the PXR800 library this structure is of type PXR For the PXRFrame library this structure is of type PXRFRAMELIB The count variable contains the number of bytes in the frame library struc ture It is sizeof PXR for the PXR800 library structure and sizeof PXRFRAMELIB for the PXRFrame library structure
98. e which cameras are available Switch to the next available camera in the sequence 1 2 3 4 icCamera is ignored ST_TO CAMERA switch to a specific camera icCamera is one of CAMERAO CAMERA1 CAMERA2 or CAMERAS dwCameraMask is ignored ST TO TRIGGER switch to the camera matching the trigger that caused the event dwCameraMask describes which cameras are available icCamera is ignored Description The REALTIME structure is used by GetRTCTiming and SetRTCTiming to describe actions taken by the real time controller It consists of two parts an array of IMG _EXPSEQ structures describing pulse sequences on the strobe and exposure lines and a CAMERAEVENT structure describing automatic cam era switching There are five pExposures elements of type IMG_EXPSEQ Each one describes the pulse sequence that should occur on one of the exposure or strobe lines The four strobe lines are e RTC _EXP0 The Exp0 signal does not have an output wire of it s own It can be used to generate a vertical sync waveform on the VSync output for cameras being driven in the SYNC_HD VEXPO mode e RTC _EXP1 e RTC _EXP2 e RTC _STROBE These three pulse sequences are generated on the Exp1 Exp2 and Strobe outputs of the currently selected camera connector Initializing and Exiting Libraries Chapter 8 Chapter 8 Initializing and Exiting Libraries Before calling any library functions from the PXR800 library or the PXRFrame library an ap
99. echnical information third party driver support white papers on 2 6 Installing the PXR800 Chapter 2 advanced technical subjects and the latest drivers and software Go to www imagenation com and select Tech Support Technical support is available Monday through Friday 8 00 A M to 5 00 P M Pacific Time Voice 503 495 2200 Toll free 800 366 9131 Fax 503 495 2201 E mail CSsupport cyberoptics com Internet www imagenation com 2 7 Chapter 2 Installing the PXR800 This page intentionally left blank 2 8 Programming the PXR800 Chapter 3 Chapter 3 Programming the PXR800 This chapter introduces you to programming the Imagenation PXR800 The chapter discusses e The library interface e Handles and ID values e Programming language specifics e Writing multithreaded programs e An example of a simple image capture program If you are just learning to work with the PXR800 you ll also want to read Chapter 4 The PXR Productivity Tool on page 4 1 which describes an interactive application that makes it easy to experiment with some of the more common API functions Later chapters contain reference material that describes all of the features of the PXR800 and all of the functions provided by the libraries The Software Development Kit SDK which you can install from your PXR800 product CD or download from the Imagenation website www ima genation com pxrfamily htm also includes several sample pro
100. ed burst transfer mode causes the following sequence of events e Before Grab is called the Camera End is continuously capturing qualified images e Typically when Grab begins execution the Camera End has already captured part of an image into the PXR800 buffer memory e Image data continues to be written to the PXR800 buffer memory until the last line of image data has been written e The System End detects image completion in the PXR800 buffer memory and begins copying data over the PCI bus to system memory e Image data transfer over the PCI bus continues until all image data is written to system memory e Grab completes 5 33 Chapter 5 Detailed Operating Information 5 34 e Typically Grab finishes several milliseconds after the end of the image With a free running camera arrival of the next image will be well under way Since the Camera End is running in continuous buffered mode this next image is already being captured to the PXR800 buffer and it can be moved to system memory by the next Grab Continuous buffered burst transfer mode combines the high PCI bus effi ciency of burst transfer mode with the high data rates of continuous buffered mode However it is the most difficult mode to use correctly This is because it has longer latency before the image reaches system memory which is char acteristic of burst transfer mode and the coherency problems of continuous buffered mode Queuing The PXR800 maintain
101. ed Operating Information Chapter 5 Single and Continuous Buffering There are four modes of transferring data These modes depend on whether single or continuous buffering is selected SetContinuousBuffering and whether incremental or burst transfer mode is being used SetTransferMode The four modes are Single buffered incremental transfer mode Single buffered burst transfer mode Continuous buffered incremental transfer mode Continuous buffered burst transfer mode These modes are described in detail below Single buffered incremental transfer mode causes the following sequence of events The Camera End does not capture image data until a Grab executes A Grab begins execution The Camera End waits for a vertical sync which might be qualified by a trigger event Several Hsync periods after vertical sync image data begins arriving from the camera As image data arrives it s digitized and written to the PXR800 buffer memory As soon as data appears in the PXR800 buffer the System End begins copying the data across the PCI bus to system memory Typically as image arrival progresses to completion the System End is nearly caught up with the Camera End and almost all of the data in the PXR800 buffer has also been written to system memory When the Camera End sends the last line of valid video data the data is immediately written into the PXR800 buffer The System End copies the final data from the PXR800 buffe
102. ed grabs handling 3 17 strobe 5 25 sync control 5 19 5 25 sync inputs 6 2 sync modes 5 19 composite sync in video 5 20 composite sync on external line 5 20 external sync drive 5 20 vertical and horizontal sync on ex ternal lines 5 20 vertical sync on external line 5 20 system end 5 28 T technical support 2 6 termination 1 5 5 9 thresholding 5 16 transfer modes continuous buffered burst transfer mode 5 33 continuous buffered incremental transfer mode 5 32 single buffered burst transfer mode 5 32 Index 6 single buffered incremental trans fer mode 5 31 triggered grab and display 3 18 triggers 5 18 signal specifications 6 3 trigger events 5 23 troubleshooting installation 2 5 U uninstalling the drivers 2 3 uninstalling the PXR800 2 3 upgrading software 2 3 Vv vertical and horizontal sync on ex ternal lines 5 20 vertical sync on external line 5 20 vertical blanking 5 4 video and machine vision systems 1 1 Video Display Library 3 5 11 1 video frame size setting 5 7 video inputs 6 1 video signal multiplexer 1 5 video32 dll 2 4 3 5 Visual Basic programming 3 5 8 5 W WEN 5 5 5 20 Win32 event 5 36
103. ed to be aware of the possibility of false image artifacts caused by aliasing Noise and Jitter The PXR800 provides high accuracy frame grabbing and digitizing Sampling jitter is less than 2 6 ns and digitizing is accurate to less than 0 5 LSB over zero to 255 grayscale levels 8 bit digitizing These capabilities are superior to most commercially available frame grabbers used in modern machine vision applications Low level video signals will be subject to more quantizing noise relative to signal amplitude than will full amplitude signals To combat this the PXR800 Detailed Operating Information Chapter 5 offers signal gain and offset controls that allow you to adjust amplitude for maximum accuracy and grayscale resolution Keep in mind too that the PXR800 can only duplicate the quality of the images coming from the video camera Noise and other artifacts inherent in the incoming video frame will also be part of the captured video frame Gen erally noise and other undesirable artifacts can be minimized through proper choice of video cameras and attention to shielding and impedance matching throughout the analog video signal path Interlace offset and blur are two video signal artifacts that can be particularly problematic in image edge detection applications Both problems are related to image motion and have various possible solutions as described below Interlace Offset As its name implies interlace offset can occur when a
104. ee Also SetTransferMode SetContinuousBuffering GetContinuousBuffering 9 32 PXR800 API Functions Chapter 9 GetTriggerEvent DWORD GetTriggerEvent FGHANDLE fgHandle DWORD pdwMask IMG TRIGGEREVENT pteEvent PXRVB GetTriggerEvent ByVal fgHandle As Long ByRef pdwMask As Long ByRef pteEvent As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG pdwMask is the address to receive the mask of the currently enabled trigger lines pteEvent the address to receive the trigger event type e TE OFF e TE LOW e TE HIGH e TE RISING e TE FALLING All four triggers use the same teEvent value Return Value Returns a non zero value on success zero on failure Description The GetTriggerEvent function returns the type of event that causes a trig ger to be detected as set by SetTriggerEvent It also returns the mask of which triggers are enabled Returns immediately See Also SetTriggerEvent RTCStart GetRTCStart Grab 9 33 Chapter 9 PXR800 API Functions GetVideoFrameSize DWORD GetVideoFrameSize FGHANDLE fgHandle DWORD pdwLeftOffset DWORD pdwTopOffset DWORD pdwWidth DWORD pdwHeight PXRVB GetVideoFrameSize ByVal fgHandle As Long ByRef pdwLheftOffset As Long ByRef pdwTopOffset As Long ByRef pdwWidth As Long ByRef pdwHeight As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG pdwLeftOffs
105. ee ON es enee oa E EN 5 25 General Purpose Input Output GPI O ceeceeeeteeeees 5 28 DATER BV APP E E E E E 5 28 Camera End and System Bid a cceccxtvrsantanpdxevvrswndotiivatereeanvas 5 28 Single and Continuous Buffering eeeeeeereerrereree 5 31 RUS Uo seria ace E E E N 5 34 OMS RTC ISSUES icaniccsastatnaatewinisateiiestinausatsatieataaaateuniants 5 37 Captured Images eeeoeoceeeeeeeeeeeeececececeeeeceeeeeeeeeeeeeeeeeeeeeeee 5 41 PXRPAM ES nanena aE E E E EENEN 5 41 RGB EXPANSION picio eaea eaii 5 42 imase MATA 2c E NE N 5 42 Frame Libtary Feat tes iaceret nian 5 43 Chapter 6 Hardyare RefcreiCE sinrin a erii eE Ei 6 1 Electrical Characteristics eeeeoeeoooeeoeeeeeeeceeeeceeeeeeeeeeeeeeeee 6 1 Video TAPUS Gasca ps appe tiennie e once aE A E A 6 1 12 Volt Power Output s ssississiseressisrississisiseresrtsrirrisnrrerret 6 1 VSand HS eena a E mre n Ma enone ene aT 6 2 VO Signals saa tenansaadean ates avennuentacpinadeteadeahewreintsapieatemminigpieesets 6 2 Pixel Glo Sete eee ne ene ene ne een E E E 6 3 ATE E E E A 6 3 PV OMNIS IN oa tctaacasachsacesdadeacanteusstasdebsnsssdonsacaseehacasareaieamsanatern 6 4 Cables and Connectors ccssccccccssssecccesssceccccsssscceeeeseees 6 4 Pre Made Cables ae en eee Peer eee ete ee ee eee eee es 6 4 Connector PiNouUtS soja sesicesleedetucanrenatdauiucicaciadialaiessenaecandes 6 5 Connector POS t ONS a2iiac052t4 aicosniacaceeelidicnnspaanellateiadeiesicened
106. een pro grammed with a key to match custom software Returns immediately The protection key is optional It is only available by special arrangement with Imagenation 9 45 Chapter 9 PXR800 API Functions ReadRevision DWORD ReadRevision FGHANDLE fgHand1le PXRVB ReadRevision ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value The return is the revision number if successful zero on failure If fgHandle is INVALID_GRABBER the return value is the software revision number only Description The ReadRevision function returns the revision number of the frame grab ber and the driver The bits are arranged as e 31 20 software revision number e 19 12 hardware revision number e 11 0 firmware revision number Returns Immediately 9 46 PXR800 API Functions Chapter 9 ResetFG void ResetFG FGHANDLE fgHandle PXRVB ResetFG ByVal fgHandle As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value No return If gHand1e is invalid the request is ignored Description The ResetFG function returns the frame grabber to a default state and aborts any queued operations Any RTC sequence is aborted This function takes several milliseconds to execute See Also FreeFG KillQueue 9 47 Chapter 9 PXR800 API Functions ResetRTC QUEUEID ResetRTC FGHANDLE fgHandle IMG WHEN2 i
107. eight is the height of the region in the destination frame into which to copy the pixels Return Value The return is non zero on success zero if failure Description The CopyFrame function copies a region from one frame into another This function only copies data between the parts of rectangles that are within the boundaries of the frames CopyFrame fails if e The specified region is entirely outside the boundaries of the frames e The frames can t be read or written e The frames don t have the same pixel type See Also GetRectangle PutRectangle 10 5 Chapter 10 PXRFrame API Functions FrameBits DWORD FrameBits PXRFRAME pFrame FRAMEVB FrameBits ByVal pFrame As Long As Long Parameters pFrame is the address of a PXRFrame Return Value The number of bits per pixel for the frame zero if failure Description The FrameBits function returns the number of bits used per pixel in the frame The valid pixel types for a frame are e PBITS Y8 e PBITS RGB16 e PBITS RGB24 e PBITS RGB32 10 6 PXRFrame API Functions Chapter 10 FrameBuffer void FrameBuffer PXRFRAME pFrame Function does not exist for Visual Basic Parameters pFrame is the address of a PXRFrame Return Value The address of the frame s image buffer or NULL if failure Description The FrameBuffer function returns a pointer to the frame s image buffer represented as an array of pixels The returned pointer ca
108. en the program terminates even if the program does not clean up properly but well written programs do not rely on this Programming the PXR800 Chapter 3 Compiling the Program To compile this program using the Microsoft Visual C 6 development sys tem do the following 1 Create a new project of type Win32 Application 2 Choose to make an empty project 3 Adda new C source file containing the program to the project 4 Add ilib_32 lib to the list of Object Library modules in the project link settings This file can be found in the Lib directory of the PXR800 SDK 5 Make the header files available to the compiler This can be done by adding the Include directory of the PXR800 SDK to the list in the Directories tab of the Options dialog box 6 Build the project Running the Program This program assumes that a PXR800 frame grabber is properly installed and that pxrframe dll pxr800 dll and the PXR drivers have been installed Because this program does not do detailed error checking it will crash if a fatal error occurs You may want to verify that the frame grabber is properly installed by running a prebuilt sample before running this program The program also assumes that a free running NTSC camera is attached to camera input 0 If you use a CCIR or similar camera an image will still be pro duced but it will not have the correct size and aspect ratio for a CCIR camera An asynchronous resettable camera that expects an
109. er s onboard clock The clock is accurate to 1 100 second It runs independently of the pixel clock and the camera s timing so the accuracy of the clock is not affected by changes in camera timing dwFieldCount the number of vertical syncs detected by the frame grabber since the last time the counter was set dwFieldInSecond the number of vertical syncs seen since the last one second tick of the frame grabber s clock Because the time of day clock is independent of the camera s pixel clock and sync timing there will be some uncertainty less than 1 100 second in the timing relationship between the clock and verti cal sync even for a camera with very stable video output This can result in the dwFieldInSecond number varying by 1 from the expected value The following are only included as part of the annotation data for an image bFields 0 Two even fields in a row 1 Odd field followed by an even field 2 Even field followed by an odd field 3 Two odd fields in a row For single field 0 or 2 Even field 1 or 3 Odd field bCamera the camera from which the image was captured bQualifyingTrigger the trigger that qualified the grab If the grab was not qualified by a trigger this value is undefined bInputs the state of the frame grabber input wires The low four bits are the general purpose inputs The other four bits are zero bOutputs the state of the frame grabber output wires The low four bits
110. er there are cases where it may be desirable to work with 16 bit or 32 bit RGB formats A com mon case is when the image is to be used for display purposes When this is the case processing for display will be much more efficient if the image data is in the same pixel format as the display device The PXR800 and PXRFrame library support 8 bit grayscale which is the PXR800 s native format Additionally 16 bit true color 5 red 6 green and 5 blue bits and 32 bit true color 8 red 8 green 8 blue and 8 unused bits are supported by the PXR800 The desired pixel type must be specified in AllocateBuffer with the ptType parameter The pixel type parameters are e 8 bit PBITS_Y8 e 16 bit PBITS_RGB16 e 32 bit PBITS_RGB32 When expanding to an RGB frame the image is still grayscale This is because each of the three color components are given the same value in PXR800 s expansion process In considering use of RGB expansion keep in mind that the PXR800 works most efficiently when transferring 8 bit grayscale images So you must con sider the trade offs between PXR800 efficiency and display processing effi ciency If your application is going to do significant processing for a 32 bit display it might be desirable to sacrifice some PXR800 efficiency for greater display processing efficiency Also the RGB formats are less efficient in that they require more memory and more data transferred over the PCI Bus The 16 bit format is less ac
111. er memory 1 7 buffering continuous 5 28 5 30 5 31 5 37 Index double 5 28 5 37 invalidating the buffer 5 37 ping pong 5 28 single 5 29 5 31 burst mode 5 30 C C language programming 3 4 8 1 cables 2 2 6 4 camera end 5 28 Camera Extender Board PXR801 2 2 camera interface 1 5 CAMERAEVENT data structure 7 5 cameras attaching 2 2 cables 2 2 camera formats 5 2 5 6 9 11 configuring 3 14 detecting 3 14 selecting 5 18 captured images 5 41 CCIR 5 2 closing libraries 8 1 coherency issues 5 37 composite sync in video 5 20 composite sync on external line 5 20 configuring cameras 3 14 connectors 6 4 continuous buffering 5 28 5 30 5 31 5 37 continuous buffered burst transfer mode 5 33 Index 1 Index continuous buffered incremental transfer mode 5 32 D data flow 5 28 data structures CAMERAEVENT 7 5 IMG_EXPSEQ 7 5 IMG_IMAGEINFO 5 42 7 2 IMG_IMAGEINFOSTATUS 7 2 IMG_IMAGEINFOTIMING 7 2 REALTIME 7 5 detecting cameras 3 14 DLLs pxr800 dll 2 4 3 1 8 2 pxr800_display dll 2 4 3 5 3 7 pxrframe dll 2 4 3 1 8 2 video32 dll 2 4 3 5 double buffering 5 28 5 37 drivers pxr800 sys 2 4 pxr800NT sys 2 4 uninstalling 2 3 E electrical characteristics 6 1 environmental specifications 6 4 even field 5 4 event detector 5 18 5 24 examples camera detect sample code 3 14 handling stalled grabs 3 17 initializing and exiting libraries 8 3 simple image capture program 3 8 triggered grab and dis
112. er of the frame is 0 0 If the region is partially out side of the boundaries of the frame this function will copy only the parts that are within the frame This function will fail if the specified rectangle is outside the boundaries of the frame 10 23 Chapter 10 PXRFrame API Functions PutRow DWORD PutRow void pvBuf PXRFRAME pFrame DWORD dwRow FRAMEVB PutRow ByRef Buf As Any ByVal pFrame As Any ByVal dwRow As Long As Long Parameters pvBuf is the address of the source buffer pFrame is the address of a PXRFrame dwRow is the row number of the frame into which to copy the pixels Return Value The return is non zero on success zero if failure Description The PutRow function copies a row of data into the frame s image The rows are numbered starting with zero at the top of the frame If the buffer does not contain enough data undefined behavior and data corruption might result This function will fail if the specified column is outside the boundaries of the frame or if the frame can t be read 10 24 PXRFrame API Functions Chapter 10 ReadBin DWORD ReadBin PXRFRAME pFrame char szFileName FRAMEVB ReadBin ByVal pFrame As Long ByVal szFilename As String As Long Parameters pFrame is the address of a PXRFrame szFilename is the name of the file to read Return Value SUCCESS the file was read successfully FILE OPEN ERROR the file could not be opened BAD READ
113. era svStart and f1Fields are ignored There might be cases where a Grab takes a long time to begin or does not begin at all because the specified conditions are never met e The Grab depends on a trigger event e There isn t a camera attached to the current video input e The current camera does not produce continuous stable video If this is possible in your application you should use IW_QUEUED and TimedWaitFinished to detect these conditions and recover See Also Wait IsFinished WaitFinished TimedWaitFinished WindowsEventFromQID AllocateBuffer 9 38 PXR800 API Functions Chapter 9 HalfHToMics DWORD HalfHToMics FGHANDLE fgHandle DWORD dwHal fH PXRVB HalfHToMics ByVal fgHandle As Long ByVal dwHalfH As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwHalfH is the number of HalfH units to convert Return Value Return is a conversion of time measured in HalfH units for the frame grabber to the appropriate number of microseconds zero on error Description The HalfHToMics function returns the number of microseconds that occupy the same amount of time as the HalfH units within one microsecond HalfH is the time unit used by the frame grabber for timing exposure pulses The value is only reliable once the grabber is synchronized with the camera If the grab ber is not receiving video this function returns zero Returns immediately See Also MicsToHalfH Se
114. ered Grab and Display 3 18 The next example is a program that uses triggers and displays images Sup pose that a computer with a PXR800 is being used to monitor several locations for security Each location has a camera and some sort of detector that gener ates a signal when motion is detected The program will wait for a trigger from one of up to four detectors and capture an image from the appropriate cam era The most recently triggered image will be displayed in a window The full program installed with the SDK samples as PXR_Trigger will not be presented here because it contains a lot of code to create and manage win dows allocate resources and so forth It can be divided into three sections initialization main loop and termination Initialization must allocate a frame grabber and a PXRFrame just as in the previous example as well as register a window class create a window and set up any other Windows user interface routines that are needed Termination frees all of the resources that are allo cated during initialization We will look in detail at the main loop The main loop is responsible for both responding to window messages and capturing images from the frame grabber One way to organize this is to use the PeekMessage function from the Win32 APD to check for window mes sages that need to be handled and call a separate function here named AppIdle that manages the frame grabber AppIdle returns TRUE if the frame grabbe
115. erlaced Progressive Lines Frame 525 525E 625 6258 Lines Field 262 5 525 312 5 625 Displayed Lines Frame 485 485 575 575 Displayed Lines Field 242 5 N A 282 5 N A Blanked Lines Frame 40 39B 50 49B Blanked Lines Field 20 N A 25 N A Framerate 30Hz 30Hz 25Hz Fieldrate 60Hz N A N A PXR800 Specific Information Image Width pixels 640 or 20 640 768 or 720 768 Image Height lines 484F 4848 574 5748 Frame Top lines 35 35B 46 468 Frame Left pixels 115 115 155 155 12 2727 12 2727 14 7500 14 7500 Pixel Clock MHz 13 5000 vr aur ve 5 A The image width number of pixels per line depends on the pixel clock rate Most video signals can be sampled at any pixel clock rate with corresponding changes to the image width and aspect ratio The numbers listed here are common values that provide correct aspect ratios for common camera geometries B Progressive scan camera formats are not as standardized as interlaced formats Line counts for progressive scan cameras might differ from what s given here C Frame Top is the value expected for the dwlopOffset parameter of the SetVideoFrameSize function This number is the count of lines between vertical sync and the start of the image for a full frame D Frame Left is the value expected for the dwLeftOffset parameter of the SetVideoFrameSize function It represents the number of pixel clocks between the leading edge of HSync an
116. esulting in higher frame rates but it also requires the programmer to use InvalidateGrabberBuffer to avoid inconsistent image data after chang ing frame grabber settings In BU _ SINGLE mode video will only be captured into the frame grabber s buffer in response to a Grab command This mode guarantees consistent image data but can be less efficient in some cases This function waits for the queue to empty and will invalidate any images stored in the PXR800 buffer memory See Also GetContinuousBuffering SetTransferMode GetTransferMode 9 53 9 54 Chapter 9 PXR800 API Functions SetDriveMode DWORD SetDriveMode FGHANDLE fgHandle IMG DRIVEMODE dmMode PXRVB SetDriveMode ByVal fgHandle As Long ByVal dmMode As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dmMode is the drive mode DRIVE DISABLED e DRIVE HD VD e DRIVE HD VEXPO See Table 9 7 on page 9 55 Return Value The return is non zero for success zero for failure Description The SetDriveMode function sets the vertical and horizontal drive mode of the frame grabber This function waits for the queue to empty Continued on the following page PXR800 API Functions Chapter 9 SetDriveMode continued Mode Name Description The frame grabber doesn t generate drive signals It DRIVE_DISABLED will try to synchronize to the currently selected camera using the mode spe
117. et is the address to receive the left offset of the video frame valid range 0 2047 pixels pdwTopOffset is the address to receive the top offset of the video frame valid range 0 2047 lines pdwWidth is the address to receive the width of the video frame valid range 4 2044 pixels pdwHeight is the address to receive the height of the video frame valid range 1 2047 lines Return Value Returns a non zero value on success zero on failure Continued on the following page 9 34 PXR800 API Functions Chapter 9 GetVideoFrameSize continued Description The GetVideoFrameSize function returns the dimensions of the video frame and its position within the video stream The width and height contain the valid region of the image The top and left offsets allow for the image to be moved within the video stream to avoid the blanking and sync periods and to compensate for non standard timing in some cameras Use SetVideoFrameSize to change the values This function will not return until all queued operations have completed See Also SetVideoFrameSize GetROI SetROI Table 9 3 on page 9 11 9 35 Chapter 9 PXR800 API Functions Grab QUEUEID Grab FGHANDLE fgHandle PXRFRAME pFrame DWORD dwSkipVSyncs IMG GRABEVENT START geStart BOOL bSwitchToTrigger IMG START VSYNC svStart IMG FIELD LEN flFields IMG WHEN iwWhen PXRVB Grab ByVal fgHandle As Long 7 ByVal pFrame As Long ByVal dwSkipVSyncs As
118. ettable camera allows an external signal to mark exactly when each image should be exposed Thus with an appropriate trig ger signal corresponding to correct part positioning the camera is able to take a snapshot of the part at exactly the right time The resulting video stream may appear continuous if the trigger events are evenly spaced or it may contain only occasional irregularly timed images if the trigger events are irregularly timed Cameras with programmable exposure will accept a signal that controls the length of time each image is exposed This allows precise control of the amount of light collected and thus the brightness of the resulting image Programmable exposure is useful for compensating for variable lighting envi ronments With the appropriate algorithms the vision system can dynamically control exposure to overcome lighting changes There are also cases where a specific exposure time is needed For example short exposures are often used when imaging moving objects to minimize motion blur On the other hand a long exposure may be needed to capture images in low light or to detect low contrast features 1 3 Chapter 1 Introduction Often there is a choice between controlling the camera exposure time and controlling the lighting For example a short exposure can be used to capture fast motion or ambient lighting can be turned off and a fast bright strobe light can be used to cause a flash exposure in the dark
119. executed e Call BlockGrabber e Call the various setup functions for RTC sequences and trigger conditions that are to participate in a setup operation that you don t want interrupted with a Grab e Ifa Grab operation must be part of the setup operation call Grab without unblocking The block will automatically be removed by the grab operation Otherwise call BlockGrabber again to release the block and allow PXR800 operation to continue normally For many applications blocking isn t necessary This is because various RTC and trigger settings can be set up when the application starts before any trig ger events are expected Blocking does become important though when trig ger events can occur at the same time as changes to RTC settings It is important then to block any chance of a trigger activating functions when the setup is not correct or complete Using Wait to Avoid Coherency Problems Another approach to avoiding coherency issues is to simply skip capturing images that might be in question or that might not be needed This can be done using the Wait function For example suppose an application uses a motion detection algorithm that requires images at a steady rate of ten frames per second A standard RS 170A video camera is being used to capture images at 30 frames per second To capture just the needed frames the application can queue a Grab for each frame it needs and follow the grab operation with two Wait operations
120. f FALSE the time stamp information cannot be retrieved The PBITS RGB24 pixel type can be used to store and manipulate images but cannot be the target of a Grab from the PXR800 See Also FreeFrame FrameFromPointer 10 3 Chapter 10 PXRFrame API Functions CopyFrame 10 4 DWORD CopyFrame PXRFRAME pSourceFrame DWORD dwSourcexX DWORD dwSourceY PXRFRAME pDestFrame DWORD dwDestxX DWORD dwDestyY DWORD dwWidth DWORD dwHeight FRAMEVB CopyFrame ByVal pSourceFrame As Long ByVal dwSourceX As Long ByVal dwSourceY As Long ByVal pDestFrame As Long ByVal dwDestX As Long ByVal dwDestY As Long ByVal dwWidth As Long ByVal dwHeight As Long As Long Parameters pSourceFrame is the source frame dwSourceX is the X coordinate of the upper left region in the source frame from which to copy the pixels dwSourceY is the Y coordinate of the upper left region in the source frame from which to copy the pixels pDestFrame is the destination frame dwDestX is the X coordinate of the upper left region in the destination frame into which to copy the pixels dwDestY is the Y coordinate of the upper left region in the destination frame into which to copy the pixels dwWidth is the width of the region in the destination frame into which to copy the pixels Continued on the following page PXRFrame API Functions Chapter 10 CopyFrame continued Parameters continued dwH
121. field of view as shown in Figure 5 1 The benefits of capturing only the ROI include reduced memory demands on the application and reduced processing and image transfer times IMAGE FROM THE CAMERA SS SSS REGION OF INTEREST ROI CAPTURED BY THE FRAME GRABBER OBJECT OF INTEREST The PXR800 allows capture of a region of interest from the full field of view sent by the camera Figure 5 1 Region of Interest ROI Camera Formats The PXR800 is designed to grab or capture frames from video cameras com plying with RS 170A NTSC U S or CCIR PAL European standards for inter laced field or progressive scan frames RS 170A and CCIR formats are similar in most respects but their field and frame rates differ as shown below e EIA RS 170A 2 1 interlaced 60 Hz field rate e EIA RS 170A rate progressive scan 30 Hz frame rate e CCIR standard 2 1 interlace 50 Hz field rate e CCIR rate progressive scan 25 Hz frame rate 5 2 Detailed Operating Information Chapter 5 Note RS 170A is the specification for color television It is an extension of the previous RS 170 specification for black and white television The PXR800 can capture frames from video sources following either specification however RS 170A video is captured as grayscale rather than color images In both the RS 170A and CCIR formats a complete video image is referred to as a video frame or simply a frame Each frame from an RS 170
122. frame valid range zero to CCIR HEIGHT_DEFAULT lines dwWidth is the width of the video frame valid range zero to CCIR_WIDTH_DEFAULT pixels dwHeight is the height of the video frame valid range zero to CCIR HEIGHT_DEFAULT lines iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI_ INVALID on failure Continued on the following page 9 77 Chapter 9 PXR800 API Functions SetVideoFrameSize continued Description The SetVideoFrameSize function sets the size of the video frame and its position within the video stream The width and height contain the valid region of the image The top and left offsets allow for the image to be moved within the video stream to avoid the blanking and sync periods and to com pensate for non standard timing in some cameras This will invalidate any images stored in the PXR800 buffer memory See Also GetVideoFrameSize GetFieldLength SetROI GetROT Table 9 3 on page 9 11 9 78 PXR800 API Functions Chapter 9 TimedWaitFinished DWORD TimedWaitFinished FGHANDLE fgHandle QUEUEID gilD DWORD dwMs PXRVB TimedWaitFinished ByVal fgHandle As Long ByVal qiID As Long ByVal dwMs As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG qiID i
123. functions these functions return control to the appli cation program after they complete their operation Detailed Operating Information Chapter 5 Synchronizing to the Queue It s often necessary to find out whether or not a previously queued function has completed its task IsFinished WaitFinished and TimedWaitFinished provide several ways of doing this The IsFinished function can be used to determine if a specific queued operation has completed To do this the operation s QUEUEID value must be provided to IsFinished A non zero value is returned if the specified oper ation is completed zero is returned if the operation has not completed You can also use IsSFinished to find out if the queue is empty all queued operations have been completed To do this use the special QUEUEID value called QI ALLQUEUE A non zero value is returned only when the queue is empty The WaitFinished function allows you to wait until a specific queued oper ation completes or even until the entire queue is empty During the wait the calling thread does not use significant system CPU time This allows other threads in the system to run more efficiently In general using WaitFinished allows more efficient system operation than can be achieved by using IsFinished in a wait loop There are however some potential pitfalls that you need to be aware of For example a queued operation might never complete This occurs with a queued Grab that is wa
124. gHandle is the handle to the frame grabber returned by AllocateFG ifFilter is the Nyquist filter setting e IF NONE e IF HIGH FREQ ON iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI INVALID on failure Description The SetNyquistFilter function turns the Nyquist filter on or off as speci fied by the ifFilter parameter which can take the following values e If itis IF NONE the filter is not activated e If IF HIGH FREQ ON the high frequency component of the signal is filtered out See Also GetNyquistFilter 9 61 Chapter 9 PXR800 API Functions SetOffset QUEUEID SetOffset FGHANDLE fgHandle long l1Offset IMG WHEN iwWhen PXRVB SetOffset ByVal fgHandle As Long ByVal lOffset As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG 10ffset is the offset valid range 128 127 iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI INVALID on failure Description The SetOffset function sets the video offset of the current frame grabber
125. ges are stored in system memory in a structure referred to as a PXRFrame PXRFrame structures are defined using functions from the PXR800 PXRFrame Library In addition to defining PXRFrames the PXRFrame Library can be used for RGB color expansion adding image information data and other opera tions These capabilities are described below PXRFrames A PXRFrame is created using the AllocateBuffer function from the PXRFrame Library Various parameters are used to describe the dimensions and attributes of the signal and how it is to be stored in the PXRFrame Each PXRFrame must be given a height and width The height parameter specifies how many lines there are in the image and the width parameter specifies the number of pixels per line There is also an image pitch parameter that specifies the number of bytes between the start of one line and the start of the next line Usually the width and pitch are the same number but some times it might be useful to make the pitch larger The pitch of a PXRFrame must be such that each line starts on a DWORD boundary This means that the pitch must be an integer multiple of four The width parameter doesn t have to be a multiple of four as long as the pitch is When a PXRFrame is allocated the amount of system memory required depends on the height pitch and pixel type 5 41 Chapter 5 Detailed Operating Information 5 42 RGB Expansion Images coming from the PXR800 are 8 bit grayscale Howev
126. gnals 6 2 ID values 3 2 ilib_32 lib 3 4 3 13 image capture program example 3 8 image geometry 5 1 image grabs 5 23 image information 5 42 image manipulation 5 9 image qualifier 5 18 5 23 image quality 5 9 imaginfo bas 3 7 IMG_EXPSEQ data structure 7 5 IMG_IMAGEINFO data structure 5 42 7 2 IMG_IMAGEINFOSTATUS data structure 7 2 IMG_IMAGEINFOTIMING data structure 7 2 incremental mode 5 30 Index 4 initializing libraries 3 2 8 1 inputs I O signal specifications 6 2 sync signal specifications 6 2 video signal specifications 6 1 installation installing the PXR Productivity Tool 4 1 installing the PXR800 2 1 installing the PXR800 as part of a product 2 4 installing the PXR800 card 2 1 installing the PXR800 software 2 1 troubleshooting 2 5 interlace offset 5 11 interlaced format 1 3 5 3 invalidating the buffer 5 37 IW_QUEUED flag 5 34 IW2_QUEUED flag 5 34 J jitter 5 10 L libraries exiting 3 4 8 1 ilib_32 lib 3 4 3 13 initializing 3 5 8 1 library interface 3 1 opening 3 4 PXR800 API functions 9 1 PXRFrame API functions 5 43 10 1 look up table LUT 1 7 5 16 LUT see look up table M multiplexer 1 5 multithreaded programs 3 7 N noise 5 10 NTSC 5 2 Nyquist filtering 1 6 5 10 Nyquist frequency 5 10 O odd field 5 4 offset 1 7 5 13 opening libraries 3 2 8 1 operating information 5 1 optional equipment 2 2 outputs 12 volt power 6 1 I O signal specifications 6 2 sync signal
127. grams that you can read and modify Many of the examples in this chapter are pieces of the sample code included with the SDK The Library Interface The PXR800 Application Programming Interface APD is made of two DLLs pxr800 dll and pxrframe dll These DLLs are designed to be callable from the C programming language and from Microsoft Visual Basic They can also be used with C although they do not use any extra features of the C lan guage The library DLLs must be installed on the computer where the program will run To compile a program using the PXR800 you must also have several 3 1 Chapter 3 Programming the PXR800 3 2 header and other files all of which are installed when you install the PXR800 SDK To use the DLLs they must be opened by calling the OpenLibrary function see Chapter 8 Initializing and Exiting Libraries on page 8 1 This function loads the DLL and in the case of pxr800 dll asks the DLL to connect to the driver and detect any PXR800 frame grabbers installed in the system This initialization process differs in several ways from the more common method of linking to a DLL where the DLL is automatically loaded at the same time as the application program Since each DLL is not loaded until the application program calls OpenLibrary the program can easily detect and handle the situation where the libraries may not be present For instance if no PXR800s are installed in a system pxr800 dll will fa
128. h e FL FIELD e FL FRAME iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request or QI_INVALID on failure Description The Grab function captures a video image and writes it into the frame buffer pFrame This function will crop the image to fit the buffer if the dimensions of SetROI exceed the dimensions of the frame buffer The choice between starting a grab on VSync or on VSyncStart controls exactly when in vertical blank the decision about whether to qualify a frame for grabbing is made If the precise timing of grabs is not important either set ting will work In applications where grabs must be synchronized with RTC exactly the grab start should usually match the RTC start time If iwWhen is IW_QUEUED the function returns immediately Otherwise it will not return until the Grab is completed If iwWhen is IW_QUEUED the return value can be used in IsFinished TimedWaitFinished or WaitFinished to check if the Grab is completed Continued on the following page 9 37 Chapter 9 PXR800 API Functions Grab continued Description continued If the blocking depth set by BlockGrabber is not zero at the time the Grab command is executed the blocking depth will be implicitly set to zero by the Grab When using a noninterlaced cam
129. he created frame is DWORD aligned and accessible by the PCI bus which is true for most user addressable data the PXR800 can capture directly into the frame created in system memory Multiple PXRFrames that use the same memory buffer can also be created And even though the same system memory buffer is used the PXRFrames can have different formats This is useful for conserving memory and can also be used to achieve special effects The memory allocated to the PXRFrame can even be onboard another PCI device such as a display adapter When this is done image grabs to the PXRFrame are done as peer to peer transfers between the PXR800 and the PCI device where the allocated memory resides The advantage here is that the image grab and transfer does not use any main system memory or CPU resources For example an application could use DirectX to get a pointer to video display memory then capture images directly into it The images would appear on the display without ever being stored in system memory Hardware Reference Chapter 6 Chapter 6 Hardware Reference Electrical Characteristics Video Inputs Input Impedance 75 Ohm 1 or gt 10K Ohm software selectable Signal Levels 0 5 V or 1 0 V peak to peak including sync Signal DC Offset 1 2 V to 3 V Nyquist filter frequency 3 dB at 7 MHz Nyquist filter rolloff 24 dB Octave 12 Volt Power Output Max total current 2 A typical Max current per camera 1 A typical Protecti
130. he odd field ends with one half field line followed immediately with the start of the even field As with the odd field the even field begins with a vertical blanking interval covering a duration of 20 lines The timing of this is such that the even field s first active video is one half line Thus because of blanking the 525 line RS 170A video frame actually has 485 displayed lines 242 5 lines per field CCIR signals fol low a similar format but with differing numbers of lines and frame rates Progressive scan cameras that follow either RS 170A or CCIR provide output signals representing a continuous frame no fields or field interlacing To con form to either standard each frame is separated by a vertical blanking period that is twice as long as in the interlaced field format This results in the same active video line counts as occurring in interlaced frames Table 5 1 on page 5 6 summarizes these line counts for the various standard video formats The PXR800 detects the video sync pulses as a means of synchronizing itself with the video camera By default the PXR800 vertically resynchronizes when ever it sees a vertical sync waveform in its video input or when it detects a WEN write enable signal on the PXR800 Vsync line The line number and the video field are both re established with each vertical sync or WEN signal Horizontal resynchronization occurs within one horizontal period In some cases the video input may have a miss
131. il to make a connection to the driver and will not be able to load If the DLL were implicitly loaded at program start the entire pro gram would fail automatically in this case Since the DLL is loaded explicitly the program instead detects the zero return value from OpenLibrary and provides it s own error messages or continues to run with a reduced feature set Handles and ID Values In the PXR800 programming interface there are several different situations in which a number serves as an identifier or handle representing some resource There is the FGHANDLE returned by AllocateFG which represents a PXR800 frame grabber There is the QUEUEID which represents an operation that is waiting in the frame grabber s queue before completing and there is the Win32 HANDLE type which represents a synchronization event that occurs when a queued operation completes The PXRFRAME pointer returned by AllocateBuffer in the PXRFrame library can also be thought of as a han dle to an image A FGHANDLE is simply an arbitrary non zero number representing a frame grabber It is not a handle to any Win32 object If you have several frame grabbers allocated at a given time the handle to each one will be unique However if you allocate a frame grabber free it and then allocate it again the two handles may or may not be different Each frame grabber is owned by the process that allocated it and they cannot be shared between processes There is no way to
132. ilar The differences are e The library interface is a structure rather than a class e The methods provided by the object are stored as pointers to functions rather than C virtual functions e There is no constructor or destructor so you must explicitly create and destroy the object There are no restrictions on the number of library structures the application has open what they are named or the scope and lifetime of the memory where the structure is stored A program may choose to open the PXR800 library using a single global structure that is accessible to the entire program If the parts of the program that use the PXR800 are going to form a module and none of the code outside of the module needs to access the libraries the structure can be made static so that it s available only inside the module Or it can even be allocated using malloc or new When compiling and linking an application that uses the PXR800 library or the PXRFrame library the list of library modules in the project s link settings should include ilib_32 lib This is a small linkable library provided with the Programming the PXR800 Chapter 3 DLLs that contains the imagenation_OpenLibrary and imagenation_CloseLibrary functions The project does not need an import library such as pxr800 lib or pxrframe lib This is because ilib_32 lib takes care of resolving references to the DLLs at runtime The name provided to imagenation_OpenLibrary can be either a full
133. inding and measuring objects in the image It may also be called upon to determine whether an object or feature is correctly positioned and may have to do numerous other image detection and analysis tasks Additionally 1 1 Chapter 1 Introduction the machine vision task generally takes place in carefully designed environ ments where the camera lighting and timing of events require special control An example of such machine vision system is shown in Figure 1 1 PROCESS CONTROL CONTROL SIGNALS LIGHTING TRIGGER CONTROL EVENTS VIDEO SIGNAL PXR800 COMPUTER AND MACHINE VISION SOFTWARE An example machine vision system with a PXR800 installed in the computer system for video system control and video image capture Figure 1 1 Example of a Machine Vision System As a result of the more stringent requirements video cameras designed for machine vision applications often have special features to provide the neces sary image control and accuracy Some of the more important features often seen in these cameras include progressive scan imaging asynchronous reset and programmable exposure control 1 2 Introduction Chapter 1 Progressive scan cameras expose and transmit a complete image for each frame in the video stream This differs from the more common interlaced video formats which expose and transmit fields composed of alternate video lines These fields are then interlaced to produce a complete
134. ing horizontal sync pulse A missing horizontal sync pulse causes a line of video to be skipped and the internal line count might be off by one This often occurs at the end of the video field and is of little consequence because the line count is re established during the subsequent vertical sync period In any system standard or nonstandard the number of field or frame lines can be measured with the GetFieldLength function In progressive scan systems the value returned by GetFieldLength is the frame height In interlaced systems returned field lengths are half the frame height rounded down to an integer value The PXR800 does not innately know if the incoming image is interlaced or progressive scan The application program must tell the PXR800 which image format to expect You use the SetInterlaceMode function to specify the camera image format FORMAT INTERLACED or FORMAT PROGRESSIVE The PXR800 can also grab frames from video cameras that use nonstandard video formats Such cameras do use the general format of fields frames hori zontal sync and vertical blanking however the size of the fields and frames differs from the standard line counts SetVideoFrameSize SetInterlaceMode SetSyncMode and SetPixelClock provide facili ties for setting the PXR800 to grab virtually any format of video input signal 5 5 Chapter 5 Detailed Operating Information General Video Formats RS170 RS170 CCIR CCIR Interlaced Progressive Int
135. into the PXR800 buffer memory The function also blocks any new RTC sequence from starting but allows in process sequences to finish It is important to call BlockGrabber prior to any RTC sequence or grab that might be subject to race conditions Once called BlockGrabber remains in effect keeping the target activities blocked until it is called again to remove the block and allow activities to continue Calls to BLlockGrabber can be nested Each time this function is called with bBlock TRUE the blocking depth is increased Each time it is called with bBlock FALSE block depths that are greater than zero are decre mented Blocking of events ceases only when the block depth becomes zero Note The Grab and Wait functions automatically set block depth to zero when they run Otherwise there would be no way to start a grab as part of a blocked group of operations BlockGrabber is also a queueable operation When queued block depth changes when the operation reaches the top of the queue and executes Regardless of where it is in the queue the blocking depth returned by BlockGrabber is the future value that will be in effect when the operation reaches the top of the queue 5 39 Chapter 5 Detailed Operating Information 5 40 The following is a typical sequence where blocking is used e Wait for any currently active grabs and RTC sequences to finish so that they are not modified by the new settings that are about to be
136. isplay Library also need the files pxr800_display dll and video32 dll with all operating systems Table 2 1 Operating System Specific Files If you have installed the SDK on a development computer copies of all the files needed for all operating systems are available in the Redist directory 2 4 Installing the PXR800 Chapter 2 Troubleshooting If the PXR800 appears not to be working correctly here are some things to try that can diagnose or fix many common installation problems General Tips Under Windows NT and Windows 2000 check the System Event Log for errors reported by the PXR800 driver The event log can be viewed with the Event Viewer In the Start menu look under Programs gt Administrative Tools gt Event Viewer Search the computer s disks using Find Files or Folders on the Start menu for all copies of pxr800 sys pxr800nt sys pxr800 dll and pxrframe dll Delete any unused copies and check the file dates versions and file sizes of these files to be sure they are the correct version Check the Imagenation product website www imagenation com for newer software or reports of workarounds The PXR800 sys driver is not signed If you are running Windows 2000 or Windows XP be sure the system is set up to allow unsigned drivers to run If the system is set up to block unsigned drivers you may need to reinstall the PXR800 software after allowing unsigned drivers If the system won t start or crashes while sta
137. iting for an external event such as a trigger signal or an incoming image that never arrives Since the Grab never gets triggered it remains in the queue forever and WaitFinished waits forever The same thing can also happen with queueable operations called with the IW_WAIT or IW2 WAIT flag if they require an event that never occurs The TimedWaitFinished function can be used to avoid potentially endless waits such as those described above When executed it waits until either the specified queued operation completes or until a specified time out value is reached If the queued operation doesn t complete TimedWaitFinished waits roughly for the specified time out interval However the actual time waited is not precise so there can be significant uncertainty as to when the function actually returns because of a time out When a time out does occur the operation being waited on remains in the queue KillQueue must be used to remove operations from a stuck queue 5 35 Chapter 5 Detailed Operating Information 5 36 Note The return from a function with an IW_WAIT or IW2_WAIT flag acts like a QUEUELD The return can be passed to IsFinished WaitFinished or TimedWaitFinished Since the operation is complete when the function returns IsFinished always returns TRUE and WaitFinished and TimedWaitFinished return immediately The KillQueue function can be used to clear the queue If the operations in the queue are no longer
138. ity of an End or Stop button create a button that calls Form Unload Displaying Video in Visual Basic Applications The process of displaying video in a window with Visual Basic is a bit cum bersome To simplify that process the PXR800 support for Visual Basic includes a Video Display Library that consists of the following two DLLs e PXR800_Display DLL e Video32 DLL The DLLs operate as a pair with the PXR800_Display DLL providing a PXR style interface to the Video32 DLL You must have both DLLs installed on your 3 5 Chapter 3 Programming the PXR800 computer even though the Visual Basic interface is only with PXR800_Display DLL The Video Display Library requires no initialization and provides only one operation copying an arbitrary rectangle of an image frame onto an arbitrary rectangle of a window s client area through the following two functions e IMG VB SizeDisplayWindow This function tells the DLL the size of the client area of the display window e IMG VB PaintDisplayWindow This function performs the copy from the image frame to the client area of the window When using the Video Display Library always include the PXR800_Display BAS file in your Visual Basic project All of the samples for Visual Basic use the Video Display Library and serve as good examples but you ll probably find PXR_VB_Grab_RT is the easiest Including BAS Files In order to reference the PXR800 Visual Basic DLLs you must in
139. l blocks of the PXR800 are shown in Figure 1 2 on page 1 6 The Camera Interface function is shown in the upper left of Figure 1 2 Up to four video cameras can be connected to each PXR800 Notice that there are also facilities for pixel clock horizontal sync and vertical sync inputs from the camera This allows for using different camera sync schemes Additionally the PXR800 has an internal pulse generator that can provide hor izontal and vertical sync signals to the camera via the same Hsync and Vsync lines This allows the PXR800 to control camera synchronization and gen lock cameras if necessary Terminations for the video input are provided in the camera interface The ter mination value can be selected under program control to be either the stan dard 75 Q video termination or a high impedance termination The camera interface function also includes a Video Signal Multiplexer Under application program control the multiplexer can be switched to supply the PXR800 with a video signal from any one of up to four cameras The PXR800 is designed to automatically synchronize to the current incoming video signal whether by embedded composite sync information or via external sync infor mation on Hsync and Vsync Syne modes can also be controlled by the appli cation program to meet different video capture requirements 1 5 Chapter 1 Introduction VIDEO HARDWARE 1TO4CAMERAS amp o okoo ff BZ OUTSIDE WORLD woos o eee 4 INPUT amp
140. l s As Integer As Boolean Parameters i always zero sS always zero Return Value False on failure True on success Description The PXRVB_OpenLibrary function opens a library to provide access to PXR800 API functions The function also opens any associated device driver files This library is a DLL The function fails returning False if the library cannot be found or the param eters are invalid 8 8 Initializing and Exiting Libraries Chapter 8 PXRVB_CloseLibrary PXRVB CloseLibrary ByVal i As Long Parameters i always zero Return Value None Description The PXRVB_CloseLibrary function closes the PXRFrame library and releases any resources that were opened with the corresponding call to PXRVB_OpenLibrary Programs must not access any library functions after the library is closed Doing so will result in an invalid function call and might cause a General Pro tection Fault 8 9 Chapter 8 Initializing and Exiting Libraries This page intentionally left blank 8 10 PXR800 API Functions Chapter 9 Chapter 9 PXR amp 800 API Functions This chapter is an alphabetical function reference for the Imagenation PXR800 Frame Grabber library The reference page for each function gives the func tion syntax for the C language and for Visual Basic The C syntax is always given first followed by the Visual Basic syntax Each Visual Basic function has the same name as its corresponding C function but with
141. le sequence and stop any value except ES OFF RP_ CONTINUOUS The RTC will generate a sequence every time the event described by pesEvent occurs ES OFF RP_ CONTINUOUS An RTC sequence has started but the RTC will stop when the sequence is complete because con tinuous mode has been turned off Table 9 5 pesEvent and preRepeat Values This function will not return until all queued operations have completed Chapter 9 PXR800 API Functions GetRTCStart continued See Also RTCStart SetRTCTiming GetRTCTiming ResetRTC 9 24 PXR800 API Functions Chapter 9 GetRTCTiming DWORD GetRTCTiming FGHANDLE fgHandle REALTIME prtRealTime PXRVB GetRTCTiming ByVal fgHandle As Long ByRef prtRealTime As RealTime As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG prtRealTime is the address of the real time programming data Return Value Returns a non zero value on success zero on failure Description The GetRTCTiming function returns the RTC values currently programmed into the PXR800 frame grabber This function will not return until all queued operations have completed See Also SetRTCTiming ResetRTC RTCStart GetRTCStart REALTIME Structure on page 7 5 9 25 Chapter 9 PXR800 API Functions GetSyncMode IMG SYNCMODE GetSyncMode FGHANDLE fgHandle IMG CAMERA icCamera PXRVB GetSyncMode ByVal fgHandle As Long ByVal icCamera As Long
142. led before the frame is freed if the frame is being used for a current Grab This assures that the grabber will stop delivering any data into the PXR800 buffer memory before the buffer is released See Also AllocateBuffer FrameFromPointer 10 14 PXRFrame API Functions Chapter 10 GetColumn DWORD GetColumn PXRFRAME pFrame void pvBuffer DWORD dwColumn FRAMEVB GetColumn ByVal pFrame As Long ByRef pvBuffer As Any ByVal dwColumn As Long As Long Parameters pFrame is the address of a PXRFrame pvBuffer is the address of the target buffer dwColumn is the column number of the frame from which to copy the pixels Return Value The return is non zero on success zero if failure Description The GetColumn function copies a column of an image from a frame into a buffer The columns are numbered starting with zero at the left of the frame The buffer is assumed to be an array of the correct type to hold the column of pixels If the entire column won t fit in the memory pointed to by pvBuf fer undefined behavior and data corruption might result The function will fail if the specified column is outside the boundaries of the frame or if the frame can t be read 10 15 Chapter 10 PXRFrame API Functions GetPixel DWORD GetPixel PXRFRAME pFrame void pvBuffer DWORD dwColumn DWORD dwRow FRAMEVB GetPixel ByVal pFrame As Long ByRef pvBuffer As Any ByVal dwColumn As Long ByVal dwRow As Long
143. ll not return until all queued operations have completed See Also SetGainRange GetFineGain SetFineGain 9 13 Chapter 9 PXR800 API Functions GetinterlaceMode 9 14 IMG VIDEO FORMAT GetInterlaceMode FGHANDLE fgHandle PXRVB GetInterlaceMode ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value Returns the currently selected video format e FORMAT INTERLACED e FORMAT PROGRESSIVE e FORMAT INVALID on error Description The GetInterlaceMode function returns the format of the images arriving from the camera as programmed by SetInterlaceMode The grabber does not innately know whether the image is interlaced or progressive scan because it can accept images from non standard cameras It is up to the appli cation to inform the grabber as to the image format to expect from the camera This function will not return until all queued operations have completed See Also SetInterlaceMode SetVideoFrameSize GetVideoFrameSize Table 9 3 on page 9 11 PXR800 API Functions Chapter 9 GetLUT DWORD GetLUT FGHANDLE fgHandle DWORD dwFirstIndex DWORD dwLength BYTE pbLUT PXRVB GetLUT ByVal fgHandle As Long ByVal dwFirstAddress As Long ByVal dwLength As Long ByRef pbLUT As Byte As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwFirstIndex is the first index of the LUT to retrieve valid range 0
144. lt TTL compatible Optically Isolated Input Protection Optical isolation to 40 V On voltage 3 V typical Max voltage 10 V between High and Low Max current 10 mA Caution Do not connect the TTL and Optically Isolated versions of any trigger simultaneously 6 3 Chapter 6 Hardware Reference TTL TRIGGER TRIG OPTO TRIGGER HIGH OPTO TRIGGER LOW Figure 6 3 Trigger Input Schematic Environment Operating temperature 0 to 60 C Power 5 V DC 700 mA Cables and Connectors Pre Made Cables Imagenation offers pre wired cables in two versions as shown in Table 6 1 Part Number CB 081 Full Use Cable CB 082 Video Trigger Only Cable Table 6 1 Pre Wired Cables The Full Use cable provides access to each of the signals on the PXR800 26 pin connector for easy prototyping and experimentation All signals are made available on BNC connectors except 12 V power which is provided on a 2 5 mm inside diameter female power plug and the optically isolated trigger 6 4 Hardware Reference Chapter 6 signals which are on a 3 pin female DIN connector Table 6 2 lists the con nections for the DIN connector Optically isolated trigger high No connect Optically isolated trigger low No connect Table 6 2 DIN Connector The Video Trigger Only cable provides only the video input and TTL trigger input each on a BNC connector Connector Pinouts You can also make your own cables
145. m frame historically derives from the series of image frames captured on celluloid film by motion picture cameras And as with motion pictures rapid sequential capture and display of video frames provides a moving picture of whatever is occurring in the video camera s field of view The PXR800 provides a means of capturing or grabbing video frames individ ually or in a series as they are output from a video camera Exactly how frames are grabbed and processed depends on various factors These factors include the video standard being used as well as captured image quality and the intended use or image analysis goals of the application Equally important in many industrial applications is the region of interest ROD within the video frame Region of Interest ROI Basics In applications such as inspection the item being inspected is the object of interest Where possible the video camera should be positioned or adjusted so that the object fills the image frame However this might not always be 5 1 Chapter 5 Detailed Operating Information possible Perhaps the camera cannot be moved or perhaps a wider field of view is necessary to account for uncertainty in object position The result is that the object of interest occupies a subset of the complete field of view In such cases the frame grabber can transfer a region of interest ROD encom passing just the object of interest This ROI is simply a rectangular portion of the full
146. mand is called with several parameters that control capture timing and triggering For this pro gram the values used are initialized in the following lines of code pxr_trigger c lines 171 176 deal LZ LYS 174 LYS LIE dwDelTime 0 no delay geStart GE ON VSYNC AFTER TRIGGER a triggered grab bSwitchToTrigger FALSE switch cameras on trigger Systane SV Brika DIELD start grelo on elther field flFields FL FRAME grab a whole frame iwWhen IW G EVED Queued grab to complete later In addition to calling the AppIdle function the main loop dispatches mes sages to the window procedures for the application s windows In many appli cations some window messages indicate conditions that require calling frame grabber functions This can be done by directly calling PXR800 functions inside the message handler by setting flags in global variables that tell AppIdle to make changes when it next runs or by a combination of the two For this particular program the only message that needs special handling is WM PAINT The image displayed in the window is the same as the image stored in gpFrame so when a WM_PAINT occurs the program simply redraws the window from the current contents of the frame as shown in the following code 3 21 Chapter 3 Programming the PXR800 pxr_trigger c lines 406 411 406 407 408 409 410 411 3 22 case WM PAINT re
147. mera 0 Figure 4 3 Main Control Dialog Box Loading a Previously Saved Program Configuration Clicking Read File loads a previously saved configuration Loading a previ ously saved configuration sets the PXR800 and all of the dialog boxes in the PXR Productivity Tool to that previous state 4 5 Chapter 4 The PXR Productivity Tool Writing Code and the PXR Productivity Tool The PXR Productivity Tool does not write or generate code However it does show you how the code for your PXR800 software application should be writ ten Each dialog box implements a small number of API commands The parameters for each command are implemented as radio buttons check boxes or edit boxes Once you have set up a particular dialog box to do what you want the code you need to write to do the same thing will be obvious 4 6 Detailed Operating Information Chapter 5 Chapter 5 Detailed Operating Information This chapter describes various operational features of the Imagenation PXR800 and key issues to consider in image capture and manipulation Image geome try image manipulation and quality real time control data flow and image data storage are covered Image Geometry Video cameras capture and transmit images in a variety of formats and resolu tions Their basic function however is to capture whatever is in their field of view as a series of snapshot images By convention each snapshot image is referred to as a frame The ter
148. n and any directory in the system s PATH environment variable Check that no other programs are running that have the frame grabber allocated Each frame grabber can be used by only one application at a time If you have just installed or updated the PXR800 software try shutting down and restarting the system to be sure any changes to the drivers DLLs and registry have taken effect Technical Support Imagenation offers free technical support to customers If the PXR800 board appears to be malfunctioning or you re having problems getting the library functions to work please read the appropriate sections in this manual If you still have questions contact us and we ll be happy to help you When you contact us please make sure that you have the following informa tion available A detailed description of the problem you are having including the exact text of any error messages and a list of steps to reproduce the problem The serial number of your board This number is printed on a sticker attached to the PXR800 board The revision number of your board This can be found by running the PXR_Grab_rtl sample program The operating system you re running The compiler you re using including the version number for example Microsoft Visual C 6 0 Information about your computer including manufacturer CPU type and memory size The Imagenation site on the World Wide Web is an excellent source for up to date t
149. n application may have one thread that controls the frame grabber and another that analyzes images The control thread can queue Grab commands and pass the QUEUEID to the analysis thread The analysis thread can then use the WaitFinished function to block it s execution until there is a complete image available to be analyzed Although a QUEUEID is not a Win32 object each queued operation can have a Win32 Event object associated with it The WindowsEventFromQID func tion provides a handle to the Win32 event for a particular queued operation This event is a manual reset event that is signaled when the queued operation completes or is canceled Using the event handle for a queued operation is often more convenient than using the QUEUEID directly in programs that are already using Win32 synchronization objects to control program execution or that need to synchronize window message handling and file I O to frame grabber operations PXRFRAME structures can be shared between threads by simply sharing the pointer supplied by AllocateBuffer PXRFRAMEs should not be shared between processes however since they contain pointers that are only valid in the memory space of the process that created them It is possible to share image data between processes however This should be done by first creating a shared memory area using a memory mapped file for instance and then having each process create it s own PXRFRAME for that memory using the FrameFromPoi
150. n be cast to the appropriate pixel type for the frame 10 7 Chapter 10 PXRFrame API Functions FrameFromPointer PXRFRAME FrameFromPointer void pBuffer DWORD dwWidth DWORD dwPitch DWORD dwHeight DWORD ptType BOOL bImageInfo Function does not exist for Visual Basic Parameters pBuffer is a user supplied buffer dwWidth is the width of the image within the buffer measured in pixels The num ber of pixels must be a multiple of four If it is not the width will be rounded down dwPitch is the width of the buffer in bytes This must be at least wide enough to hold the width of pixels or the function will fail dwHeight is the number of rows in the image ptType is the pixel type of the image e PEITS Y8 e PBITS RGB24 e PBITS_ RGB16 e PBITS RGB32 bImageInfo This value is TRUE if the buffer is large enough to contain the image and the time stamp information This value is FALSE if the buffer is large enough to contain only the image Return Value The address of the aliased frame buffer NULL if failure Continued on the following page 10 8 PXRFrame API Functions Chapter 10 FrameFromPointer continued Description The FrameFromPointer function creates a PXRFrame structure which uses pBuffer as its image buffer It is the application s responsibility to assure that pBuffer is large enough to contain the image and also the time stamp infor mation if bImageInfo is TRUE The size of
151. n in video images Blur magnitude in pixels B VP TE NP FOV Detailed Operating Information Chapter 5 Where B blur in pixel VP object velocit FOV field of view size in direction of motio TE exposure time in second NP number of pixels across the field of view Exposure time TE for a blur of one pixel TE FOV VP NP Generally blur is thought of as being the result of the subject image moving during frame exposure However blur can also be caused or increased by camera movement during frame exposure Thus it is also important to con sider camera mount stability in resolving image blur problems A loose camera mount combined with production environment vibrations can be the source of significant image blur Reducing movement of the object in the camera s field of view will of course reduce blur But reducing object movement might not be practical in a high speed production environment A better solution might be to reduce image exposure time TE This can be done by using an electronically shuttered camera or by using strobed illumination of the object For either case the PXR800 provides exposure control lines and strobe trigger lines These can be set up and controlled using SetRTCTiming and RTCStart Note It is important to avoid confusing camera related issues with motion blur Camera focus camera stability and the condition and cleanliness of camera lenses can all affect image sharpness a
152. nd quality Gain and Offset As indicated in Figure 5 4 on page 5 9 the incoming video signal can be conditioned by gain offset and fine gain adjustments These adjustments are done via software with SetGainRange SetOffset and SetFineGain The order in which these adjustments are made to the video signal is gain range first then offset and lastly fine gain SetGainRange SetOffset and SetFineGain can all be queued By proper queuing the gain and offset values can be updated between two image grabs without skipping any fields of image data 5 13 Chapter 5 Detailed Operating Information 5 14 SetGainRange is applied to the video signal prior to the ADC see Figure 5 4 on page 5 9 It is an analog adjustment designed to compensate for low video signal levels It has two settings zero and one For normal video levels of 1 Volt peak to peak the gain range should be set to zero When set to one the input video is amplified by a factor of two before being digitized This allows full grayscale resolution for signals of approximately 1 2 Volt peak to peak Note The maximum input level for the ADC is 1 Volt peak to peak Gain adjustments that cause the video signal to exceed this maximum ADC input should be avoided Signals exceeding the maximum input level will be clipped SetOffset allows programmable offset of the digitized video signal in 256 even steps of the video dynamic range Valid offset values ar
153. needs the clock to match the local time of day the PXR800 clock should be set accordingly with the SetTime function The field count information is derived by counting the number of vertical syncs that have been detected and the field per second count is the vertical syncs detected since the PXR800 clock s seconds value last changed Because the PXR800 clock isn t synced to the camera there is a small probability that the field count for a given second will differ from the expected count by a value of one This can occur even though the camera is producing stable video at the correct rate Frame Library Features PXRFrame Library capabilities include graphic format changes selective accessing of portions of the image and creating a PXRFrame from any piece of system memory having the right size Images can be loaded and saved in BMP and PNG formats or as unformatted binary data Bin format The uncompressed 8 bit and 24 bit BMP formats are supported and PNG 8 16 24 and 32 bit formats are supported Data can be selectively copied into or out of the PXRFrame s image Selection can include rectangles rows columns or single pixels A PXRFrame can be created from memory supplied by the application pro gram using the FrameFromPointer function The FrameFromPointer function uses the supplied memory as its buffer rather than actually copying 5 43 Chapter 5 Detailed Operating Information 5 44 the data If t
154. ng Information Chapter 5 plish this the LUT could be loaded with zeros in the lowest 30 locations When this is done any dark pixel with a value less than 30 is translated to zero This makes the darker regions of the image completely black value zero making it much easier to detect regions above the threshold value of 30 To disable the LUT you can make it transparent by loading it with values from zero to 255 in numerical order 0 1 2 255 Reversing the numerical order 255 254 253 0 produces a negative image Changing LUT entries is done with the SetLUT function The dwFirstIndex argument specifies the first entry to be changed 0 255 and dwLength 1 256 is the length of LUT entries to set The entire LUT can be changed or any selected segment can be changed Since the table is read from the start of the pbLUT buffer the buffer must have at least dwLength entries or an Overrun error may occur Updates to the LUT affect the incoming image immediately This may result in an image with old LUT values applied to part of the image and new LUT val ues applied to the rest of the image For more information on this situation see Coherency Issues on page 5 37 Uses for the LUT including those already mentioned are e Gamma correction to compensate for nonlinearities in the camera signal or in the monitor on which the image is displayed e Binary thresholding to separate objects from a background e Palett
155. ngle parameter are better implemented as edit boxes with spinners than as radio buttons The Gain Offset dialog box includes good examples as shown in Figure 4 2 The SetFineGain and SetOffset controls are implemented as edit boxes with spinners but still are sent to the PXR800 and generate feedback as soon as you change the values Gain Offset E xj Seth yquistFilter i F_HIGH_FREG_ON IF NONE SetGanA angel a ci SetFineG aint ize SetOffset 0 Take effect immediately Figure 4 2 The Gain Offset Dialog Box The PXR Productivity Tool Chapter 4 Saving PXR800 Configurations with the PXR Productivity Tool The PXR Productivity Tool lets you save and retrieve previously saved PXR800 frame grabber configurations including e Dialog box positions e Current program state You can use this feature to save important setup information or work to be finished later Saving The Current Program State When you click Save File in the Main Control dialog box the PXR Productiv ity Tool saves its current state The files are saved with a default PXR exten sion PXR Productivity Tool Main Control Window E xj Reset FSA o Read File Save File ESR Setup Functions i i Frame Size RATC Timing Drive Mode Trigger RTC Start Stop Sync Mode Pal Gain Offset Termination Acquire Configure Camera f Start Display Stop go os a ra About Curent Ca
156. nt in a high performance machine vision system In this environ ment it not only captures high quality video images but it can also address the many synchronization and control issues that occur in a modern machine vision system The following introductory information provides an overview of machine vision systems and how the PXR800 fits into the machine vision environment Video and Machine Vision Systems Traditionally analog video sources including video cameras VCRs and the like have been designed to represent movement by producing a continuous stream of image signals The video signal formats used were designed to emphasize the perception of moving scenes often at the expense of accuracy in the image s fine detail These traditional video sources were intended solely for providing human viewers with a convincing representation of moving scenes Fortunately the human eye and mind is able to participate in the pro cess by mentally filling in or accepting implied detail to add realism to what is viewed Today video is increasingly being used for machine vision applications How ever the emphasis in machine vision is on the accuracy of individual images in the video image stream In this arena the goal is not to provide an illusion of moving scenes to a human viewer but to provide high quality image data for computer processing and analysis For example the computer in a machine vision system will often be responsi ble for f
157. nter function 3 3 Chapter 3 Programming the PXR800 3 4 Programming Language Specifics This section discusses specific information about writing programs in C and in the Microsoft Visual Basic programming environment Programming in C When one of the DLLs is opened by calling imagenation_OpenLibrary the functions it supplies are not made available as global symbols Instead the application program supplies a structure that is filled with pointers to the func tions Because these function names are not global symbols they do not con flict with function names from other parts of your program For instance suppose your program uses an image processing library that happens to con tain a function named GetRectangle The PXRFrame library also contains a GetRectangle function but because the PXRFrame functions are members of a structure they can coexist with other functions of the same name The structure holding the function pointers to the opened library can be thought of in terms of object oriented programming as an object representing the library This library object is created by the imagenation_OpenLibrary call and is destroyed by the imagenation_CloseLibrary call While the library object exists it provides a set of methods for manipulating frame grabbers and image memory Because the programming interface is callable from C the library interface is not represented as a C class although the syntax for using it is sim
158. o copy the pixel Return Value The return is non zero on success zero if failure Description The PutPixel function copies the pixel from pvPixel into the frame at dwColumn dwRow where 0 0 is the upper left corner of the frame The buffer is assumed to be large enough to hold the pixel If the pixel is of the correct type undefined behavior and data corruption may result The function will fail if the specified coordinate is outside the boundaries of the frame or if the frame can t be read 10 22 PXRFrame API Functions Chapter 10 PutRectangle DWORD PutRectangle void pvBuf PXRFRAME pFrame DWORD dwColumn DWORD dwRow DWORD dwWidth DWORD dwHeight FRAMEVB PutRectangle ByRef pvBuf As Any gt ByVal pFrame As Long ByVal dwColumn As Long ByVal dwRow As Long ByVal dwWidth As Long ByVal dwHeight As Long As Long Parameters pvBuf is the address of the source buffer pFrame is the address of a PXRFrame dwColumn is the column number of the frame into which to copy the pixels dwRow is the row number of the frame into which to copy the pixels dwWidth is the width of the rectangle in the frame into which to copy the pixels dwHeight is the height of the rectangle in the frame into which to copy the pixels Return Value The return is non zero on success zero if failure Description The PutRectangle function copies a rectangle of the data into the frame s image The upper left corn
159. ock can be changed with SetPixelClock This function will not return until all queued operations have completed Continued on the following page 9 18 PXR800 API Functions Chapter 9 GetPixelClock continued Pixel Clock Name Frequency Co dth ea eh ngth PCLOCK_NTSC_SQUARE 12 2727MHz 780 Clocks 262 1 2 or 525 lines PCLOCK_CCIR_SQUARE 14 75 MHz 944 Clocks 312 1 2 or 625 lines PCLOCK_NTSC_RECTANGLE 13 5 MHz 858 Clocks 262 1 2 or 525 lines PCLOCK_CCIR_RECTANGLE 13 5 MHz 864 Clocks 312 1 2 or 625 lines PCLOCK EXT synced to ris None None ing edge of PCL synced to fall None None LOCK EXT INVERTED f a een ing edge of PCL The default line width and field length are used when the drive mode is not DRIVE_DISABLED see SetDriveMode In this mode the timing of horizontal and vertical drive pulses is based on the pixel clock setting The shorter field length is used in interlaced mode and the longer length is used in progressive mode see SetInterlaceMode The external pixel clock and vertical and horizontal drive cannot be used together so there is no default width or length in the modes that use an external pixel clock Table 9 4 Pixel Clock Information See Also SetPixelClock Table 9 3 on page 9 11 9 19 Chapter 9 PXR800 API Functions GetROI DWORD GetROI FGHANDLE fgHandle DWORD pdwROILeft DWORD pdwROITop DWORD pdwROIWidth DWORD pdwROTHeight PXRVB GetROI B
160. of the four triggers can be chosen as an event source independent of which camera is selected Trigger events can also control which camera is selected via SetRTCTiming However individual triggers cannot be associated with types of events Pulse Generation Event Detect shown in Figure 5 9 on page 5 24 can be used to initiate pulses or pulse sequences for the Exposure Exp1 amp Exp2 and Strobe lines at the camera interface The time of the Exposure and Strobe pulses can be programmed using SetRTCTiming Pulse sequences start when events such as triggers vertical sync or software commands are detected by Event Detect The rate at which the pulse generators run is based on the horizontal timing from Syne Control The horizontal line interval H is the basic unit of timing see Figure 5 8 on page 5 19 For RS 170A video H is 63 5 psec For CCIR PAL H is 64 psec All pulse generation and some RTC events are timed using HalfH It should be noted that HalfH is only a stable time unit if the active camera is producing stable video Also camera switches can cause HalfH instability Strobe Exp1 and Exp2 are all identical general purpose pulse generators with the same event timing There are four wires connected to each of these sig nals one for each camera connector You can use these pulses to reset cam eras control camera exposure or to control external equipment such as strobe lights An Exp0 is also available But
161. om an interlaced camera without any special triggering 3 11 Chapter 3 Programming the PXR800 26 28 30 3i 22 33 34 35 3 12 Line by Line Explanation continued FrameLib WriteBMP pFrame TEST BMP TRUE The frame library provides several utility functions for working with images once they are captured In this case the image is saved to a file in BMP for mat MessageBox NULL Grab saved to TEST BMP Done MB OK MessageBox is a Win32 function that displays some text in a simple dialog box If we didn t do this the program would never display anything to the screen This gives the user some indication that something really happened when the program was run PXR FreeFG hFG FrameLib FreeFrame pFrame imagenation CloseLibrary amp FrameLib imagenation CloseLibrary amp PXR return TRUE Before the program finishes running every resource that was allocated should be freed The frame grabber is released using FreeFG the memory allocated to the frame structure is released using FreeFrame and finally the libraries are closed Closing the libraries must be done after the other functions because FreeFG and FreeFrame are functions from the PXR800 and PXRFrame libraries and functions from a library shouldn t be called after the library is closed In general any resources such as memory and frame grabbers that a program has allocated will be freed by Windows wh
162. on 2 A polymeric resettable fuse Note 12 Volt power is available only if the board s power connector has been connected to the computer s power supply 6 1 Chapter 6 Hardware Reference VS and HS Used as Sync Inputs Input Protection Diode clamped between ground and 5 V 100 Ohm series resistance Input Levels 3 3 V CMOS thresholds 5 V compliant Used as Drive Outputs Output Levels 5 V CMOS 30 mA max current 1 0 Signals Input Protection Diode clamped between ground and 5 V 100 Ohm series resistance Input Levels 3 3 V CMOS thresholds 5 V compliant Output Levels 5 V CMOS All four GP Input lines see Figure 6 1 are wired together after 100 Ohm series resistors All four GP Output lines see Figure 6 2 on page 6 3 are driven by the same 5 V CMOS driver Each Strobe and Exposure output has a separate 5 V CMOS driver 100 Q 5 CAMERA 0 CAMERA 1 GPIN CAMERA 2 CAMERA 3 Figure 6 1 GP Input Schematic 6 2 Hardware Reference Chapter 6 5 CAMERA 0 wa CAMERA 1 GPOUT CAMERA 2 CAMERA 3 Figure 6 2 GP Output Schematic Pixel Clock Internal Clock Frequency 12 2727 MHz 13 5000 MHz 14 7500 MHz External Clock Frequency 12 27 MHz to 14 75MHz Input Levels 3 3 Volt CMOS thresholds 5 V compliant Input Impedance 15K Ohm Triggers See Figure 6 3 on page 6 4 TTL Input Protection Diode clamped between ground and 5 V 100 Ohm series resistance Input Levels 5 Vo
163. one if the operation is finished Returns zero if the operation has not completed DW ERROR on failure Description The IsFinished function checks the PXR800 queue and determines whether the operation has completed This allows an application to receive notification when an operation completes so that the application can con tinue with foreground processing If qi ID is QI_ ALLQUEUE the function checks to see if any operations are queued In this case the return value is one only if the queue is empty See Also WaitFinished TimedWaitFinished WindowsEventFromQID 9 41 Chapter 9 PXR800 API Functions KillQueue 9 42 DWORD KillQueue FGHANDLE fgHandle PXRVB KillQueue ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value Returns a non zero value on success zero on failure Description The KillQueue function aborts any queued operations for the specified frame grabber Any operations in the queue when this function is called are removed This function may take several milliseconds to execute See Also ResetFG FreeFG WaitFinished IsFinished PXR800 API Functions Chapter 9 Mics ToHalfH DWORD MicsToHalfH FGHANDLE fgHandle DWORD dwMicroseconds PXRVB MicsToHalfH ByVal fgHandle As Long ByVal dwMicroseconds As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwMicroseconds is th
164. ong ByVal szFilename As String As Long Parameters pFrame is the address of a PXRFrame szFilename is the name of the file to read Return Value SUCCESS the file was read successfully FILE OPEN ERROR the file could not be opened BAD READ an error occurred while the file was being read INVALID FRAME the frame pointer is invalid Description The ReadPNG function reads a file in PNG format into the specified frame If the frame is not large enough to hold the image the right and bottom edges of the image are discarded 10 27 Chapter 10 PXRFrame API Functions WriteBin DWORD WriteBin PXRFRAME pFrame char szFilename BOOL bOverwrite FRAMEVB WriteBin ByVal pFrame As Long ByVal szFilename As String ByVal bOverwrite As Boolean As Long Parameters pFrame is the address of a PXRFrame szFilename is the name of the file to write bOverwrite is TRUE if the file can be overwritten if it already exists is FALSE if it cannot be overwritten Return Value SUCCESS the file was written successfully FILE EXISTS the file already exists but bOverwrite was FALSE FILE OPEN ERROR the file could not be opened BAD WRITE an error occurred while the file was being written INVALID FRAME the frame pointer is invalid Description The WriteBin function writes the image in the frame into the specified file No information about the image height width or pixel depth is written only the
165. ong ByVal szFilename As String ByVal bOverwrite As Boolean As Long Parameters pFrame is the address of a PXRFrame szFilename is the name of the file to write bOverwrite is TRUE if the file can be overwritten if it already exists is FALSE if it cannot be overwritten Return Value SUCCESS the file was written successfully FILE EXISTS the file already exists but bOverwrite was FALSE FILE OPEN ERROR the file could not be opened BAD WRITE an error occurred while the file was being written INVALID FRAME the frame pointer is invalid Description The WritePNG function writes the image in the frame into the specified file in the PNG format If the file already exists and bOverwrite is FALSE this function returns an error otherwise the contents of the file are overwritten WritePNG opens and closes the file 10 30 The Video Display Library Chapter 11 Chapter 11 The Video Display Library The process of displaying video in a window using the Microsoft Visual Basic development environment is a bit cumbersome To simplify that process the PXR800 software support for Visual Basic includes a Video Display Library that consists of the following two DLLs e PXR800_Display DLL e Video32 DLL The DLLs operate as a pair with the PXR800_Display DLL providing a PXR style interface to the Video32 DLL You must have both DLLs installed on your computer even though Visual Basic interfaces only with PXR800_
166. pOffset dwWidth dwHeight IW WAIT return TRUE This camera detection method correctly handles CCIR RS170 and most CCIR and RS170 rate progressive scan cameras It will not handle many asynchro nous cameras because the GetFieldLength function returns meaningful values only for cameras that continuously output images Any resettable cam era that produces an image only in response to an event signal cannot be set up using this method This method also cannot detect the difference between the square pixel and rectangular pixel clock rates for RS170 or CCIR The routine above assumes 640 pixel lines for RS170 and 768 pixel lines for CCIR Cameras that are designed to support the 720 pixel versions of these modes will not have the pixel clock set correctly resulting in images with incorrect aspect ratios Programming the PXR800 Chapter 3 Handling Stalled Grabs The Grab function completes when it has captured an image from the current camera If there is no camera connected or if the current camera is not trans mitting video no image will be received and the Grab will never complete If a program does not take any action to handle these conditions it may stall forever waiting for a Grab that cannot finish One way to detect and handle stalled Grabs is to use the IW_QUEUED option to add the Grab to the frame grabber s queue and then use TimedWaitFinished to wait for the Grab to complete The TimedWaitFinished function ac
167. paint video window hDC BeginPaint hWnd amp ps ShowFrame gpFrame hDC dwImageX dwimageyY EndPaint hWnd amp ps reran OF One important point about the way AppIdle is used is that when the main loop finishes there is usually a Grab operation still waiting in the queue Before terminating the program this should be dealt with In some cases the program can just wait for the queue to empty by calling WaitFinished but in this case we have no idea how long that could take It s better here to can cel the operation by calling the KillQueue function It is important to be sure either by waiting or by using KillQueue that any Grab operations that might be trying to use a PXRFrame have finished executing before calling FreeFrame Otherwise the Grab will attempt to write into memory that has been freed and might crash the program At this point you have seen several examples of how to use the PXR800 in simple applications The techniques presented here should provide a good starting place for designing your application The following chapters provide detailed information about the individual features of the frame grabber and a complete reference to all functions provided in the libraries Also the Imagenation website www imagenation com is frequently updated with additional sample programs and application notes The PXR Productivity Tool Chapter 4 Chapter 4 The PXR Productivity Tool The PXR Productivity Tool was
168. path to the DLL or just the name of the DLL If the name is provided without a path the system will search for the DLL using the normal search algorithm for locating DLLs For most applications this is a good thing to do because it means that the application program does not need to duplicate the operating system s logic for finding DLLs If a full path is provided the DLL will be loaded only if it appears in exactly the location specified Programming in Visual Basic This section discusses concepts procedures and cautions that are specific to the Microsoft Visual Basic development environment A new DLL is intro duced as well as a caution about terminating programs Support for Visual Basic began with version 1 4 of the PXR800 software If you have an earlier version you can download the latest software from the Imagenation website at Www imagenation com in the technical support section Caution Do not use the End button in the Visual Basic development environment to terminate your application If you do so and then try to restart your application the application will fail End prevents the program from de allocating the frame grabber which causes a frame grabber allocation failure when the program restarts Before terminating a program de allocate all PXR800 frame grabbers by using the PXRVB FreeFG function in the Form Unload procedure Using the End button bypasses Form Unload and all other procedures If you want the functional
169. pixels per line depends on the pixel clock rate Most video signals can be sampled at any pixel clock rate with corre sponding changes to the image width and aspect ratio The numbers listed here are common values that provide correct aspect ratios for common cam era geometries B Progressive scan camera formats are not as standardized as interlaced for mats Line counts for progressive scan cameras may differ from those given here C Frame Top is the value expected for the top parameter in the SetVideoFrameSize function This number is the count of lines between vertical syne and the tart of the image for a full frame D This is the value expected for the left parameter in the SetVideoFrameSize function It represents the number of pixel clocks between the leading edge of HSync and valid image data This number depends on the pixel clock frequency as well as on the camera s horizontal blank timing The best value for this parameter is likely to vary by a few pixels between camera models and might also vary somewhat because of analog effects such as delay in the Nyquist filter and other filtering that occurs in the cable Table 9 3 Camera Format Information See Also SetInterlaceMode GetInterlaceMode SetVideoFrameSize GetROI GetVideoFrameSize Table 9 3 on page 9 11 9 11 Chapter 9 PXR800 API Functions GetFineGain DWORD GetFineGain FGHANDLE fgHandle PXRVB GetFineGain ByVal fgHandle As Long As Long Parameters fg
170. play 3 19 exiting libraries 8 1 exposure 5 25 external sync drive 5 20 Index 2 F features of the PXR800 1 4 FGHANDLE 3 2 fine gain 1 7 5 14 flags 5 34 formats Bin 5 43 BMP 5 43 PNG 5 43 frame size setting 5 7 frames 5 1 functions initializing and exiting libraries FRAMEVB_CloseLibrary 8 7 FRAMEVB_OpenLibrary 8 6 imagenation_CloseLibrary 3 4 8 4 imagenation_OpenLibrary 3 4 3 5 8 2 PXRVB_CloseLibrary 8 9 PXRVB_OpenLibrary 8 8 functions PXR800 API AllocateFG 3 2 BlockGrabber 5 39 9 3 CheckError 9 5 FreeFG 9 6 GetCamera 9 7 GetContinuousBuffering 9 8 GetDriveMode 9 9 GetFieldLength 5 5 9 10 GetFineGain 9 12 GetGainRange 9 13 GetInterlaceMode 9 14 GetLUT 9 15 GetNyquistFilter 9 16 GetOffset 9 17 GetPixelClock 9 18 GetROI 9 20 GetRTCStart 9 22 GetRTCTiming 7 6 9 25 GetSyncMode 9 26 GetSyncPolarity 9 28 GetTermination 9 30 GetTime 9 31 GetTransferMode 9 32 GetTriggerEvent 9 33 GetVideoFrameSize 9 34 Grab 5 18 5 19 5 24 9 36 HalfHToMics 9 39 InvalidateGrabberBuffer 5 33 5 37 9 40 IsFinished 5 35 5 37 9 41 KillQueue 5 35 9 42 MicsToHalfH 9 43 ReadIO 5 28 9 44 ReadProtection 9 45 ReadRevision 9 46 ResetFG 5 36 9 47 ResetRTC 9 48 RTCStart 5 24 5 39 9 49 SetCamera 5 18 9 51 SetContinuousBuffering 5 28 5 31 9 53 SetDriveMode 5 19 5 20 5 22 9 54 SetFineGain 5 13 5 14 9 56 SetGainRange 5 13 5 14 9 57 SetInterlaceMode 5 5 5 21 5 22 9 58 SetLUT 5 17 5 36 9 59 SetNyquistFilter
171. plication must explicitly initialize each library After an applica tion no longer needs access to the libraries and before the program termi nates the application must exit the library This chapter describes how to initialize and exit libraries for the C and Visual Basic programming languages The PXR800 API is provided in two libraries The PXR800 API library Chapter 9 PXR800 API Functions on page 9 1 provides the functions for managing the PXR800 Frame Grabber The PXRFrame library Chapter 10 PXRFrame API Functions on page 10 1 provides the functions for creat ing accessing and releasing the buffers into which images are captured For additional information on initializing and exiting libraries see The Library Interface on page 3 1 and Programming Language Specifics on page 3 4 For reference information on the PXR800 API structures refer to Chapter 7 PXR800 API Structures on page 7 1 C Language Functions This section describes the C functions for initializing and exiting the PXR800 and the PXRFrame libraries e imagenation_OpenLibrary e imagenation_CloseLibrary 8 1 Chapter 8 Initializing and Exiting Libraries imagenation_OpenLibrary short imagenation OpenLibrary char file void iface short count Parameters file the name of a valid DLL that can provide an interface to functions for the PXR800 This can be a file name or a full pathname iface a pointer to a structur
172. ptically coupled to increase system reliability and reduce noise interference e Control and capture from up to four multiplexed cameras e Ability to either accept or generate external video sync signals The PXR800 can provide sync signals for easily gen locking up to four cameras The above features along with other PXR800 capabilities allow creation of applications that take the best advantage of high performance analog video cameras The PXR800 can flexibly synchronize to the camera and reliably cap 1 4 Introduction Chapter 1 ture high quality images It can accurately track both the absolute time of image capture and the time of the image relative to other events In addition to synchronizing to the camera timing the PXR800 can also act as a timing generator for controlling the camera or other equipment that needs to be syn chronized to the camera s timing such as lighting The PXR800 can also detect signals from other equipment and use them as a timing reference for the entire video capture process Overview of PXR800 Features and Operation The PXR800 is a PCI card that installs in a personal computer running any of the following versions of the Microsoft Windows operating system 98 98 SE Me NT4 2000 or XP It acts as an intermediary between the outside world of video imaging for machine vision and the computer system of image pro cessing and analysis This relationship and some of the key functiona
173. r Description The GetFieldLength function returns the field length in lines of the last video field including vertical blank and vertical sync for the specified frame grabber Until a full field from Vsync to Vsync has been detected by the grab ber this value will not represent the behavior of the camera If no video source is detected GetFieldLength returns zero The PXR800 assumes no video source is active if no horizontal sync is detected for more than 4096 pixel clock pulses or no vertical sync is detected for more than 4096 lines Interlaced video cameras can have field lengths that include a half line The GetFieldLength function returns the line count rounded down For exam ple GetFieldLength returns 262 for NTSC cameras which have 262 5 lines per field Refer to Table 9 3 on page 9 11 for a list of general camera timing informa tion Returns immediately Continued on the following page GetFieldLength continued Field Rate NTSC RS170 60Hz PXR800 API Functions Chapter 9 50Hz 30Hz Progressive 25Hz Progressive Interlace Yes Yes Image Width 640 or 720 768 or 720 Image Height 484 574 Lines Field 262 1 2 312 1 2 Vertical Blank 20 25 Frame Top 35 46 115 12 2727 MHz or 13 5000 MHz 155 14 7500 MHz or 13 5000 MHz Frame Left 12 2727 MHz 14 7500 MHz Pixel Clock A The image width number of
174. r is not trying to do anything that requires attention causing the loop to wait until another window message comes in If AppIdle returns FALSE this indicates that it is working on some frame grabber operation and would like to be called again soon to finish it When AppIdle returns FALSE the main loop will generally run as fast as AppIdle allows it to so the code inside AppiIdle should use some sort of delay to balance between system responsiveness and CPU usage If AppIdle returns quickly the system will be very responsive to messages but the main loop will use a lot of CPU time polling If AppIdle delays for a long time the CPU overhead of message polling will be lower but the system will respond to messages less promptly Programming the PXR800 Chapter 3 pxr_trigger c lines 186 200 186 187 188 189 190 Loa TIZ 193 194 15 LOG Le 198 19 200 for if PeekMessage amp msg NULL 0 0 PM REMOVE if msg message WM QUIT break TranslateMessage amp msqg DispatchMessage amp msqg else if AppIdle WaitMessage The AppIdle function cannot simply do a triggered Grab and return when the Grab finished because it may be a long time before the trigger occurs During that time the main loop needs to run so that window messages are properly handled This problem can be solved by using a queued Grab If the iwWhen parameter for the Grab is IW_QUEUED the grab operation will
175. r to system memory The Grab operation completes Unless the PCI bus or system memory is heavily loaded with other tasks the Grab typically completes early during vertical blanking prior to vertical sync starting the next image If there is a queued operation waiting to start it will start at this point which is usually early enough to capture the next image Single buffered incremental transfer mode is the easiest mode to use when processing of every frame is not the highest priority Since capture to the 5 31 Chapter 5 Detailed Operating Information 5 32 PXR800 buffer memory can only begin after Grab a Grab always gets the next image of the requested type to arrive from the camera This makes it eas ier to understand which trigger event is associated with a Grab Also there are no data coherency problems when settings are changed between Grabs Single buffered burst transfer mode causes the following sequence of events e The Camera End isn t capturing data until a Grab occurs e Grab begins executing e The Camera End waits for a vertical sync possibly qualified by a trigger event e Several Hsync periods after vertical sync image data begins arriving from the camera e As image data arrives it s digitized and written to the PXR800 buffer memory e Image data continues to be written to PXR800 buffer memory until the last line of the image has been written e The System End detects a complete image in
176. ra for mat selected by SetPixelClock Vertical timing is con trolled by the RTC using the Exp0 generator Table 5 2 Synchronization Modes 5 21 Chapter 5 Detailed Operating Information Some cameras expect drive signals that are close to the standard line and frame rates Additionally they lock to the drive signals only if they are stable over several field times Such cameras can be synchronized to each other by driving them all from the same drive line but the drive signals cannot be used to reset camera timing quickly Some cameras reset immediately to synchronize to the drive signals The external vertical drive signal can be used to control timing on these cameras On some cameras the width of the vertical drive pulse or the time between pulses also controls the exposure timing of the camera If you desire a stable drive signal where vertical drive matches the standard drive waveform use the DRIVE HD VD mode For a drive signal where you can control vertical drive timing to cause camera resets or other effects use DRIVE HD VEXPO and program the Exp0 pulse to match the desired vertical drive waveform An external pixel clock cannot be used in the DRIVE _HD_VD or DRIVE HD VEXPO modes This is because the PXR800 internally generates all of the timing see Table 5 3 Also all cameras attached to the PXR800 must be using the same mode DRIVE_HD_VD or DRIVE_HD_VEXPQO Default A Default Field Pixel Clock N
177. received from the camera 5 37 Chapter 5 Detailed Operating Information 5 38 InvalidateGrabberBuffer does nothing This would be the case for example during video signal vertical blanking The InvalidateGrabberBuffer function should be used after a series of one or more functions that cause image changes This eliminates incoherent image data by invalidating the buffer However if the series of image chang ing functions occurs between image captures there won t be coherency issues and the buffer will not be cleared by InvalidateGrabberBuffer This built in decision feature follows the desired goal of continuous buffering which is to grab valid coherent images in sequence as quickly as possible The following functions can cause image data changes resulting in coherency issues when using the continuous buffering mode e Grab if any parameters other than fgHandle pFrame and iwWhen are different from the next Grab e SetCamera e SetFineGain e SetGainRange e SetLUT e SetNyquistFilter e SetOffset e Wait if any parameters other than fgHandle and iwWhen are different from the next Grab You can also queue InvalidateGrabberBuffer Thus a sequence of queued operations that includes changes to image capture settings can also invalidate the buffer Inconsistent image data will be discarded without stalling the queue Some PXR800 API functions automatically invalidate the PXR800 buffer when they execute Therefore it
178. rectangle of 8 bpp pixels from a frame you could use code such as Buff1 7500 As Byte I FRAMEVB GetRectangle Frame Buff1 0 10 10 100 75 Writing Multithreaded Programs The PXR800 library is multithread safe Application programs can create multi ple threads that share access to the PXR800 frame grabbers in the system Some examples of where multiple threads can be useful include e Having one thread responsible for frame grabber control and another responsible for user interface message handling This allows the user interface to remain responsive even when frame grabber operations require a long time to execute without requiring the frame grabber thread to explicitly handle time outs and event polling e Having one or more worker threads that perform image processing on captured images e A system with several frame grabbers performing independent tasks could assign a separate thread to each frame grabber Resources such as frame grabber handles queue IDs and PXRFrames can be shared between threads When sharing a frame grabber between two or more 3 7 Chapter 3 Programming the PXR800 threads the threads must be designed so that one thread does not change frame grabber settings that the other thread is relying on For example if one thread calls SetROI to change the ROI on a frame grabber while another thread calls Grab the two operations will execute in different orders depend ing on how the system sche
179. rrent Program State ieiicssmeahiacdeaesasieiaaaaeieaiooanes 4 5 Loading a Previously Saved Program Configuration 4 5 Writing Code and the PXR Productivity Tool 0 4 6 Chapter 5 Detailed Operating Information ccscccccescsssssseeeeees 5 1 Image GEOMICEY oo cccccctesstncetatecnectereletaceretasetesevecaunteveceterererustes 5 1 Region of Interest ROD Basics sss ssnsjomisidannveadiiamnsdandanensciqnanpie 5 1 Cam ra POLL AUS aiid ouSiapsanilvincns nai oan rviva ionarishaiieln vs inbinia rye Uianwialiniaeon 5 2 The Pixel Clock eris inna E E A ARa 5 7 Set Video Frame SU esa vated ocean cecupuahquadexencnnetanrnae 5 7 ROI Details aioe koennen inaakisi 5 8 iv Table of Contents Image Manipulation and Image Quallity sscccccseees 5 9 Ternat sasra n rere rrreremrcn cry iver nant tn ree tere 5 9 Nyquist PINCH cciaiiuartiedininoieceiuinieiaciaduiliaast 5 10 Noise and Jittef See a ee oe ae oe ee ene ae ee ee eee ee 5 10 Gain and Oset said ava ysenirasrujiace eee EEE E A 5 13 LUT Look Up Table een poten ee Pee ern 5 16 Real Time Control RTO ccccccccscsccccccccccccccccecccccscees 5 17 C mera Sellet waiis ceases nawtiseieabantannrtideaitaneertabieeauadacipandan 5 18 Sync Control and Sync Modes ciciscsntsdisetrdserneaiaverocanseasannetannnne 5 19 Image Grabs airiem ea me A E RS 5 23 Trigger Events pics savisannnes vavieascnninraveseninndtremnasndidgentnndamint 5 23 Pi Se G
180. rt pExposures RTC_EXP1 plDefaultLevel PULSE LOW rt pExposures RTC_EXP1 pdwTick 0 20 rt pExposures RTC_EXP1 pdwTick 1 6 IME OW GOOSUSS RIC MPS sickle s74p t pExposures RTC_EXP2 plStartLevel PULSE LOW t pExposures RTC_EXP2 plDefaultLevel PULSE LOW pExposures RTC_EXP2 pdwTick 0 40 t pExposures RTC_EXP2 pdwTick 1 6 t pExposures RTC_EXP2 pdwTick 2 354 EXP1 TIMING MASK EXP2 TIMING MASK IW WAIT The pulse sequences for all Exp1 Exp2 and Strobe are started simultaneously by the event selected through RTCStart In the DRIVE_HD_VD and DRIVE_HD EXPO modes see SetDriveMode the PXR800 also generates horizontal and vertical drive pulses The internal sync timing is used in these modes and results in the line and field lengths listed in Table 5 4 NTSC Interlace 780 clocks HSyne 262 5 lines VSync NTSC Square Interlace 858 262 5 CCIR Interlace 944 312 5 CCIR Square Interlace 864 312 5 NTSC Progressive 780 525 NTSC Square Progressive 858 525 CCIR Progressive 944 625 CCIR Square Progressive 864 625 Table 5 4 Line and Field Lengths 5 27 Chapter 5 Detailed Operating Information General Purpose Input Output GPI O Eight separate wires are provided for GPI O four for input and four for out put The input lines are read only and their state can be read at any time with ReadIo The four output lines c
181. rting Under Windows NT go into the BIOS setup and disable Plug amp Play Operating System support Try removing other devices such as sound cards or network cards from the system to check for resource conflicts and incompatibilities This is particularly important if the computer contains legacy or ISA devices Try moving the PXR800 frame grabber to a different PCI slot Some resource conflicts and configuration problems affect only some of the computer s slots If you have more than one PXR800 installed try running first with only one PXR800 card installed Make sure the computer s power supply is large enough to support all the installed devices This is particularly important if the PXR800 is supplying power to one or more cameras There is an LED near the top edge of the PXR800 card If the PXR800 is working the light will blink green If the light does not blink it is likely the PXR800 board has been damaged To see the LED you must start your computer while the cover is removed 2 5 Chapter 2 Installing the PXR800 If sample programs don t run or report Unable to open the PXR Library Be sure the PXR800 frame grabber card is installed and seated properly in its PCI slot Be sure the files pxr800 dll and pxrframe dll are in a directory where the system can locate them These directories include the Windows Windows System or Windows System32 directories the same directory as the program you re trying to ru
182. ry the PXR800 library is called through a structure It is declared here and given the name PXR FGHANDLE hFG A PXR frame grabber is accessed using a frame grabber handle This handle is returned by the library when the grabber is allocated and must be saved and used later to specify the particular frame grabber to other library functions For this program the frame grabber handle will be kept in a global variable named hFG PXRFRAME pFrame NULL Images captured by the frame grabber are stored in PXRFrame structures A frame structure contains an array of pixels where the image will be placed along with some descriptive information about the image Frame structures are allocated using the PXRFrame library which returns a pointer to PXRFRAME This program will only be using a single frame structure and the variable pFrame points to it LA 12 Ly iis 20 22 24 25 Programming the PXR800 Chapter 3 Line by Line Explanation continued int WINAPI WinMain HINSTANCE hInstance HINSTANCE hPrevInstance char szCmdLine int iCmdShow Because this is program is a Win32 application it s entry point is named WinMain A program this simple could also be written as a Console applica tion using main instead Most real programs using the PXR800 will use Windows user interface features so a normal Win32 application is a more typ ical choice imagenation OpenLibrary pxr800 dl11 amp PXR sizeof PXRAPI
183. s 6 7 Table of Contents vi Chapter 7 PXRSOO API SOCIT asian aiaa 7 1 IMG_IMAGEINFO Structure cccccccccccccccccccccccccccccccsccces 7 2 REALTIME Structure seeooeeeoseeooecoossecsssosssecsseessssosssesssesssse 7 5 Chapter 8 Initializing and Exiting Libraries 00000000000000000000000000000 8 1 C Language Functions seeosecooesccsscosssecssecsssossseosseessseosse 8 1 Visual Basic Functions socseeccocsscsccosssecccsseccccssesccsssseecsssse 8 5 Chapter 9 PXR800 API Fimo isisisi riaa eaa aiaa ii 9 1 Chapter 10 PXRFrame API Functions sesecsccsoscsececsecscsesscsecesscssesesee 10 1 Chapter 11 The Video Display Library ssisssissississscrossssosssssssssscioussissssisss 11 1 VOW E E O E A E A ia l ea o Table of Contents List of Illustrations Chapter 1 Figure 1 1 Example of a Machine Vision System 1 2 Figure 1 2 PXR800 Functional Diagram sccccccsssssseeeeees 1 6 Chapter 4 Figure 4 1 The Frame Size Dialog BOX ccccccssssssseeecceeeees 4 3 Figure 4 2 The Gain Offset Dialog BOX ccccssssssseeccceeeeees 4 4 Figure 4 3 Main Control Dialog BOX ssseccsssecesesessseeeeees 4 5 Chapter 5 Figure 5 1 Region of Interest ROD ccccesssseecccesssceccceesseee 5 2 Figure 5 2 Interlaced Format siccsccssccsssscscsssscsssessessssccsscasasssccssnssss 5 3 Figure 5 3 Video Signal Diagrams
184. s Byte ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwFirstIndex is the index of the first value of the LUT to set valid range 0 255 dwLength is the number of LUT entries to set valid range 1 256 pbLUT is a pointer to an array that contains the LUT data It must be at least as long as dwLength The data is copied before SetLUT returns so pbLUT can be changed or freed before the queued operation finishes iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI INVALID on failure Continued on the following page 9 59 Chapter 9 PXR800 API Functions SetLUT continued Description The SetLUT function changes the values in the frame grabber s lookup table LUT Specifying dwFirstIndex and dwLength can change any subrange of the table The buffer must have at least dwLength entries or an overrun error might occur The table is read from the start of the pbLUT array See Also GetLUT 9 60 PXR800 API Functions Chapter 9 SetNyquistFilter QUEUEID SetNyquistFilter FGHANDLE fgHandle IMG FILTER ifFilter IMG WHEN iwWhen PXRVB SetNyquistFilter ByVal fgHandle As Long 7 ByVal ifFilter As Long ByVal iwWhen As Long As Long Parameters f
185. s a QueuelID returned from a queueable function dwMs is the number of milliseconds until the time expires Return Value Returns e 1 if the item has completed e 0 if the time has expired e DW_ERROR on error Description The TimedWaitFinished function waits for the completion of a queued request or waits until the timeout milliseconds have passed whichever comes first If qiID is QI_ ALLQUEUE this function will wait for the completion of all queued requests This function is useful to prevent the Grab event from stalling forever Should a trigger never occur the exact time the function returns in case of time out might be slightly later than requested Do not use the time required by this function as a precise time reference See Also IsFinished WaitFinished WindowsEventFromQID KillQueue 9 79 Chapter 9 PXR800 API Functions Wait QUEUEID Wait FGHANDLE fgHandle DWORD dwSkipVSyncs IMG GRABEVENT START geStart BOOL bSwitchToTrigger IMG START VSYNC svStart IMG FIELD LEN flFields IMG WHEN iwWhen PXRVB Wait ByVal fgHandle As Long ByVal dwSkipVSyncs As Long ByVal geStart As Long ByVal bSwitchToTrigger As Boolean ByVal svStart As Long ByVal flFields As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwSkipVSyncs is the number of Vsyncs to skip before waiting for the image geStart e GE ON VSYNC waits for an image qualified at
186. s a queue of operations started by API function calls that have queuing capability API function queuing is set by the specific function s IW _QUEUED or IW2_QUEUED flag For example Grab has an IMG WHEN parameter that can be set to IW WAIT or IW_QUEUED e When set to IW WAIT Grab execution is held off until all other queued requests are completed e When set to IW_QUEUED Grab is added to the queue and its actual execution will occur in the order of queued events When an operation is queued it returns a QUEUEID The QUEUEID is a num ber that identifies the queued operation so that its status can be checked later Queued operations are automatically executed in the order that they are requested Any function called with the IW_QUEUED or IW2_QUEUED flag returns very quickly This allows the application program to continue with other tasks while the requested operation waits to reach the top of the queue before running Functions called with the IW_WAIT or IW2_WAIT flag wait for all queued operations to complete before starting Then after completing the wait called function returns control to the application program Note IW_QUEUED and IW2_QUEUED are functionally identical to each other The same is true for IW_WAIT and IW2_WAIT Some functions such as ResetRTC can be set to bypass the queue and exe cute immediately Functions that can bypass the queue have an IW2_NOw flag As with other unqueued
187. s used in several of the sample programs provided with the SDK Camera Detect Sample Code from pxr_grab c lines 467 488 67 BOOL SetVideoParameters void 68 69 70 Wa 72 13 74 13 76 T7 78 719 80 81 82 83 84 85 86 87 88 DWORD dwFieldLength DWORD dwLeftOffset dwTopOffset dwWidth dwHeight IMG PIXEL CLOCK pcClock IMG VIDEO FORMAT vfFormat we don t know if there is any camera attached so we would prefer not to do any operations that depend upon the video stream We know that a field may take up to 40 ms with CCIR progressive We will wait for up to 2 fields in case we are switching into the middle of a field Sleep 80 now get the field length of the video on channel 0 dwFieldLength PXR GetFieldLength hFG use the field length to determine the video type and format switch dwFieldLength default return FALSE Programming the PXR800 Chapter 3 pxr_grab c lines 489 533 489 RS170 NTSC interlaced 490 case 262 491 case 263 492 pcClock PCLOCK NTSC SQUARE 493 vfFormat FORMAT INTERLACED 494 dwhefttOffset RS170 LEFT DEFAULT 495 dwTopOffset RS170 TOP DEFAULT 496 dwWidth RS170 WIDTH DEFAULT 497 dwHeight RS170 HEIGHT DEFAULT 498 break 499 500 CCIR interlaced SOL case 312 502 case 313 503 peClock PCLOCK_CCIR_SQUARE 504 vfFormat FORMAT INTERLACED 505 Cbe Osen C
188. start when Grab is called and the Grab function will return immediately even if the trigger has not occurred and the image has not been captured A later call to AppIdle can check to see whether the Grab has finished and act accord ingly pxr_trigger c lines 212 221 KS Ss Bsr is fer sy hs is 2 3 4 15 6 7 8 9 220 221 BOOL AppIdle void HDC Moler is Telconig abDisolenyy ms return TRUE if GetKeyState VK_LBUTTON gt 0 3 19 Chapter 3 Programming the PXR800 pxr_trigger c lines 222 260 22D copy the video ram to a memory buffer BOS iit Gaicleicaley P Oi TNA ALTID 224 225 wait for the grabs to stop or 100 milliseconds 226 if PXR TimedWaitFinished hFG gqidGrab 100 ZEW 228 if PXR CheckError hFG 229 2S if true write something in control box 2o 232 always clear qidGrab when grab is finished 2993 if bAcquire 234 235 hdc GetDC hDisplay 236 ShowFrame gpFrame hdc dwImageX dwImageY 237 ReleaseDC hDisplay hdc 238 209 240 qidGrab QI INVALID 241 242 243 244 245 if bAcquire 246 247 if qidGrab is clear a grab needs to be queued 248 if qidGrab QI INVALID 249 250 qidGrab PXR Grab hFG gpFrame dwDelTime geStart 251 bSwitchToTrigger svStart flFields iwWhen 252 253 254 return FALSE 255 256 else 25m 258 return TRUE background app nothing to do 258
189. t can be used with the event handle Stale QUEUEIDs and Events can occur when the application tries to use a QUEUEID or handle for an operation that has been finished for a long time The API library allocates a fixed number of unique QUEUEID values for con secutively queued operations If a queued operation is old enough newer operations being added to the queue will use all available QUEUEIDs in order until eventually a new operation takes over the QUEUEID of the old opera tion The API guarantees that at least 400 queuable operations can occur between when a QUEUEID is returned and when it becomes stale Detailed Operating Information Chapter 5 If a QUEUEID has been reused functions such as IsFinished that take QUEUEID as a parameter might give incorrect results for the old queued oper ation Also if a QUEUEID has been reused any event handles created from the original queued operation become invalid Note Queueable functions contribute to the count of new queued operations even if the returned QUEUEID is never used by the application and even if they were called with IW WAIT Functions called with IW2_ NOW do not count as new queued operations Coherency Issues The PXR800 captures images into the PXR800 buffer memory Depending on your application needs you can set up the PXR800 for operation in single buffering or continuous buffering mode Continuous buffering or double buffering allows rapid capture and
190. t on a trigger event that is followed by the start of Vsync preRepeat is the code for how often to repeat the strobes e RP_SINGLE will fire the strobes once e RP_CONTINUOUS RTC sequence will start whenever the event is detected e RP _STOP RTC sequence is not programmed to run or the last sequence that started with RP_ SINGLE has completed Continued on the following page 9 22 PXR800 API Functions Chapter 9 GetRTCStart continued psvStart is the code to identify which field the RTC starts on e SV_EVEN_ FIELD RTC only starts on an even field e SV_ODD_FIELD RTC only starts on an odd field e SV EITHER FIELD RITC starts on either field Return Value Returns a non zero value on success zero on failure Description The GetRTCStart function provides information about which events start real time sequences and how often they are repeated To control which event will start the RTC use RTCStart The possible combinations of values for pesEvent and preRepeat and their meanings are pesEvent ES OFF preRepeat RP STOP RTC timing sequence status Any previous RTC sequences have stopped and no new RTC sequences have been requested ES OFF RP SINGLE A single RTC sequence has started The RTC will stop when the sequence is complete any value except ES OFF RP SINGLE The RTC is waiting for the event described by pesEvent After the event it will generate a sing
191. tRTCTiming GetRTCTiming 9 39 Chapter 9 PXR800 API Functions InvalidateGrabberBuffer QUEUEID InvalidateGrabberBuffer FGHANDLE fgHandle IMG WHEN iwWhen PXRVB InvalidateGrabberBuffer ByVal fgHandle As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI INVALID on error Description The InvalidateGrabberBuffer function prevents an image in the PXR8000 buffer memory from being delivered in response to a Grab request This is especially useful when used in conjunction with the BlockGrabber function Any image already being transferred into the system memory out of the PXR800 buffer memory is not affected Only images in the PXR800 buffer memory that are waiting to be delivered are invalidated See Also BlockGrabber SetContinuousBuffering GetContinuousBuffering 9 40 PXR800 API Functions Chapter 9 IisFinished DWORD IsFinished FGHANDLE fgHandle QUEUEID gilID PXRVB IsFinished ByVal fgHandle As Long ByVal giID As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG qiID is a QueueID returned by one of the queueable functions Return Value Returns
192. tTermination IMG TERMINATION GetTermination FGHANDLE fgHandle IMG CAMERA icCamera PXRVB GetTermination ByVal fgHandle As Long ByVal icCamera As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG icCamera is one of the cameras e CAMERAO e CAMERA1 e CAMERA2 e CAMERA3 Return Value Return is the termination code e TERM 75 OHM e TERM HIGH IMPEDANCE e TERM INVALID on error Description The GetTermination function returns the type of termination in use for the camera Use SetTermination to change the setting Returns immediately Note Although changing termination changes the image brightness this should not be used as a brightness control Use this only to compensate for cable impedance issues Use SetGainRange or SetFineGain to adjust image brightness See Also SetTermination SetGainRange GetGainRange SetOffset GetOffset SetNyquistFilter GetNyquistFilter SetFineGain 9 30 PXR800 API Functions Chapter 9 GetTime DWORD GetTime FGHANDLE fgHandle IMG IMAGEINFOTIMING pTime PXRVB GetTime ByVal fgHandle As Long ByRef pTime As IMG ImageInfoTiming As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG pTime is the address of an IMG_IMAGEINFOTIMING structure which receives the grabbers timing values Return Value Return is non zero for success zero for failure Description The GetTime fun
193. ter 9 PXR800 API Functions SetCamera continued Description The SetCamera function changes the currently active camera input of the specified frame grabber The grabber may not be synchronized to the camera immediately e If the cameras are of different types will not stabilize until everything is set up for the new type of camera e If the pixel clock is changed waits one field for synchronization e If the cameras are not genlocked waits one field for synchronization e If the source of Hsync or Vsync is changed waits one field for synchronization The camera can also be changed with RTCStart and Grab See Also GetCamera RTCStart Grab 9 52 PXR800 API Functions Chapter 9 SetContinuousBuffering DWORD SetContinuousBuf4fering FGHANDLE fgHandle IMG BUFFERING buContinuous PXRVB SetContinuousBuffering ByVal fgHandle As Long ByVal buContinuous As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG buContinuous sets the current state of how the grabber is buffering the images e BU SINGLE e BU CONTINUOUS Return Value Returns a non zero value on success zero on failure Description The SetContinuousBuffering function sets the current buffering method In BU CONTINUOUS mode the frame grabber will continuously capture video data into the onboard buffer memory using the settings from the last Grab or Wait command called This mode can be more efficient r
194. the PXR Productivity Tool we tried to find a balance between the total number of dialog boxes and the number of API commands per dialog box We also realized that it might be helpful to have several dialog boxes open at the same time Organizing the interface into several small dialog boxes lets you place them around the outside of the video window without obscuring the image as you test and learn In general we tried to group the API commands in functionally related groups The Frame Size dialog box shown in Figure 4 1 on page 4 3 is a good example It incorporates the fol lowing API commands e SetPixelClock e SetInterlaceMode e SetVideoFrameSize e SetROI e GetFieldLength These commands are used to set up the image size according to the video for mat of the camera and are closely related A change in any one of them can require a change in the others Placing them all on the same dialog box lets you make changes and view the effects immediately The PXR Productivity Tool Chapter 4 cera dwFieldLength a Read only SetPinelClock PCLOCK_EXTERNAL PCLOCK_EXT_INVERTED PCLOCK_NTSC_RECTANGLE PCLOCK_CCIR_RECTANGLE PCLOCK_NTSC_SQUARE immediately SetintelaceMode FORMAT_INTERLACED C FORMAT PROGRESSIVE SetyideoEramesize dwLettO treet jis daTop ffset 35 diwidth E40 dwHeight Jaga SefyideoFrame Size Reset Defaults Take effect when you click SetAill the button dwAOlLeft 0 dwAOlTop jo
195. the PXR800 buffer memory and begins copying data over the PCI bus to system memory e Data transfer over the PCI bus continues until all image data is written to system memory e Typically Grab completes several milliseconds after the end of the image If the camera is free running there will be a substantial delay until the next qualified image because no further image data is being captured at this point The chief advantage of the single buffered burst transfer mode is that data is transferred as quickly as possible over the PCI bus This uses bus resources with the greatest efficiency However this mode does have limited usage because it s generally not possible to capture successive images Continuous buffered incremental transfer mode causes the following sequence of events e Before Grab is called the Camera End is continuously capturing qualified images e When Grab begins execution the Camera End will have typically captured a portion of an image into PXR800 buffer memory e At the beginning of Grab the System End notices that there is already image data in the PXR800 buffer memory and begins copying as fast as possible to system memory Detailed Operating Information Chapter 5 e Typically the System End can copy data faster than the camera is sending it As a result the System End catches up with the Camera End and begins copying image data as it arrives from the camera e When the camera sends the last line of
196. the addition of the prefix PXRVB_ For additional information on using the functions refer to Chapter 5 Detailed Operating Information on page 5 1 For reference information on the PXR800 API structures refer to Chapter 7 PXR800 API Structures on page 7 1 For reference information on initializing or exiting library func tions refer to Chapter 8 Initializing and Exiting Libraries on page 8 1 For reference information on the Frame Library refer to Chapter 10 PXRFrame API Functions on page 10 1 This function reference is a general guide for using the functions in personal computers running the Microsoft Windows operating system versions 98 98 SE Me NT4 2000 or XP The functions work as written for C C and Visual Basic with the header files provided 9 1 Chapter 9 PXR800 API Functions 9 2 AllocateFG FGHANDLE AllocateFG DWORD dwGrabber PXRVB AllocateFG ByVal dwGrabber As Long As Long Parameters dwGrabber the number 0 to 3 of grabber to be allocated A special value of GR_NEXT AVAILABLE will allocate an unused grabber Return Value The return value is a handle for the requested frame grabber if successful zero on failure Description The AllocateFG function attempts to find a PXR800 Frame Grabber and give the program access to it The program can request a specific frame grab ber in a system that has more than one by specifying a number dwGrabber If the grabber is
197. the end of VSync e GE ON VSYNC_AFTER_TRIGGER waits for the next VSync that ends after a trigger event e GE ON VSYNC_START waits for an image qualified at the start of VSynce e GE ON VSYNC_START AFTER _TRIGGER waits for the next VSync that begins after a trigger event bSwitchToTrigger e If TRUE will cause the grabber to switch to the camera that matches the trigger e Otherwise the camera will not be changed Continued on the following page 9 80 PXR800 API Functions Chapter 9 Wait continued Parameters continued svStart identifies which field to wait for e SV EVEN FIELD e SV ODD FIELD e SV EITHER FIELD flFields identifies the number of fields to wait for e FL FIELD e FL FRAME If the grabber is in progressive mode this value is ignored as the image will be one field in length iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the frame grabber queue so it will be completed later Return Value Return is a handle to a queued request QI _ INVALID on failure Description The Wait function completes after an image that meets the specified criteria has been completely seen by the frame grabber no data is transferred The time of a Wait will be the same as a Grab with the same settings The Wait function implicitly sets the blocking depth to zero See Also Grab WaitFinished TimedWaitFinished
198. the memory block at pBuffer must be e atleast pitch height if bImageInfo is FALSE e orpitch height size of IMG _IMAGEINFO if bImageInfo is TRUE It is important to not free the memory used by pBuffer until the Frame is no longer using the memory The Frame must be freed when no longer needed by using the FreeFrame function Freeing the frame releases the memory allocated for the PXRFrame structure but does not attempt to free the memory at pBuffer 10 9 Chapter 10 PXRFrame API Functions FrameHeight DWORD FrameHeight PXRFRAME pFrame FRAMEVB FrameHeight ByVal pFrame As Long As Long Parameters pFrame is the address of a PXRFrame Return Value The number of lines in the image zero if failure Description The FrameHeight function returns the height of the frame The height is the number of lines contained within a full image 10 10 PXRFrame API Functions Chapter 10 FramePitch DWORD FramePitch PXRFRAME pFrame FRAMEVB FramePitch ByVal pFrame As Long As Long Parameters pFrame is the address of a PXRFrame Return Value The number of bytes in a line zero if failure Description The FramePitch function returns the width of the buffer in bytes This width represents the number of bytes from the start of a row to the start of the next row It might contain more bytes than necessary for the image width 10 11 Chapter 10 PXRFrame API Functions FrameType 10 12 DWORD Fr
199. transfer a FGHANDLE from one process to another If a process is running multiple threads that access a single frame grabber they all share the same FGHANDLE value A QUEUEID is a non zero number that represents an operation that has been placed in a PXR800 frame grabber s queue for execution All operations cur rently in the queue will have different QUEUEIDs Eventually the library will Programming the PXR800 Chapter 3 begin reusing QUEUEID values but it guarantees that at least the last 400 operations for a particular frame grabber will have unique ID values A QUEUEID is meaningful only to the frame grabber that will be performing the operation All functions using QUEUEIDs also require a FGHANDLE to identify which frame grabber the operation is associated with If your applica tion uses more than one frame grabber the QUEUEIDs for some operations on one of the frame grabbers might happen to be the same as QUEUEIDs for operations on the other frame grabber In such situations be sure to keep track of which frame grabber is responsible for which operations Since QUEUEIDs are only meaningful to a particular frame grabber and a frame grabber can only be owned by a single process QUEUEIDs cannot be shared between processes However QUEUEIDs can be shared between threads in a single process This is often useful since waiting for an operation to complete in a frame grabber s queue is one way of synchronizing threads For example a
200. turned by AllocateFG icCamera is one of the cameras e CAMERAO e CAMERA1 e CAMERA2 e CAMERA3 itTermination is the termination code e TERM 75 OHM e TERM HIGH IMPEDANCE Return Value The return is non zero for success zero on failure Description The SetTermination function sets the type of termination in use for the camera Returns immediately Note Although changing termination changes the image brightness SetTermination should not be used as a brightness control Use this only to compensate for cable impedance issues Use SetGainRange or SetFineGain to adjust image brightness See Also GetTermination SetNyquistFilter GetNyquistFilter SetGainRange SetFineGain 9 73 Chapter 9 PXR800 API Functions SetTime 9 74 DWORD SetTime FGHANDLE fgHandle IMG IMAGEINFOTIMING pTime PXRVB SetTime ByVal fgHandle As Long ByRef pTime As IMG ImageInfoTiming As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG pTime is the address of an IMG_IMAGEINFOTIMING structure which provides the frame grabber s timing values Return Value Return is non zero for success zero on failure Description The SetTime function sets the time of the frame grabber s onboard clock The time kept by this clock can be read using GetTime and is stored in the image info data for a frame when Grab captures an image to the frame Returns immediately See Also GetTime
201. ued on the following page 9 84 PXR800 API Functions Chapter 9 WritelO continued See Also ReadIO 9 85 Chapter 9 PXR800 API Functions This page intentionally left blank 9 86 PXRFrame API Functions Chapter 10 Chapter 10 PXRFrame API Functions This chapter is an alphabetical function reference for the Imagenation PXRFrame Library The reference page for each function gives the function syntax for the C language and for Visual Basic The C syntax is always given first followed by the Visual Basic syntax Each Visual Basic function has the same name as its corresponding C function but with the addition of the prefix FRAMEVB_ For additional information on using the structures refer to Chapter 5 Detailed Operating Information on page 5 1 For reference information on the PXR800 API structures refer to Chapter 7 PXR800 API Structures on page 7 1 For reference information on initializing or exiting library func tions refer to Chapter 8 Initializing and Exiting Libraries on page 8 1 For reference information on the PXR800 API functions refer to Chapter 9 PXR800 API Functions on page 9 1 This function reference is a general guide for using the functions in personal computers running the Microsoft Windows operating system versions 98 98 SE Me NT4 2000 or XP The functions work as written for C C and Visual Basic with the header files provided 10 1 Chapter 10 PXRFram
202. uency which is defined as 1 2 the sam pling frequency of digitizing When such frequency components above the Nyquist frequency do exist high frequency noise for example sampling causes them to appear as low frequency aliases in the sampled signal To minimize aliasing it is common practice to use an anti aliasing filter also referred to as a Nyquist filter in the analog signal path prior to sampling and analog to digital conversion The Nyquist filter is a low pass filter that passes the video signal while significantly attenuating high frequency components above the Nyquist frequency SetNyquistFilter is used to activate or deactivate the Nyquist filter in the PXR800 When deactivated IF_NONE the analog video is unfiltered and there is a risk of aliasing in the digitized signal When activated the Nyquist filter is applied to the incoming video signal The filter has a 3 db point at 7 MHz and has a 24 dB octave roll off While use of the Nyquist filter is recommended in most instances there are some cases where you might want to turn off the filter For example you might want to turn it off if the incoming video has already been adequately fil tered In this case more filtering might diminish image sharpness There might also be circumstances where it is possible to observe small features in sharp image edges when the filter is off With the filter on such features might not be distinguishable Whenever the filter is off you ne
203. until all queued operations have completed See Also SetNyquistFilter SetTermination GetTermination PXR800 API Functions Chapter 9 GetOffset long GetOffset FGHANDLE fgHandle PXRVB GetOffset ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value Returns the current video offset valid returns are 128 127 returns 255 on error Description The GetOffset function returns the video offset of the current frame grab ber Use SetOffset to specify the offset The offset is digitally added to the pixel data before fine gain is applied An offset of zero makes the video blanking level roughly a zero pixel value This function will not return until all queued operations have completed See Also SetOffset SetFineGain SetGainRange GetFineGain GetGainRange 9 17 Chapter 9 PXR800 API Functions GetPixelClock IMG PIXEL CLOCK GetPixelClock FGHANDLE fgHandle PXRVB GetPixelClock ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value Returns the current pixel clock selected e PCLOCK NTSC SQUARE e PCLOCK CCIR SQUARE e PCLOCK NTSC RECTANGLE e PCLOCK CCIR RECTANGLE e PCLOCK EXT e PCLOCK EXT INVERTED e PCLOCK INVALID on error Description The GetPixelClock function returns the currently selected pixel clock of the specified frame grabber This pixel cl
204. ured The PXR800 memory is capable of double buffering also referred to as ping pong or continuous buffering This allows the Camera End to begin capture of a new image into one side of the buffer without destroying the previous image written into the other side of the buffer Reading and writing of image data ping pongs between the buffers allowing continuous capture and read ing of image data During image grabs the Camera End can be in one of two modes single buff ering mode or continuous buffering mode Selection of the buffering mode is done with SetContinuousBuf fering Detailed Operating Information Chapter 5 SYSTEM APPLICATION MEMORY PCI BUS H eS i ae ne Gee Ey l DLL o O DRIVER EN Bile foo ecicone CORE S z z I w PXR800 f l L ran l S L l CAMERA REAL TIME T l CAMERA K _ INTERFACE Spree y 1 aN SIE lt O CAMERA TRIGGERS STROBE EXPOSURES GPI O Figure 5 11 PXR800 Data Flow and Control Paths In single buffering the Camera End doesn t put data into the PXR800 buffer memory unless the event qualifying an image occurs after a Grab command has started For example if Grab requests a triggered grab in single buffering mode data doesn t begin streaming into the buffer until the beginning of the first image following the first trigger after the Grab has reached the top of the queue In other words the Grab must reach the top of the queue then a trig ger must occur and then data
205. use depends on the demands of your applica tion Here are some possible solutions e Minimize Object Movement Interlace offset diminishes as object movement decreases However decreasing object movement is a tradeoff between video edge resolution needs and production throughput and might not be a practical solution e Rotate the Video Camera By rotating the video camera ninety degrees to the direction of object motion it may be possible to eliminate or reduce the appearance of interlace offset in the captured image The tradeoff here though is that there will still be a one scan line uncertainty in the location of the image s vertical edges e Use a Progressive Scan Camera Progressive scan cameras capture images by scanning the entire image frame in line order Since there is no field interlacing interlace offset does not occur Blur Blur is caused by object motion in the video camera s field of view It is a pixel level phenomenon that can occur before interlace offset even becomes a noticeable issue Or it can become so significant as to render interlace offset a minor issue Blur can even occur when using a progressive scan camera Essentially it is the smearing of the image across two or more pixels during video frame exposure As in film based photography video blur can be reduced by using shorter faster exposure times The following equations are useful in determining blur magnitude and exposure times for blur reductio
206. ut Dynamic Range Corresponds to 100IRE 714 mV The above diagram is a functional overview of PXR800 signal conditioning and manipulation capabilities Figure 5 4 Signal Conditioning and Manipulation Termination The type of video termination for each of the four camera inputs can be selected under software control This is done with the SetTermination function The available termination values are 75 Q and high impedance gt 10k QO The default termination is 75 Q which matches the characteristic impedance of typical video system components Usually you should use the 75 Q termination This provides an impedance match between the camera and the PXR800 video signal input A correct impedance match is important for maintaining video signal quality into the PXR800 If the high impedance selection is used on 75 Q video systems you can expect distorted noisy video caused by reflections in the improperly ter minated system 5 9 Chapter 5 Detailed Operating Information 5 10 High impedance can be used to avoid double terminating the video signal when a second device is also connected to the video cable and that device is providing 75 Q termination Nyquist Filtering Nyquist filtering is provided prior to the ADC The purpose of Nyquist filter ing is to minimize a potential digitizing artifact referred to as aliasing Aliasing occurs when the analog video signal contains significant frequency components above the Nyquist freq
207. valid data for the image the data is immediately written to the PXR800 buffer memory e The System End detects an image in the PXR800 buffer memory and begins copying data over the PCI bus to system memory e Grab completes e Jfa queued operation is waiting it begins to execute e The next qualified image is captured as it arrives and is written to the PXR800 buffer whether or not another Grab has started The continuous buffered incremental transfer mode is most useful for situa tions where data must be analyzed at full frame rates Because Grab can start after the image begins arriving a simple loop that calls Grab and then ana lyzes the resulting image can run at the full frame rate as long as image anal ysis takes less than about half the frame rate The image captured by Grab is either the next image of the requested type or the image currently in progress This means that a triggered grab will sometimes get an image that was trig gered by an event that happened before Grab was called In writing applications using this mode be careful about changing image properties such as offset or gain Such changes might take effect midway through image capture to the PXR800 buffer If Grab is called immediately afterwards the image written to system memory will have some data from prior to the change in image properties The function InvalidateGrabberBuffer can be called before Grab to discard this inconsistent data Continuous buffer
208. verview of PXR800 Features and Operation 0000000000 1 5 The NXE Ste Bc cscasssssicersecacarsernersroraea eure agers 1 8 Chapter 2 Installing the PXERS00 vaccine ccceecrcenimnenananc 2 1 Quick Installation gicccenssscieseccsewescecteces increwesendecsaveveecxeeestsactedse 2 1 Installing the PXR800 Software from the Setup CD 2 1 Installing the PXR800 Card csatiocsesaiiocaoeinaniea secredaeancbiasdaads 2 1 Attaching the CBG ceiien iia 2 2 Restarting the COMputer sessecseessersrrrsserisrerssrersrerssrrrsrere 2 2 Optional Equipment oscviscccscccscssievendnevevescvevenasivaxeneverssevesdecsees 2 2 PXR801 Camera Extender Board agsieneusncausurciaanminanouuecwiacnts 2 2 Camera CAD IGS os uicdissihocubiaadeiatemansie eon acta dterevamateaetbns 2 2 Uninstalling the PXR800 eeoooseescosssscccsssccccsssscosssssecsssse 2 3 Uninstalling the Development Software cicnccciuiiseniutnaieannanin 2 3 Uninstalling the Drivers cig ccrsetansaieisrnceiolannsedanasassionabinadensnnanens 2 3 Upgrading or Repairing the Software 00000000s0000000000 2 3 Installing the PXR800 as Part of a Product ssssssssssssssssss00 2 4 Troubleshooting sseecoooseccocsssscccssscccossescosssesocsssececsssssssoo 2 5 General TIPS encnsianin naana a A E A AA EES 2 5 Technical Support sesssossesssoeseesscecesssocseessoccsessscesesssoesescese 2 6 Table of Contents Chapter 3 Programming the PXR800 ccccccssc
209. wWhen PXRVB ResetRTC ByVal fgHandle As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG iwWhen describes when this function should occur e IW2 WAIT wait for all other queued requests to complete e IW2 QUEUED add to the frame grabber queue so it will be completed later e IW2 NOW perform the operation immediately before any other operation in the queue Return Value Return is a handle to a queued request QI INVALID on failure Description The ResetRTC function stops any currently executing RTC sequences It does not change the pulse settings and start conditions that were set by RTCStart and SetRTCTiming it only stops the currently running sequence This function will stop sequences in progress unlike RTCStart with the RP_STOP parameter which stops repeating sequences but allows the cur rently running sequence to finish See Also RTCStart SetRTCTiming 9 48 PXR800 API Functions Chapter 9 RTCStart QUEUEID RTCStart FGHANDLE fgHandle IMG EVENT START esEvent IMG REPEAT rekepeat IMG START VSYNC svimageStart IMG WHEN2 iwWhen PXRVB RTCStart ByVal fgHandle As Long ByVal esEvent As Long ByVal reRepeat As Long ByVal svimageStart As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG esEvent is the starting event for the real time control RTC
210. with no contrast e A fine gain of 128 is normal gain where the range from blanking level to white level is represented by a pixel value from zero to 255 e A fine gain of 255 is approximately twice normal contrast See Also GetFineGain SetGainRange GetGainRange 9 56 PXR800 API Functions Chapter 9 SetGainRange QUEUEID SetGainRange FGHANDLE fgHandle DWORD dwGain IMG WHEN iwWhen PXRVB SetGainRange ByVal fgHandle As Long 7 ByVal dwGain As Long ByVal iwWhen As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG dwGain sets the gain setting valid range 0 1 iwWhen describes when this function should occur e IW WAIT wait for all other queued requests to complete e IW QUEUED add to the Frame Grabber queue so it will be completed later Return Value Return is a handle to a queued request QI INVALID on failure Description The SetGainRange function sets the gain range of the specified frame grab ber The gain range is an analog adjustment designed to compensate for low video signal levels e Ifthe gain range is zero the input video is assumed to be normal 1 volt peak to peak e Ifthe gain range is one the input video is amplified by a factor of two before being digitized This allows full grayscale accuracy for signals of approximately 1 2 Volt peak to peak See Also SetFineGain GetFineGain GetGainRange 9 57 Chapter 9 PXR800
211. xt odd field Next frame starting with an even field Next frame starting with an odd field Next frame starting with either field progressive or interlaced Additionally acquisition can be further limited to those images that follow a combination of events These include Start of an image Vertical Drive Vertical Sync or WEN A hardware trigger followed by the start of an image triggering can be selected to be on a rising or falling edge or on a high or low level A software event followed by the hardware trigger and or the start of an image Trigger Events The PXR800 supports a variety of triggering capabilities Both hardware trig gers signals and software events can be used to trigger other events such as image grabs or pulse generation Various trigger event sources are indicated in Figure 5 9 on page 5 24 These include Trig 0 3 in the upper right of Figure 5 9 which can be a pulse or signal associated with a camera An example of a trigger is a sensor pulse generated when an object of interest moves into a camera s field of view Note The trigger inputs Trig 0 3 are available either as straight wire inputs or optically isolated inputs The optically isolated inputs must be driven by something that can source current 5 23 Chapter 5 Detailed Operating Information e Sync Control events are generated through the Sync Control block near the center of Figure 5 9 Events generated from here ar
212. xtremely wide and flexible range of grab conditions can be set up and queued through the Real Time Engine by the application program Notice too that triggers strobe and exposure control are also handled through the Real Time Engine according to selections and setup conditions made in the application program How grabbed images are read into and out of the Buffer Memory is also selectable via the application program Single buffering or continuous buffer ing ping pong or double buffering modes are available in combination with incremental and burst DMA direct memory access transfer modes Again which combination of modes you use depends on your application needs Grabbed images are transferred out of the PXR800 Buffer Memory through the PCI interface into designated areas of the Computer System Memory The des ignated areas of memory are structures referred to as PXRFrames which are set up via the Application program Four general purpose inputs and four general purpose outputs GPI O are provided to communicate with external devices The API application program interface supplied with the PXR800 pro vides a command set for programming camera selection and control applying image processing offset gain LUT ROI etc selecting and qualifying 17 Chapter 1 Introduction images setting up real time sequences and much more A PXRFrame Library is also supplied for performing various operations on image data stored as a PXR
213. y image qualifications and any future real time events from taking effect The function stops any cur rent image qualification operation from updating the on board memory buffer However real time sequences that have already started are not affected InvalidateGrabberBuffer should be used after a block to clear any unwanted images from the on board memory buffer that are left from an image qualification process that was interrupted by the block Continued on the following page 9 3 Chapter 9 PXR800 API Functions BlockGrabber continued Each call to BlockGrabber with TRUE will increase the blocking depth The blocking will not be removed until a matching number of calls to BlockGrabber with FALSE have been called Thus calls to BlockGrabber can be stacked The effect of the block occurs when all queueable operations before the BlockGrabber call have completed Grab and Wait both implicitly unblock the frame grabber setting the block level to zero when they execute See Also Grab InvalidateGrabberBuffer KillQueue Wait 9 4 PXR800 API Functions Chapter 9 CheckError DWORD CheckError FGHANDLE fgHandle PXRVB CheckError ByVal fgHandle As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG Return Value The return value is a code to the latest error condition detected by the PXR800 Frame Grabber or driver e This function resets the error condition to PXR800 ERROR_NO
214. yVal fgHandle As Long ByRef pdwROILeft As Long ByRef pdwROITop As Long ByRef pdwROIWidth As Long ByRef pdwROIHeight As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG pdwROILeft is the address to receive the left offset of the ROI valid range 0 2047 pdwROITop is the address to receive the top offset of the ROI valid range 0 2047 pdwROIWidth is the address to receive the width of the ROI valid range 4 2044 must be a multiple of four pixels pdwROIHeight is the address to receive the height of the ROI valid range 1 2047 All pointers must be valid or the application might crash Return Value Returns a non zero value on success zero on failure Description The GetROT function gets the dimensions of the region of interest ROT and its position within the valid video If the size of the ROI is larger than the size of the frame when a Grab happens the Grab will capture an image the size of the frame The values returned by GetROI may be smaller than those set with the SetROI function The ROI width is rounded down to a multiple of four pix els If the requested ROI was larger than the current video frame size as set by SetVideoFrameSize the ROI will be adjusted to fit Continued on the following page 9 20 PXR800 API Functions Chapter 9 GetROI continued When using an interlaced camera it is possible to grab a single field which includes
215. ync Mode Names SetSyncMode SetSyncPolarity GetSyncPolarity GetDriveMode SetDriveMode Table 9 3 on page 9 11 9 27 Chapter 9 PXR800 API Functions GetSyncPolarity DWORD GetSyncPolarity FGHANDLE fgHandle IMG CAMERA icCamera IMG POLARITY ppoVDrive IMG POLARITY ppoHDrive PXRVB GetSyncPolarity ByVal fgHandle As Long ByVal icCamera As Long ByRef ppoVDrive As Long ByRef ppoHDrive As Long As Long Parameters fgHandle is the handle to the frame grabber returned by AllocateFG icCamera is one of the cameras e CAMERAO e CAMERAIL e CAMERA2 e CAMERA3 ppovDrive is the address to receive the vertical sync polarity value e POLARITY POSITIVE e POLARITY NEGATIVE ppoHDrive is the address to receive the horizontal sync polarity value e POLARITY POSITIVE e POLARITY NEGATIVE Return Value The return is non zero for success zero for failure Bad values for ppoVDrive and ppoHDrive can crash the application Continued on the following page 9 28 PXR800 API Functions Chapter 9 GetSyncPolarity continued Description The GetSyncPolarity function returns the current video sync polarity set tings Use SetSyncPolarity to control the polarity of the sync signals Use SetSyncMode and SetDriveMode to control the source of the sync signals Returns immediately See Also SetSyncPolarity SetSyncMode GetSyncMode SetDriveMode GetDriveMode 9 29 Chapter 9 PXR800 API Functions Ge
Download Pdf Manuals
Related Search
Related Contents
平成27年8月改訂版 Golden Technologies HMI 1200 TV Projector User Manual manual de usuario aplicación móvil raveno (android) 02 - CONRAD Produktinfo. A5522SA 取扱説明書 Philips HP2843/11 Data Sheet Definitive Technology StudioMonitor 55 Altronix AL300ULXB2 MU-68-D _Célula Calibrada 5V Compensada Copyright © All rights reserved.
Failed to retrieve file