0

I started working on a project with Halcon and initially I used HDevelop 21.11 Progress version.

Recently I imported the code to C# using MVTec.HalconDotNet NuGet package but I'm having issues when connecting to the camera with OpenFramegrabber, while the same code works fine in HDevelop.

This is the C# code that it's giving me issues:

HOperatorSet.OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8, "rgb", -1, "false", "[1] RGB8 (3088x2076)", "[1] UI588xCP-M_4103243856", -1, 1, out HTuple AcqHandle);
// HalconDotNet.HOperatorException

Full exception message:

HalconDotNet.HOperatorException: 'HALCON error #5302: Image acquisition: wrong device in operator open_framegrabber'

and this is the code in HDevelop:

open_framegrabber ('DirectShow',1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', '[1] RGB8 (3088x2076)', '[1] UI588xCP-M_4103243856', -1, 1, AcqHandle)

I already tried playing around with the parameters on the C# code but the issue persist.

The device is detected by InfoFramegrabber and the output is

{["[0] PC Camera", "[1] UI588xCP-M_4103243856"]}

but the InfoFramegrabber command with info_boards only return info about device:0 (the PC Camera) in C# while on HDevelop it returns both the devices.


NuGet package version: 21110.0.0
HDevelop version: 21.11 Progress

erik7854
  • 150
  • 1
  • 16
  • Have you checked to see if you have the correct device? – Robert Harvey Apr 11 '22 at 13:19
  • @RobertHarvey yes with `HOperatorSet.InfoFramegrabber("DirectShow", "device", out HTuple info, out HTuple valeus);` and the output is `{["[0] PC Camera", "[1] UI588xCP-M_4103243856"]}` – erik7854 Apr 11 '22 at 13:24
  • 1
    I usually avoid to connect to the camera using the Halcon framegrabber, I prefer connect using they SDK and create the HImage from the byte array of the image – Stefano Cavion Apr 28 '22 at 13:20

2 Answers2

2

I would highly recommend using the uEye interface for HALCON, so the complete camera parameter set is available. Otherwise, the settings you can adjust are limited in DirectShow interface.

Unfortunately, the uEye interface doesn't come with the HALCON installation anymore (compared to the past). Therefore, you must install it manually performing the following steps:

  1. Install uEye SDK (recommended newest version 4.96.1) with component "Interfaces/HALCON"

Since uEye SDK 4.96.1 the following steps are optional, cause the installer also moves the files to the correct destination:

  1. Go to uEye installation path (by default: C:\Program Files\IDS\uEye) and navigate to \interfaces\HALCON\x64\13.0 or in older versions (<4.95)\OtherDrivers\HALCON\13.0
  2. Copy the folders "bin" and "doc" to %HALCONROOT% (by default: C:\Program Files\MVTec\HALCON-21.11-Progress) and the folder "examples" to C:\Users\Public\Documents\MVTec\HALCON-21.11-Progress

After completing these steps, the camera should be accessible via name 'uEye' in open_framegrabber() and default parameters.

0

Can you please go to: Assistants -> Image Acquisition -> Source tab and click Auto-detect Interfaces?

Then go to Connection tab in Image Acquisition Assistant click Connect and then Code Generation tab in Image Acquisition Assistant and check Code Preview for open_framegrabber operator

09 try
  • 26
  • 3
  • The generated code with default parameters differ only in the cameraType parameter: `open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[1] UI588xCP-M_4103243856', 0, -1, AcqHandle)` and even after setting it to `'default'` the issue persists. I can connect successfully from the image assistant even with the cameraType to `[1] RGB8 (3088x2076)` – erik7854 Apr 12 '22 at 08:45
  • Could you please modify the camera name to not use underscore and try to connect? I have found this on MVTEC website: If the board identifier contained more than one underscore it was not possible to use the device identifier as device string in open_framegrabber. The call of open_framegrabber failed with error 5302. Or try to rename camera to something simple e.g.: CAM1 and then try to connect. – 09 try Apr 12 '22 at 09:04
  • Also I guess it's GiGE camera? I would try to change interface from DirectShow to GigEVision or GigEVision2. – 09 try Apr 12 '22 at 09:19
  • Changing the name didn't help, I can connect to the camera with HDevelop but not in C#. Yes, it is a GigE uEye camera but it's only detected in DirectShow mode (also for uEye mode, `hAcquEye.dll` is missing in `%HALCONROOT%\bin\%HALCONARCH%` even after installing all the available packages so cannot use that ether) – erik7854 Apr 12 '22 at 09:52
  • If it's possible to connect to camera in HDevelop via open_framgrabber then as a workaround until you solve it I would suggest creating procedure in Halcon for camera connection, exporting it as library project functionality in HDevelop and calling it from C#. – 09 try Apr 12 '22 at 10:17
  • I would rather use that as my last option, thanks for your help – erik7854 Apr 12 '22 at 12:47