In my program I do a DeviceFactory.Discover(DiscoverFlags.IncludeInaccessible) once.
Then give the DiscoveryInformation to a class which opens the connection and starts grabbing.
Is there an event that triggers when the camera is available? Or is polling with TryOpen the only way?
Polling is the only way. Technologies like e.g. GigE Vision only implement polling. Also this produces broad cast traffic which we try to minimize. You are more likely to know when it is ok to produces extra traffic .
And yes, there are devices that react allergic to broad casts…
this will be fixed in the next release.
I have attached the new dll.
Just replace it with the existing one at your CVB installation directory (%CVB%). CVFactory.zip (289.4 KB)
When I use your dll I sometimes get System.AccessViolationException, reverted back to the old dll, my solution works too and didn’t have the error yet:
System.AccessViolationException
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
StackTrace " at Stemmer.Cvb.ImgLib.LoadImageFile(String fileName, IntPtr& image)\r\n at Stemmer.Cvb.DeviceFactory.InternalTryOpen(String provider, Device& device)\r\n at Stemmer.Cvb.DeviceFactory.TryOpen(String provider, Device& device)\r\n at Stemmer.Cvb.DeviceFactory.TryOpen(DiscoveryInformation info, Device& device)\r\n at WpfApp1.CvbGrabber._OpenDevice() in C:\\ServerCopy\\19-0062 Pick and skewer\\Sync\\Test\\WpfApp1\\WpfApp1\\CvbGrabber.cs:line 84\r\n at WpfApp1.CvbGrabber._Polling_Elapsed(Object sender, ElapsedEventArgs e) in C:\\ServerCopy\\19-0062 Pick and skewer\\Sync\\Test\\WpfApp1\\WpfApp1\\CvbGrabber.cs:line 45\r\n at System.Timers.Timer.MyTimerCallback(Object state)\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.TimerQueueTimer.CallCallback()\r\n at System.Threading.TimerQueueTimer.Fire()\r\n at System.Threading.TimerQueue.FireNextTimers()" string
My setup has 2 camera’s, I open “Common Vision Blox Management Console” and select one under the GenICam Device Configurator.
In my own program I only connect to the one selected, then switch from device in CVBMC.
Camera’s in my setup:
in %CVB% I rename the CVFactory_new CVFactory_old depending on which I want to use.
Tested it again with latest code, now I sometimes get this error with both CVFactory dlls:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'VinDevice'.
at Stemmer.Cvb.Driver.VinDevice.get_Streams()
at Stemmer.Cvb.Device.get_Stream()
at WpfApp1.CvbGrabber._OpenDevice() in C:\ServerCopy\19-0062 Pick and skewer\Sync\Test\WpfApp1\WpfApp1\CvbGrabber.cs:line 96
I just saw that the siFilterDriver was missing because I did a reinstall of the software.
with old CVFactory dll I did a few tests and problem didn’t happen.
New one gave the problem above.
Hi @BenDevos,
could you explain again what exactly you are doing?
I tried your attached program and it seems to work for me when I have a camera connected with the ID “Meat”.
I also tried to disconnect the camera while it was being opened and then reconnected it while the polling was ongoing. After a short while the camera was loaded and the MainWindow showed up.
If there seems to be something wrong with your siFilterDriver I’d suggest completely uninstalling cvb and reinstalling it fresh.
Or is the procedure I am using to test your attached application wrong?
Our current setup has 7 camera’s and when one camera isn’t connected while our software starts up then that camera starts polling but this has a negative effect on the other 6 working camera’s I think?
Bad implementation at my part now is that each camera has its own polling. While this behavior should be implemented at factory level to reduce unnecessary polling requests.