Delphi - Detect Unplugging of Camera/CVB Component Method Link-up


We have a software program coded in Delphi which we have recently been adding CVB functionality to after moving from a different brand of cameras.

We use TCVImage, TCVRingBuffer and TCVGrabber components and some of the associated functions and all the code complies and runs correctly.

  1. One additional bit of functionality I would like to add would be to catch if a CVB camera is connected or disconnected to the machine so that this can be displayed/dealt with more smoothly. GenICam Browser appears to produce a diag line when disconnection happens - is there a Delphi example of how to catch this, please, as I tried to look through the documentation but most of it was in other languages and I was struggling to work out how to translate it!

  2. Secondly, rather than using CVB components as components of the form, we have coded it such that global instances of the components are made during the setup process of the program. (eg cvGrabbers := TCVGrabber.Create(nil))
    Therefore, we have had to link any component methods at runtime too (eg cvImgs.OnImageSnaped := TCVBMethods.CVBImgImageSnaped and cvImgs.OnCVCError := TCVBMethods.CVBImgCVCError where I have set up TCVBMethods as a Delphi class).
    For some reason, some of these functions seem to link up and work correctly, but some don’t - eg, here, the error one works fine but the snaped one doesn’t. Do you have any idea why this would be?



Hi @danielquintic

sorry for the late reply.

  1. Disconnect/Reconnect
    • This feature is not accessible through the ActiveX controls. If you need to access this in Delphi, the only way is through the INotify functions in the C-API (iCVCDriver.pas, line 528 to 534 in the file shipped with CVB
    • The events to register callbacks for are CVNO_EID_DEVICE_DISCONNECTED and CVNO_EID_DEVICE_RECONNECT and in the callbacks react to how you see fit.
    • Keep in mind, though, that the callbacks may be raised from a thread other than the main thread of your process, making it necessary to take extra precautions if you need/want to modify UI elements from within the callback.
    • Also note that in the reconnect case, it will be necessary to restart the acquisition outside the callback, which can make things a bit complicated (at least if you want image acquisition to automatically resume if a disconnect + reconnect occurred).

Generally speaking, it would advise against ambitious disconnect/reconnect behavior mixing TCVImage (= ActiveX control) and CVCDriver.dll usage. Giving your user a status update and stopping the Grab should be feasible, anything beyond that will be very challenging.

  1. I am sorry, but I don’t think I can help you with that. From looking at the signatures I would not understand why CVCError comes through while ImageSnaped (sic!) - which has no parameters and no return value - is not marshalled, but my knowledge about how Delphi wraps and interfaces to ActiveX controls is fairly limited.

Sorry for the slow reply.

  1. I will take a look at doing a simple “disconnected” message when the disconnected event is thrown and get back to you if I struggle! Sounds like anything more will be tricky.

  2. OK - I couldn’t understand why either - I will check the parameters etc again to make sure they match - is there anyone else who could advise on this?