Run Advanced Sample with OpenCV

You are viewing an old version of the documentation. You can switch to the documentation of the latest version by clicking the top-right corner of the page.

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

Install OpenCV

  1. Download and install OpenCV (C# version), namely, OpenCvSharp. Please note down the directory of OpenCvSharp.

  2. Find the MechDLCShapeWithOpenCVSamples.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 ImageInferWithOpenCV  References. 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 OpenCvSharp, find and select the OpenCvSharp.dll file from the path xxx\ManagedLib\net461 and then click Add.

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

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

Build the Sample

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

    csharp build opencv 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.
  5. In the directory OpenCvSharp, copy and paste the OpenCvSharpExtern.dll file in the directory of NativeLib\win\x64 to the path xxx\mechdlk_sdk\samples\csharp\bin.

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 opencv 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.