Run Advanced Sample with HALCON

You are currently viewing the documentation for the latest version (2.1.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

You can build and run the provided sample by the following instructions if you have completed all operations required in the Prerequisites section.

Install HALCON

  1. Download and install HALCON (C# version). Please note down the directory of HALCON.

  2. Find the MechDLCShapeWithHalconSamples.sln file under xxx\mechdlk_sdk\samples\csharp and double-click the file to open the solution in Visual Studio.

  3. In the Solution Explorer panel, select ImageInferWithHalcon  References. Then, right-click References and select Add Reference.

  4. In the pop-up Reference Manager dialog box, click Browse in the lower-right corner.

  5. In the directory of HALCON, find and select the halcondotnet.dll file from the path xxx\bin\dotnet35 and click Add.

  6. In the Reference Manager dialog box, click OK to finish reference adding.

The provided sample was tested with HALCON 20.11.1.2. The directory of the DLL file may differ for different HALCON versions. Please follow the above steps according to the actual situation.
csharp add halcon

Build the Sample

  1. In the Visual Studio menu bar, select Build  Build Solution. An executable file is generated and saved to the bin folder (xxx\mechdlk_sdk\samples\csharp).

    csharp build halcon sample
  2. Copy and paste the resources folder under the project folder to the path xxx\mechdlk_sdk\samples\csharp\bin.

  3. Copy and paste all files in the 3rd_dll folder under the project folder to the path xxx\mechdlk_sdk\samples\csharp\bin.

    Ensure that only the files in the 3rd_dll folder are copied and pasted to the destination path, not the folder itself.
  4. Copy and paste all files in the mechdlk_sdk\dll directory under the project folder to the path xxx\mechdlk_sdk\samples\csharp\bin.

    Ensure that only the files in the mechdlk_sdk\dll folder are copied and pasted to the destination path, not the folder itself.
To run any C# sample in Mech-DLK SDK, you only need to perform Steps 2, 3, and 4 once.

After you complete the copy, the destination folder should contain the following types of files (the filenames may vary):

copy files to directory

Run the Sample

You can run the sample in Visual Studio after building it, or you can run the sample by double-clicking the executable file.

Run the Sample in Visual Studio

  1. In the Solution Explorer panel, right-click the sample and select Set as Startup Project.

    startup project csharp halcon sample
  2. Click Start on the toolbar to run the sample.

Run the Executable File of the Sample

In the bin folder (path: xxx\mechdlk_sdk\samples\csharp\bin), double-click the executable file named after the sample to run the sample and obtain results.

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.