I am new to Common Vision Blox Software and I read that it is possible using Image Manager to setup a device emulation without having a physical camera, but I cant find where the Image Manager is or how to start it. Could someone guide me ? I did look in my installed applications but couldnt find it, also in the Applications folder of the CVB Installation it is not located. Does it even come with the normal CVB Installation? I installed CommonVisionBlox 13.00.005 (x64).exe + the Common Vision Blox Bindings Preview (x64).exe (for .NET bindings).
I dont have a physical camera (yet) but want to get started with WPF by simulating a device.
Is that possible?
Thanks in advance.
“Image Manager” is the package name for a number of DLLs (CVCImg.dll, CVCDriver.dll, CVCDisp.dll, CVCUtilities.dll, CVGenApi.dll), a set of ActiveX controls (CVDisplay.ocx, CVImage.ocx, CVGrabber.ocx, CVGenApiGrid.ocx, CVRingBuffer.ocx and the soon deprecated CVLinescan.ocx), the Overlay Plugins that are usable with the CVDisplay.ocx and the Stemmer.Cvb.Forms.Controls.Display control in the CVB.Net wrapper and of course the GenICam.vin and the GenApi implementation that comes with (I won’t list the details here as you won’t interact with them directly as a programmer).
If you have installed any component of or just the CameraSuite you definitely have the Image Manager available and can use it. There are actually three possibilities to emulate hardware with
- You can use an AVI file. In the classic API as well as in the CVB.Net API you can simply open an AVI file like you’d open a Bitmap file. @parsd gave a nice description in his Getting Started with CVB.Net post and pointed out useful sample applications that come with the Bindings Preview.
- The other alternative is using so-called “EMU” files. These files are simply text files that follow a simply syntax to define a list of images to be loaded sequentially (for an example please have a look at the File %CVB%\Tutorial\ClassicSwitch.emu). Note that all the images to be used must use the same size and pixel format. Once loaded an *.emu file will behave like a very simple frame grabber.
- The most sophisticated way would be the GigE Vision Server tool (which requires a license on top of the Image Manager). This utility allows you to define a virtual GigE camera complete with Node Map and all that can be used with - or with any other software capable of talking with a GigE Vision camera.
I hope that helps. I not then simply come back for more answers
Thanks for that information,
could you give me more information about those AVI files? I only know windows AVI video movie files, is that meant?
Because I tried to load an .avi video file and it throwed an empty cvb exception.
Yes, AVI files means the common “audio video interleaved” files that have been around since the first versions of Windows. Using the C-API you’d just load them with
LoadImageFile(myFileName, myImg); and may subsequently use
myImg with all sorts of function call that are intended for frame grabbers (like
CanGrab2 for querying whether it has an IGrab2 interface - it should! - or
G2Grab/G2Wait/G2Freeze for streaming.
When using the new CVB.Net API the approach is slightly different: The C-Api did not make any distinction between bitmaps, frame grabbers, videos etc. on the syntactic level - it’s always necessary to query the capabilities of a given
IMG handle at runtime (this basically is a by-product of modelling an “is a” relationship with a language - in this case C - that neither supports inheritance nor overloading). With languages that support type polymorphism such a relation ship is of course modeled using inheritance. When designing the new APIs we also wanted to make a distinction between the image handle (needed to access the image data and properties) and the stream handle (needed to control the flow of images). Therefore the CVB.Net API differs from the C-API in that
new Stemmer.Cvb.Image(myFileNyme); will only work on bitmap images and throw when trying to load something that isn’t a bitmap (although the exception’s message should rather be “Loading the Image from file failed”).
To open an *.avi (or *.emu or *.vin) file in CVB.Net please use the static
Stemmer.Cvb.DeviceFactory.Open() method. It’ll return an object derived from
Stemmer.Cvb.Device - if it is an *.avi file you opened this will be a
Stemmer.Cvb.Driver.VideoDevice - on which you may access the stream and image like this:
var myDevice = DeviceFactory.Open("<path to *.avi or *.emu or *.vin>");
var myStream = d.Stream;
var myImage = d.DeviceImage;
When working with WPF you can in the simplest of cases just store
myDevice in a Dependency Property and then bind to the relevant members. This here is a simplified version of the WpfGenICam example that comes with the Bindings Preview reduced to what you’ need for AVI playback: WpfGenICam.zip (10.8 KB)
If you already followed this advice but keep getting an exception then there is also a chance that the *.avi you are trying to open cannot be opened. Reasons for this may be subtle. For example if your application runs as a 64 bit process but the codec necessary to replay the video is only available as a 32 bit component you’d end up with an exception. You’d also experience similar behavior when trying to run your AVI-playback in a 32 bit application on a 64 bit installation of (the x64 installer comes with just enough Image Manager components to enable use of the display in the Visual Studio forms designer but the 32 bit components are not fully functional; there are plans to build a hybrid-capable setup in a later version of the product but that will require some breaking changes to the API).
and again thanks for the complex answer.
Yes I was about to use WPF because I want to create a small application which communicates via TwinCat.Ads. When getting triggered it should snap and save the image to the hard drive.
This project is not in hurry but I want to slowly get known to CVB since the old software is also done with CVB but the old GenICamExample with WinForms which is kinda buggy with the Forms Designer and additionally I like to work with up 2 date software.
But back to the topic: I just converted some mp4 to avi and tried to load that with CVB.Net for Wpf FileDialogs class. That throw an exception but it is always empty, also the inner exception is empty, very weird.
I will try by just using DeviceFactory.Open() when I am home. Thanks for your great explanation and for taking the time
Edit: Okay, I tried it out, and got it finally working, inspired by the GenICam WPF example I have a solid base now.
I am not yet familiar enough with WPF to know the most basic stuff, to be exact, dependency properties are still a mystery to me but I am learning it.
I created a class inheriting from DependencyObject called DeviceDependency defining the DeviceDependency Property.
In my ViewModel I am instantiating this class and the View Binds to the DeviceImage of that DependencyProperty. Whenever I click a button (for now) it calls Device.Stream.GetSnapshotAsync() and that seems to work fine with a .AVI file now. I guess later when I got a camera, discovering it with the GenApi.vin driver and then using it like I was using the AVI now with GetSnapshot will work the same way ?! But that is something for future, just wanted to explore a little how everything is working. Now figuring out if it’s disposing everything fine as later this program has to handle and save at least 20-30 images per minute to hard disk.
Thanks again for helping me out