- ////这是主程序
- * Image Acquisition 02: Code generated by Image Acquisition 02
- open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[0] USB2.0 VGA UVC WebCam', 0, -1, AcqHandle)
- grab_image_start (AcqHandle, -1)
- dev_close_window()
- dev_open_window(0,0,728,512,'black',WindowID)
- while (true)
- grab_image_async (Image, AcqHandle, -1)
- * Image Acquisition 02: Do something
- rgb1_to_gray (Image, GrayImage)
- dev_display (GrayImage)
- threshold (GrayImage, Regions, 82, 255)
- connection (Regions, ConnectedRegions)
-
- select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 21951.2, 200000)
- dev_display (GrayImage)
- dev_display (SelectedRegions)
- area_center (SelectedRegions, Area, Row, Column)
- disp_message (WindowID, '面积'+Area+'坐标:'+Row+' '+Column,'window',0,0, 'white', 'false')
-
- endwhile
- close_framegrabber (AcqHandle)
- ////这是disp_message()
- * This procedure displays text in a graphics window.
- *
- * Input parameters:
- * WindowHandle: The WindowHandle of the graphics window, where
- * the message should be displayed.
- * String: A tuple of strings containing the text messages to be displayed.
- * CoordSystem: If set to 'window', the text position is given
- * with respect to the window coordinate system.
- * If set to 'image', image coordinates are used.
- * (This may be useful in zoomed images.)
- * Row: The row coordinate of the desired text position.
- * You can pass a single value or a tuple of values.
- * See the explanation below.
- * Default: 12.
- * Column: The column coordinate of the desired text position.
- * You can pass a single value or a tuple of values.
- * See the explanation below.
- * Default: 12.
- * Color: defines the color of the text as string.
- * If set to [] or '' the currently set color is used.
- * If a tuple of strings is passed, the colors are used cyclically
- * for every text position defined by Row and Column,
- * or every new text line in case of |Row| == |Column| == 1.
- * Box: A tuple controlling a possible box surrounding the text.
- * Its entries:
- * - Box[0]: Controls the box and its color. Possible values:
- * -- 'true' (Default): An orange box is displayed.
- * -- 'false': No box is displayed.
- * -- color string: A box is displayed in the given color, e.g., 'white', '#FF00CC'.
- * - Box[1] (Optional): Controls the shadow of the box. Possible values:
- * -- 'true' (Default): A shadow is displayed in
- * darker orange if Box[0] is not a color and in 'white' otherwise.
- * -- 'false': No shadow is displayed.
- * -- color string: A shadow is displayed in the given color, e.g., 'white', '#FF00CC'.
- *
- * It is possible to display multiple text strings in a single call.
- * In this case, some restrictions apply on the
- * parameters String, Row, and Column:
- * They can only have either 1 entry or n entries.
- * Behavior in the different cases:
- * - Multiple text positions are specified, i.e.,
- * - |Row| == n, |Column| == n
- * - |Row| == n, |Column| == 1
- * - |Row| == 1, |Column| == n
- * In this case we distinguish:
- * - |String| == n: Each element of String is displayed
- * at the corresponding position.
- * - |String| == 1: String is displayed n times
- * at the corresponding positions.
- * - Exactly one text position is specified,
- * i.e., |Row| == |Column| == 1:
- * Each element of String is display in a new textline.
- *
- *
- * Convert the parameters for disp_text.
- if (Row == [] or Column == [])
- return ()
- endif
- if (Row == -1)
- Row := 12
- endif
- if (Column == -1)
- Column := 12
- endif
- *
- * Convert the parameter Box to generic parameters.
- GenParamName := []
- GenParamValue := []
- if (|Box| > 0)
- if (Box[0] == 'false')
- * Display no box
- GenParamName := [GenParamName,'box']
- GenParamValue := [GenParamValue,'false']
- elseif (Box[0] != 'true')
- * Set a color other than the default.
- GenParamName := [GenParamName,'box_color']
- GenParamValue := [GenParamValue,Box[0]]
- endif
- endif
- if (|Box| > 1)
- if (Box[1] == 'false')
- * Display no shadow.
- GenParamName := [GenParamName,'shadow']
- GenParamValue := [GenParamValue,'false']
- elseif (Box[1] != 'true')
- * Set a shadow color other than the default.
- GenParamName := [GenParamName,'shadow_color']
- GenParamValue := [GenParamValue,Box[1]]
- endif
- endif
- * Restore default CoordSystem behavior.
- if (CoordSystem != 'window')
- CoordSystem := 'image'
- endif
- *
- if (Color == '')
- * disp_text does not accept an empty string for Color.
- Color := []
- endif
- *
- disp_message (WindowHandle, String, CoordSystem, Row, Column, Color, GenParamName, GenParamValue)
- return ()
复制代码 |