### C Image Acquisition Example Source: https://www.mvtec.com/doc/halcon/13/en/grab_image_start Example demonstrating how to open a framegrabber, start asynchronous grabbing, process images in a loop, and close the framegrabber using C. ```C /* Select a suitable image acquisition interface named AcqName. */ open_framegrabber("AcqName", 1, 1, 0, 0, 0, 0, "default", -1, "default", \ -1.0, "default", "default", "default", -1, -1, &AcqHandle) ; /* Start asynchronous grabbing. */ grab_image_start(AcqHandle, -1) ; /* Run acquisition loop. */ while (1) { /* Get image, start next grab. */ grab_image_async(&Image, AcqHandle, -1.0) ; /* Next: Do something with the grabbed image. */ } close_framegrabber(AcqHandle) ; ``` -------------------------------- ### HDevelop Image Acquisition Example Source: https://www.mvtec.com/doc/halcon/13/en/grab_image_start Example demonstrating how to open a framegrabber, start asynchronous grabbing, process images in a loop, and close the framegrabber using HDevelop. ```HDevelop * Select a suitable image acquisition interface named AcqName. open_framegrabber('AcqName', 1, 1, 0, 0, 0, 0, 'default', -1, 'default', \ -1.0, 'default', 'default', 'default', -1, -1, AcqHandle) * Start asynchronous grabbing. grab_image_start(AcqHandle, -1) * Run acquisition loop. while (true) * Get image, start next grab. grab_image_async(Image, AcqHandle, -1.0) * Next: Do something with the grabbed image. endwhile close_framegrabber(AcqHandle) ``` -------------------------------- ### C Window Operations Example Source: https://www.mvtec.com/doc/halcon/13/en/open_window Demonstrates common window operations in C, including opening a window, displaying an image, writing text, getting mouse input, setting LUT and color, and drawing a rectangle. ```C open_window(0,0,400,-1,"root","visible","",&WindowHandle) ; read_image(&Image,"fabrik") ; disp_image(Image,WindowHandle) ; write_string(WindowHandle,"File: fabrik") ; new_line(WindowHandle) ; get_mbutton(WindowHandle,NULL,NULL,NULL) ; set_lut(WindowHandle,"temperature") ; set_color(WindowHandle,"blue") ; write_string(WindowHandle,"temperature") ; new_line(WindowHandle) ; write_string(WindowHandle,"Draw Rectangle") ; new_line(WindowHandle) ; draw_rectangle1(WindowHandle,&Row1,&Column1,&Row2,&Column2) ; set_part(Row1,Column1,Row2,Column2) ; disp_image(Image,WindowHandle) ; new_line(WindowHandle) ; ``` -------------------------------- ### HDevelop Window Operations Example Source: https://www.mvtec.com/doc/halcon/13/en/open_window Demonstrates common window operations in HDevelop, including opening a window, displaying an image, writing text, getting mouse input, setting LUT and color, and drawing a rectangle. ```HDevelop open_window(0,0,400,-1,'root','visible','',WindowHandle) read_image(Image,'fabrik') disp_image(Image,WindowHandle) write_string(WindowHandle,'File, fabrik') new_line(WindowHandle) get_mbutton(WindowHandle,_,_,_) set_lut(WindowHandle,'temperature') set_color(WindowHandle,'blue') write_string(WindowHandle,'temperature') new_line(WindowHandle) write_string(WindowHandle,'Draw Rectangle') new_line(WindowHandle) draw_rectangle1(WindowHandle,Row1,Column1,Row2,Column2) set_part(WindowHandle,Row1,Column1,Row2,Column2) disp_image(Image,WindowHandle) new_line(WindowHandle) ``` -------------------------------- ### C Example: Displaying LUTs and Getting Mouse Input Source: https://www.mvtec.com/doc/halcon/13/en/disp_lut Demonstrates setting a lookup table, displaying it, and capturing mouse button events in C. ```C set_lut(WindowHandle, "color1") ; disp_lut(WindowHandle, 256, 256, 1) ; get_mbutton(WindowHandle, NULL, NULL, NULL) ; set_lut(WindowHandle, "sqrt") ; disp_lut(WindowHandle, 128, 128, 2) ; ``` -------------------------------- ### HDevelop Example: Displaying LUTs and Getting Mouse Input Source: https://www.mvtec.com/doc/halcon/13/en/disp_lut Demonstrates setting a lookup table, displaying it, and capturing mouse button events in HDevelop. ```HDevelop set_lut(WindowHandle,'color1') disp_lut(WindowHandle,256,256,1) get_mbutton(WindowHandle,_,_,_) set_lut(WindowHandle,'sqrt') disp_lut(WindowHandle,128,128,2) ``` -------------------------------- ### Edge-Preserving Smoothing and Rolling Filter Example Source: https://www.mvtec.com/doc/halcon/13/en/guided_filter Shows an example of using the guided filter for edge-preserving smoothing and then applying it iteratively as a rolling filter. It reads an image, applies a single guided filter, and then uses a loop with a constant guide for multiple iterations. ```HDevelop read_image (Image, 'mreut') * Edge-preserving smoothing guided_filter (Image, Image, ImageGuided, 5, 20) * Rolling filter (5 iterations) gen_image_proto (Image, ImageGuide, 0) for I := 1 to 5 by 1 guided_filter (Image, ImageGuide, ImageGuide, 5, 20) endfor ``` -------------------------------- ### C Example: Background Estimation Initialization and Execution Source: https://www.mvtec.com/doc/halcon/13/en/run_bg_esti Illustrates background estimation in C using HALCON. This example covers image initialization, creating a background estimation dataset with fixed gains and threshold adaptation, and executing the estimation to identify foreground regions. ```C /* Read image for initialization: */ read_image(&InitImage,"xing/init") ; /* Initialize BgEsti-Dataset with fixed gains and threshold adaption */ create_bg_esti(InitImage,0.7,0.7,"fixed",0.002,0.02, "on",7,10,3.25,15.0,&BgEstiHandle) ; /* Read the next image in sequence: */ read_image(&Image0,"xing/xing000") ; /* Estimate the Background: */ run_bg_esti(Image0,&Region1,BgEstiHandle) ; /* Display the foreground region: */ disp_region(Region1,WindowHandle) ; /* Read the next image in sequence: */ read_image(&Image1,"xing/xing001") ; /* Estimate the Background: */ run_bg_esti(Image1,&Region2,BgEstiHandle) ; /* Display the foreground region: */ disp_region(Region2,WindowHandle) ; /* etc. */ ``` -------------------------------- ### Get Image Pointer Example in C Source: https://www.mvtec.com/doc/halcon/13/en/get_image_pointer1_rect Example demonstrating the usage of the get_image_pointer1_rect function in C to obtain a pointer to image data and its properties like width, height, and pitch. ```C Hobject image,reg,imagereduced; char typ[128]; Hlong width,height,vert_pitch,hori_bit_pitch,bits_per_pix, winID; unsigned char *ptr; open_window(0,0,512,512,"black",winID); read_image(&image,"monkey"); draw_region(®,winID); reduce_domain(image,reg,&imagereduced); get_image_pointer1_rect(imagereduced,(Hlong*)&ptr,&width,&height, &vert_pitch,&hori_bit_pitch,&bits_per_pix); ``` -------------------------------- ### HDevelop Example for I/O Device Operations Source: https://www.mvtec.com/doc/halcon/13/en/query_io_device Demonstrates querying I/O channels and reading data using HDevelop. It shows selecting an interface, opening an I/O device, querying channel names, opening a channel, and reading from it. ```HDevelop * Select a suitable i/o device interface of name IOInterfaceName query_io_interface (IOInterfaceName, 'io_device_names', DeviceNames) open_io_device (IOInterfaceName, DeviceNames[0], [], [], IODeviceHandle) query_io_device (IODeviceHandle, [], 'io_channel_names.digital_input', ChannelInputNames) open_io_channel (IODeviceHandle, ChannelInputNames[0], [], [], IOChannelHandle) read_io_channel (IOChannelHandle, Value, Status) ``` -------------------------------- ### GetCameraSetupParam: Get generic camera setup parameters Source: https://www.mvtec.com/doc/halcon/13/en/HOperatorSet Retrieves generic camera setup model parameters. This operator provides access to fundamental camera intrinsic and extrinsic properties. ```APIDOC GetCameraSetupParam: Gets generic camera setup model parameters. Purpose: To retrieve intrinsic and extrinsic camera parameters. Parameters: - CameraSetupModel: The camera setup model object. - ParamName: The name of the parameter to retrieve (e.g., 'cam_cx', 'cam_cy', 'cam_fx'). Returns: - ParamValue: The value of the requested parameter. Usage: GetCameraSetupParam(CameraSetupModel, ParamName, ParamValue) ``` -------------------------------- ### GetCameraSetupParam: Get generic camera setup parameters Source: https://www.mvtec.com/doc/halcon/13/en/HOperatorSet Retrieves generic camera setup model parameters. This operator provides access to fundamental camera intrinsic and extrinsic properties. ```APIDOC GetCameraSetupParam: Gets generic camera setup model parameters. Purpose: To retrieve intrinsic and extrinsic camera parameters. Parameters: - CameraSetupModel: The camera setup model object. - ParamName: The name of the parameter to retrieve (e.g., 'cam_cx', 'cam_cy', 'cam_fx'). Returns: - ParamValue: The value of the requested parameter. Usage: GetCameraSetupParam(CameraSetupModel, ParamName, ParamValue) ``` -------------------------------- ### Close Edges with Length (C Example) Source: https://www.mvtec.com/doc/halcon/13/en/close_edges_length Example demonstrating the usage of the close_edges_length operator in C. It first preprocesses an image to get edge information and then applies close_edges_length to refine the edges. ```C sobel_amp(Image,&EdgeAmp,"sum_abs",5); threshold(EdgeAmp,&EdgeRegion,40.0,255.0);skeleton(EdgeRegion,&ThinEdge); close_edges_length(ThinEdge,EdgeAmp,&CloseEdges,15,3); ``` -------------------------------- ### update_kalman Example (C) Source: https://www.mvtec.com/doc/halcon/13/en/update_kalman Demonstrates the system parameters, an example update file structure, and the expected results after calling the update_kalman operator in C. ```C /* The following values are describing the system */ /* */ /*DimensionIn = [3,1,0] */ /*ModelIn = [1.0,1.0,0.5,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0, */ /* 54.3,37.9,48.0,37.9,34.3,42.5,48.0,42.5,43.7] */ /*MeasurementIn = [1,2] */ /* */ /*An example of the Updatefile: */ /* */ /*n=3 m=1 p=0 */ /*A+C-Q-G-u-L-R- */ /*transitions at time t=15: */ /*2 1 1 */ /*0 2 2 */ /*0 0 2 */ /* */ /*the results of update_kalman: */ /* */ /*DimensionOut = [3,1,0] */ /*ModelOut = [2.0,1.0,1.0,0.0,2.0,2.0,0.0,0.0,2.0,1.0,0.0,0.0, */ /* 54.3,37.9,48.0,37.9,34.3,42.5,48.0,42.5,43.7] */ /*MeasurementOut = [1.2] */ ``` -------------------------------- ### dev_set_window_extents Functionality and Example Source: https://www.mvtec.com/doc/halcon/13/en/dev_set_window_extents Demonstrates how to set the extents of the current HALCON window using the dev_set_window_extents operator. It includes an HDevelop example showing window setup, image display, and modification of window extents. ```APIDOC dev_set_window_extents (Row, Column, Width, Height) Sets the extents of the current HALCON window. Parameters: - Row: Row index of the upper left corner. - Column: Column index of the upper left corner. - Width: Width of the window. - Height: Height of the window. Return Value: Returns 2 (H_MSG_TRUE) if parameters are correct, otherwise raises an exception. Related Operators: - dev_display - dev_set_lut - dev_set_color - dev_set_draw - dev_set_part ``` ```HDevelop dev_close_window () read_image (For5, 'for5') get_image_size (For5, Width, Height) dev_open_window (0, 0, Width, Height, 'black', WindowHandle) dev_display (For5) stop () dev_set_window_extents (-1,-1,Width/2,Height/2) dev_display (For5) stop () dev_set_window_extents (200,200,-1,-1) ``` -------------------------------- ### HDevelop Example: Opening and Displaying an Image Source: https://www.mvtec.com/doc/halcon/13/en/dev_open_window An example HDevelop script demonstrating how to open a graphics window, read an image, set its size to match the image dimensions, display the image, change the lookup table, and set a partial view. ```HDevelop dev_close_window () read_image (For5, 'for5') get_image_size (For5, Width, Height) dev_open_window (0, 0, Width, Height, 'black', WindowHandle) dev_display (For5) dev_set_lut ('rainbow') dev_display (For5) stop () dev_set_lut ('default') dev_display (For5) stop () dev_set_part (100, 100, 300, 300) dev_display (For5) ``` -------------------------------- ### C: opening_seg Implementation and Usage Source: https://www.mvtec.com/doc/halcon/13/en/opening_seg Provides a C function `my_opening_seg` simulating the opening operation and an example demonstrating its usage with region generation and processing. ```C /* Simulation of opening_seg */ my_opening_seg(Hobject Region, Hobject StructElement, Hobject *Opening) { Hobject H1,H2; erosion1(Region,StructElement,&H1,1); connection(H1,&H2); dilation1(H2,StructElement,Opening,1); clear_obj(H1); clear_obj(H2); } /* separation of circular objects */ gen_random_regions(&Regions,"circle",8.5,10.5,0.0,0.0,0.0,0.0,400,512,512); union1(Regions,&UnionReg); gen_circle(&Mask,100,100,8.5); opening_seg(UnionReg,Mask,&RegionsNew); ``` -------------------------------- ### HDevelop Ellipse Contour Generation Example Source: https://www.mvtec.com/doc/halcon/13/en/gen_ellipse_contour_xld Demonstrates the usage of HALCON functions `gen_ellipse_contour_xld` and `length_xld` in HDevelop for creating an ellipse contour and measuring its length. It also includes a transformation example for the start angle. ```HDevelop draw_ellipse(WindowHandle,Row,Column,Phi,Radius1,Radius2) gen_ellipse_contour_xld(Ellipse,Row,Column,Phi,Radius1,Radius2,0,6.28319, \ 'positive',1.5) length_xld(Ellipse,Length) * Transform StartPhi so that the start point of the ellipse actually * intersects the line through origin at the angle StartPhi measured from * the positive main axis affine_trans_point_2d ([1.0,0.0,0.0,0.0,1.0*Radius2/Radius1,0.0], \ sin(StartPhi), cos(StartPhi), Qx, Qy) StartPhiEllipse := atan2(Qx,Qy) ``` -------------------------------- ### C Example: Smallest Circle Source: https://www.mvtec.com/doc/halcon/13/en/smallest_circle Provides a C implementation example for finding the smallest circle. It involves reading an image, performing region growing and shape selection, calling the 'T_smallest_circle' function to get the circle parameters, and then generating and displaying the circle. ```C read_image(&Image,"fabrik"); open_window(0,0,-1,-1,0,"visible","",&WindowHandle); regiongrowing(Image,&Regions,5,5,6.0,100); select_shape(Regions,&SelectedRegions,"area","and",100.0,2000.0); T_smallest_circle(SelectedRegions,&Row,&Column,&Radius); T_gen_circle(&Circles,Row,Column,Radius); set_draw(WindowHandle,"margin"); disp_region(Circles,WindowHandle); ``` -------------------------------- ### Train OCV Project Example Source: https://www.mvtec.com/doc/halcon/13/en/traind_ocv_proj Example demonstrating how to create an OCV project handle, define a region of interest (ROI), reduce the domain of an image to the ROI, and then train the OCV project with the processed sample. ```C++ create_ocv_proj("A",&ocv_handle); draw_region(&ROI,window_handle); reduce_domain(Image,ROI,&Sample); traind_ocv_proj(Sample,ocv_handle,"A","single"); ``` -------------------------------- ### Get Camera Setup Parameters (API) Source: https://www.mvtec.com/doc/halcon/13/en/get_camera_setup_param Retrieves generic parameters from a camera setup model. This operator is available across multiple HALCON interfaces, including C, C++, and .NET, allowing flexible access to camera configuration settings. ```APIDOC get_camera_setup_param ( : : CameraSetupModelID, CameraIdx, GenParamName : GenParamValue) ``` ```C Herror get_camera_setup_param(const Hlong CameraSetupModelID, const Hlong CameraIdx, const char* GenParamName, double* GenParamValue) ``` ```C++ Herror T_get_camera_setup_param(const Htuple CameraSetupModelID, const Htuple CameraIdx, const Htuple GenParamName, Htuple* GenParamValue) ``` ```C++ Herror get_camera_setup_param(const HTuple& CameraSetupModelID, const HTuple& CameraIdx, const HTuple& GenParamName, double* GenParamValue) ``` ```C++ Herror get_camera_setup_param(const HTuple& CameraSetupModelID, const HTuple& CameraIdx, const HTuple& GenParamName, HTuple* GenParamValue) ``` ```C++ HTuple HCameraSetupModel::GetCameraSetupParam(const HTuple& CameraIdx, const HTuple& GenParamName) const ``` ```C++ void GetCameraSetupParam(const HTuple& CameraSetupModelID, const HTuple& CameraIdx, const HTuple& GenParamName, HTuple* GenParamValue) ``` ```C++ HTuple HCameraSetupModel::GetCameraSetupParam(const HTuple& CameraIdx, const HString& GenParamName) const ``` ```C++ HTuple HCameraSetupModel::GetCameraSetupParam(const HTuple& CameraIdx, const char* GenParamName) const ``` ```C++ HTuple HCameraSetupModel::GetCameraSetupParam(Hlong CameraIdx, const HString& GenParamName) const ``` ```C++ HTuple HCameraSetupModel::GetCameraSetupParam(Hlong CameraIdx, const char* GenParamName) const ``` ```.NET void HOperatorSetX.GetCameraSetupParam(VARIANT CameraSetupModelID, VARIANT CameraIdx, VARIANT GenParamName, out VARIANT GenParamValue) ``` ```.NET VARIANT HCameraSetupModelX.GetCameraSetupParam(VARIANT CameraIdx, BSTR GenParamName) ``` ```C++ static void HOperatorSet.GetCameraSetupParam(HTuple cameraSetupModelID, HTuple cameraIdx, HTuple genParamName, out HTuple genParamValue) ``` ```C++ HTuple HCameraSetupModel.GetCameraSetupParam(HTuple cameraIdx, string genParamName) ``` ```C++ HTuple HCameraSetupModel.GetCameraSetupParam(int cameraIdx, string genParamName) ``` -------------------------------- ### HALCON HComputeDevice Class API Source: https://www.mvtec.com/doc/halcon/13/en/HComputeDevice Comprehensive API documentation for the HALCON HComputeDevice class. This includes methods for opening, closing, activating, deactivating, initializing, querying, and setting parameters for compute devices. ```APIDOC HComputeDevice Class API Reference: Name: HComputeDevice — Class representing a compute device handle. Constructors: - OpenComputeDevice: Opens a compute device. Signature: OpenComputeDevice(DeviceType: string, Index: integer, StringParameter: string, IntegerParameter: integer, FloatParameter: float) Description: Opens a compute device, allowing for configuration via various parameter types. Finalizer/Destructor: - DeactivateComputeDevice: Deactivates a compute device. Signature: DeactivateComputeDevice(DeviceHandle: integer) Description: Releases resources associated with a specific compute device. Methods: - ActivateComputeDevice: Signature: ActivateComputeDevice(DeviceHandle: integer) Description: Activates a previously opened compute device for use. - DeactivateAllComputeDevices: Signature: DeactivateAllComputeDevices() Description: Deactivates all currently active compute devices. - DeactivateComputeDevice: Signature: DeactivateComputeDevice(DeviceHandle: integer) Description: Deactivates a specific compute device. - GetComputeDeviceInfo: Signature: GetComputeDeviceInfo(DeviceHandle: integer, InfoName: string) Description: Retrieves information about a compute device, such as its type, capabilities, or status. Parameters: - DeviceHandle: Handle to the compute device. - InfoName: The name of the information to retrieve (e.g., 'type', 'memory'). Returns: Information value as a string. - GetComputeDeviceParam: Signature: GetComputeDeviceParam(DeviceHandle: integer, ParamName: string) Description: Queries a specific parameter of a compute device. Parameters: - DeviceHandle: Handle to the compute device. - ParamName: The name of the parameter to query (e.g., 'max_threads'). Returns: The value of the specified parameter. - InitComputeDevice: Signature: InitComputeDevice(DeviceHandle: integer) Description: Initializes a compute device after it has been opened. - OpenComputeDevice: Signature: OpenComputeDevice(DeviceType: string, Index: integer, StringParameter: string, IntegerParameter: integer, FloatParameter: float) Description: Opens a compute device, allowing for configuration via various parameter types. - QueryAvailableComputeDevices: Signature: QueryAvailableComputeDevices(DeviceType: string) Description: Retrieves a list of available compute devices of a specified type. Parameters: - DeviceType: The type of compute device to query (e.g., 'gpu', 'cpu'). Returns: A tuple containing the number of devices and their handles. - ReleaseAllComputeDevices: Signature: ReleaseAllComputeDevices() Description: Closes all opened compute devices and releases their resources. - ReleaseComputeDevice: Signature: ReleaseComputeDevice(DeviceHandle: integer) Description: Closes a specific compute device and releases its resources. - SetComputeDeviceParam: Signature: SetComputeDeviceParam(DeviceHandle: integer, ParamName: string, ParamValue: string) Description: Sets a parameter for a compute device. Parameters: - DeviceHandle: Handle to the compute device. - ParamName: The name of the parameter to set. - ParamValue: The new value for the parameter. ``` -------------------------------- ### Set Display Part (C Example) Source: https://www.mvtec.com/doc/halcon/13/en/set_part Demonstrates setting the entire image to be displayed in the window and then drawing a rectangle to define a new display part, followed by displaying the selected part, using C syntax. ```C get_system("width",Width) ; get_system("height",Height) ; set_part(WindowHandle,0,0,Height-1,Width-1) ; disp_image(Image,WindowHandle) ; draw_rectangle1(WindowHandle,&Row1,&Column1,&Row2,&Column2) ; set_part(WindowHandle,Row1,Column1,Row2,Column2) ; disp_image(Image,WindowHandle) ; ``` -------------------------------- ### Get Icon Example in C Source: https://www.mvtec.com/doc/halcon/13/en/get_icon Demonstrates drawing a region and an icon, setting the icon, and then retrieving it using get_icon. ```C /* draw a region and an icon. */ /* set it and get it again. */ draw_region(&Region,WindowHandle) ; draw_region(&Icon,WindowHandle) ; set_icon(Icon) ; set_shape(WindowHandle,"icon") ; disp_region(Region,WindowHandle) ; get_icon(&OldIcon) ; disp_region(OldIcon,WindowHandle) ; ``` -------------------------------- ### HDevelop Example: Background Estimation Initialization and Execution Source: https://www.mvtec.com/doc/halcon/13/en/run_bg_esti Demonstrates initializing and running background estimation using HALCON's HDevelop. It shows reading images, creating a background estimation dataset with specific parameters, and then running the estimation to detect foreground regions. ```HDevelop * Read image for initialization: read_image(InitImage,'xing/init') * Initialize BgEsti dataset with * fixed gains and threshold adaption: create_bg_esti(InitImage,0.7,0.7,'fixed',0.002,0.02, \ 'on',7.0,10,3.25,15.0,BgEstiHandle) * Read the next image in sequence: read_image(Image0,'xing/xing000') * Estimate the background: run_bg_esti(Image0,ForegroundRegion1,BgEstiHandle) * Display the foreground region: dev_display (ForegroundRegion1) * Read the next image in sequence: read_image(Image1,'xing/xing001') * Estimate the background: run_bg_esti(Image1,ForegroundRegion2,BgEstiHandle) * Display the foreground region: dev_display (ForegroundRegion2) * etc. ``` -------------------------------- ### C Example: Querying Fonts Source: https://www.mvtec.com/doc/halcon/13/en/query_font Demonstrates how to use the T_query_font operator in C to get a list of available fonts and display them in the output window. ```C open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ; set_check("~text") ; create_tuple(&Fontlist,1) ; create_tuple(&String,1) ; create_tuple(&WindowHandleTuple,1) ; set_i(WindowHandleTuple,WindowHandle,0) ; T_query_font(WindowHandleTuple,&Fontlist) ; set_color(WindowHandle,"white") ; for(i=0; i : producer_proc() par_start : consumer_proc() * wait until both procedures have finished par_join ([ThreadID1, ThreadID2]) ``` -------------------------------- ### HDevelop Example: Coordinate Conversion Source: https://www.mvtec.com/doc/halcon/13/en/convert_coordinates_image_to_window Demonstrates the usage of convert_coordinates_image_to_window in HDevelop. The example reads an image, gets window extents, sets a display part, converts image coordinates of a generated rectangle to window coordinates, and converts a window center point back to image coordinates. ```HDevelop read_image (Image, 'printer_chip/printer_chip_01') dev_get_window (WindowHandle) get_window_extents (WindowHandle, Row, Column, Width, Height) dev_set_part (450, 300, 750, 600) dev_display (Image) * * Generate rectangle in image coordinates Row := [474, 746] Column := [314, 589] gen_rectangle1 (Rectangle1, Row[0], Column[0], Row[1], Column[1]) * Convert rectangle corner points to window coordinates convert_coordinates_image_to_window (WindowHandle, Row[[0,1,0,1]], \ Column[[0,0,1,1]], RowWindow, ColumnWindow) * * Window center in window coordinates WindowCenterRow := Height/2-1 WindowCenterColumn := Width/2-1 * Convert window center to image coordinates convert_coordinates_window_to_image (WindowHandle, WindowCenterRow, \ WindowCenterColumn, RowImage, ColumnImage) * * Display all points in image coordinates dev_display (Image) disp_cross (WindowHandle, Row[[0,1,0,1]], Column[[0,0,1,1]], 6, rad(45)) disp_cross (WindowHandle, RowImage, ColumnImage, 6, 0) ``` -------------------------------- ### HDevelop Example: Opening and Reading an I/O Channel Source: https://www.mvtec.com/doc/halcon/13/en/open_io_device Demonstrates the sequence of HDevelop operators to query available I/O interfaces, open an I/O device, query its channels, open a specific channel, and read data from it. ```HDevelop * Select a suitable i/o device interface of name IOInterfaceName query_io_interface (IOInterfaceName, 'io_device_names', DeviceNames) open_io_device (IOInterfaceName, DeviceNames[0], [], [], IODeviceHandle) query_io_channel (IODeviceHandle, [], 'io_channel_names.digital_input', ChannelInputNames) open_io_channel (IODeviceHandle, ChannelInputNames[0], [], [], IOChannelHandle) read_io_channel (IOChannelHandle, Value, Status) ``` -------------------------------- ### C Example: Draw Point Source: https://www.mvtec.com/doc/halcon/13/en/draw_point Shows the usage of the draw_point operator in C to get interactive point coordinates and subsequently draw a cross contour. ```C draw_point(WindowHandle,&Row,&Column) ; gen_cross_cross_contour_xld (&Cross, Row, Column, 6.0, 0.0) ; ``` -------------------------------- ### HALCON C Example: Drawing Circles Source: https://www.mvtec.com/doc/halcon/13/en/disp_circle An example demonstrating how to open a window, set drawing properties, and draw circles using mouse clicks in a C implementation with HALCON. ```C open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ; set_draw(WindowHandle,"fill") ; set_color(WindowHandle,"white") ; get_mbutton(WindowHandle,&Row,&Column,&Button) ; disp_circle(WindowHandle,Row,Column,(Row + Column) mod 50) ; ``` -------------------------------- ### C Example for entropy_image Source: https://www.mvtec.com/doc/halcon/13/en/entropy_image Illustrates the usage of the entropy_image operator in C. It shows how to read an image, display it using a window handle, compute the entropy, and then display the entropy image. ```C read_image(&Image,"fabrik"); disp_image(Image,WindowHandle); entropy_image(Image,&Entropy,9,9); disp_image(Entropy,WindowHandle); ``` -------------------------------- ### HDevelop Example for get_component_model_params Source: https://www.mvtec.com/doc/halcon/13/en/get_component_model_params Demonstrates how to read a component model and then retrieve its parameters using get_component_model_params. It also shows iterating through shape model IDs to get their parameters. ```HDevelop read_component_model ('pliers.cpm', ComponentModelID) get_component_model_params (ComponentModelID, MinScoreComp, RootRanking, \ ShapeModelIDs) for i := 0 to |ShapeModelIDs|-1 by 1 get_shape_model_params (ShapeModelIDs[i], NumLevels, AngleStart, \ AngleExtent, AngleStep, ScaleMin, ScaleMax, \ ScaleStep, Metric, MinContrast) endfor ``` -------------------------------- ### HDevelop Example: I/O Interface Operations Source: https://www.mvtec.com/doc/halcon/13/en/query_io_interface Demonstrates a sequence of HDevelop operations to query I/O interfaces, open an I/O device, query channels, open a channel, and read from it. ```HDevelop * Select a suitable i/o device interface of name IOInterfaceName query_io_interface (IOInterfaceName, 'io_device_names', DeviceNames) open_io_device (IOInterfaceName, DeviceNames[0], [], [], IODeviceHandle) query_io_device (IODeviceHandle, [], 'io_channel_names.digital_input', ChannelInputNames) open_io_channel (IODeviceHandle, ChannelInputNames[0], [], [], IOChannelHandle) read_io_channel (IOChannelHandle, Value, Status) ``` -------------------------------- ### Generate Circle Sector in C Source: https://www.mvtec.com/doc/halcon/13/en/gen_circle_sector Example of generating a circle sector region using the gen_circle_sector operator in C, including window setup, image reading, domain reduction, and display. ```C open_window(0,0,-1,-1,"root","visible","",&WindowHandle); read_image(&Image,"montery"); gen_circle_sector(&CircleSector,300.0,200.0,150.5,0,rad(120)); reduce_domain(Image,CircleSector,Mask); disp_color(Mask,WindowHandle); ``` -------------------------------- ### C Example for local_max Source: https://www.mvtec.com/doc/halcon/13/en/local_max Provides a basic C example showing the sequence of HALCON operators to read an image, compute corner responses, find local maxima, and display the results. ```C read_image(&Image,"fabrik"); corner_responce(Image,&CornerResp,5,0.04); local_max(CornerResp,&Maxima); set_colored(WindowHandle,12); disp_region(Maxima,WindowHandle); T_get_region_points(Maxima,&Row,&Col); ``` -------------------------------- ### C Background Estimation Example Source: https://www.mvtec.com/doc/halcon/13/en/update_bg_esti Example code demonstrating the initialization, running, and updating of background estimation using HALCON's C API. ```C /* read Init-Image: */ read_image(&InitImage,"xing/init") ; /* initialize BgEsti-Dataset with fixed gains and threshold adaption */ create_bg_esti(InitImage,0.7,0.7,"fixed",0.002,0.02, "on",7,10,3.25,15.0,&BgEstiHandle) ; /* read the next image in sequence: */ read_image(&Image0,"xing/xing000") ; /* estimate the Background: */ run_bg_esti(Image0,&Region1,BgEstiHandle) ; /* use the Region and the information of a knowledge base */ /* to calculate the UpDateRegion */ update_bg_esti(Image0,UpdateRegion,BgEstiHandle) ; /* then read the next image in sequence: */ read_image(&Image1,"xing/xing001") ; /* estimate the Background: */ run_bg_esti(Image1,&Region2,BgEstiHandle) ; /* etc. */ ``` -------------------------------- ### HDevelop Example: Point-Segment Distance Source: https://www.mvtec.com/doc/halcon/13/en/distance_ps Demonstrates how to use the distance_ps operator in HDevelop to find the minimum and maximum distances between a point and a line segment. It includes setup for window and drawing operations. ```HDevelop dev_open_window (0, 0, 512, 512, 'black', WindowHandle) draw_point (WindowHandle, Row, Column) gen_cross_contour_xld (Cross, Row, Column, 15, 0) draw_line (WindowHandle, Row1, Column1, Row2, Column2) gen_contour_polygon_xld (Contour, [Row1,Row2], [Column1,Column2]) distance_ps (Row, Column, Row1, Column1, Row2, Column2, \ DistanceMin, DistanceMax) ``` -------------------------------- ### Get HALCON Operator Information Source: https://www.mvtec.com/doc/halcon/13/en/get_operator_info Retrieves online texts and information concerning a specific HALCON operator. It allows querying various attributes or 'slots' of an operator, such as its description, parameters, and examples. ```APIDOC get_operator_info(OperatorName) - Retrieves information about a specified HALCON operator. - Parameters: - OperatorName: The name of the HALCON operator (string). - Available Slots (queryable via get_operator_info or query_operator_info): - 'short': Short description of the operator. - 'abstract': Detailed description of the operator. - 'chapter': Name(s) of the chapter(s) in the operator hierarchy. - 'functionality': The object class to which the operator can be assigned. - 'keywords': Keywords associated with the operator (optional). - 'example': Example usage of the operator. 'example.LANGUAGE' can be used to specify a language. - 'complexity': Complexity of the operator (optional). - 'effect': Currently not in use. - 'parallelization': Characteristic parallel behavior of an operator. - 'parallel_method': Method of automatic operator parallelization. - 'alternatives': Alternative operators (optional). - 'see_also': Operators containing further information (optional). - 'predecessor': Possible and sensible predecessor operators. - 'successor': Possible and sensible successor operators. - 'result_state': Return value of the operator (e.g., TRUE, FALSE, FAIL, VOID, EXCEPTION). - 'attention': Restrictions and advice concerning the correct use of the operator (optional). - 'parameter': Names of the parameters of the operator. - 'references': Literary references (optional). - 'module': The module to which the operator is assigned. - 'html_path': The directory where the HTML documentation resides. - 'warning': Possible warnings for using the operator. - 'compute device': List of compute devices supported by the operator. - Slot Notation: - Appending '.latex' to a slotname (e.g., 'short.latex') retrieves the text in LaTeX notation. - Related Operators: - get_operator_name: Retrieves the name of an operator. - query_operator_info: Retrieves information available for all operators (see Slot). - get_param_info: Retrieves information about operator parameters. - get_system / set_system: Used to manage system settings, including help directories. ``` -------------------------------- ### HDevelop Image Display and Drawing Example Source: https://www.mvtec.com/doc/halcon/13/en/open_window Demonstrates basic image processing operations in HDevelop, including opening a window, reading an image, displaying it, writing text, drawing a rectangle, and setting window properties. This script utilizes functions like open_window, read_image, disp_image, draw_rectangle1, and set_part. ```HDevelop open_window(0,0,400,-1,'root','visible','',WindowHandle) read_image(Image,'fabrik') disp_image(Image,WindowHandle) write_string(WindowHandle,'File, fabrik') new_line(WindowHandle) get_mbutton(WindowHandle,_,_,_) set_lut(WindowHandle,'temperature') set_color(WindowHandle,'blue') write_string(WindowHandle,'temperature') new_line(WindowHandle) write_string(WindowHandle,'Draw Rectangle') new_line(WindowHandle) draw_rectangle1(WindowHandle,Row1,Column1,Row2,Column2) set_part(WindowHandle,Row1,Column1,Row2,Column2) disp_image(Image,WindowHandle) new_line(WindowHandle) ``` -------------------------------- ### C Example: Detect Local Minima Source: https://www.mvtec.com/doc/halcon/13/en/local_min Provides a basic example in C for detecting local minima. It first reads an image, computes corner responses, and then applies the 'local_min' operator. Finally, it displays the resulting regions. ```C read_image(&Image,"fabrik"); corner_responce(Image,&CornerResp,5,0.04); local_min(CornerResp,&Minima); set_colored(WindowHandle,12); disp_region(Minima,WindowHandle); T_get_region_points(Minima,&Row,&Col); ``` -------------------------------- ### Get Image Pointer in C Source: https://www.mvtec.com/doc/halcon/13/en/get_image_pointer1 Example demonstrating how to use the get_image_pointer1 operator in C to obtain a pointer to image data, along with its type, width, and height. ```C Hobject Image; char typ[128]; Hlong width,height; unsigned char *ptr; read_image(&Image,"fabrik"); get_image_pointer1(Image,(Hlong*)&ptr,typ,&width,&height); ``` -------------------------------- ### Display Distribution (C) Source: https://www.mvtec.com/doc/halcon/13/en/disp_distribution Example demonstrating how to use the disp_distribution function in C to visualize a gray value distribution on a specified window. ```C open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ; set_draw(WindowHandle,"fill") ; set_color(WindowHandle,"white") ; read_image(Image,"monkey") ; draw_region(&Region,WindowHandle) ; noise_distribution_mean(Region,Image,21,&Distribution) ; disp_distribution (WindowHandle,Distribution,100,100,3) ; ```