Home Image-Pro Plus Automation with Macros

Crosshairs on live image

In response to a recent question, whether it would be possible to display cross-hairs on a live image to align a specimen, the answer is yes

Workspace Preview (available for all cameras in Image-Pro) displays the live camera image in a normal Image-Pro Plus workspace, with all processing options available. While the frame rate (due to the additional processing) will not be as fast as the standard live preview, the additional functionality can be very useful. 

First, add the following macro to your active script file:

Sub Crosshair()
Dim source As Integer
Dim dInfo As IPDOCINFO
Dim annotNum As Integer

' Check to see if the crosshairs have been drawn yet
' (this prevents repeated redraws)
ret = IpAnGet(GOOBJGET_OBJ_NUMBER, annotNum)
If annotNum >= 2 Then Exit Sub

' Get image information
ret = IpDocGet(DOCGET_GETACTDOC, 0, source)
ret = IpDocGet(DOCGET_GETDOCINFO, source, dInfo)

' If not present, draw crosshairs on the image
ret = IpAnCreateObj(GO_OBJ_LINE)
ret = IpAnMove(0, 0, dInfo.Height/2)
ret = IpAnMove(2, dInfo.Width-1, dInfo.Height/2)
ret = IpAnCreateObj(GO_OBJ_LINE)
ret = IpAnMove(0, dInfo.Width/2, 0)
ret = IpAnMove(2, dInfo.Width/2, dInfo.Height-1)
End Sub

In the Video/Ditgital Capture dialog, check Workspace Preview. Expand the dialog (using the More >> button), and click on the Macro tab. Select the "Crosshair" macro for Workspace Preview. now any workspace preview will have crosshairs drawn - and the check on the number of annotation objects will prevent constant redraws.

This technique can be used to draw crosshairs, stereology dissectors, protractors, or any other overlay needed for live previews. 
Sign In or Register to comment.