Hello my name is Sascha Dorenbeck.
I'm Image Processing Senior Developper at STEMMER IMAGING.
Today, I'm in the STEMMER IMAGING European Training Center and I will talk about how easy it is to acquire and display an image with Common Vision Blox (CVB).
We're doing the application in Microsoft Visual Studio and I chose C#.
We can use any supported Common Vision Blox language but for simplicity and speed I simply chose C#.
First, we need to create a C# project, so I click on "New project".
Here, I make sure that I select the "Windows Forms" application
and give our example application a good name like "CVB Display".
Check that we have "Windows Forms" application and a nice name, then click OK.
After a short while you will see the form we will work on now.
First, we need to import the Common Vision Blox Active X controls to work with.
To do that, scroll down on the toolbox to the general tab and right-click on the area here
and in the context menu shown here you click on "Choose items".
In this dialoge we simply switch to "Com components tab" because Active X Controls are also com components.
We need two Active X Controls.
The first one is Common Vision Display control.
And the next one would be the Common Vision Image control.
Select both and click OK.
After that, we see that we have both the display and the image control in our tab.
Select the display control and left-click in the form.
Now Visual Studio will import the Active X Control in our Microsoft Visual Studio project.
The display is now shown here so we position it a bit.
As you would guess probably the display is used to display images or video streams.
To control the image streams, we use the Common Vision Blox image control.
So we also put it into our form.
What's important: the image control is not a visual user interface control,
it just helps us to implement our form or processing,
so you can position it anywhere it won't be shown later in the application.
So these are our core components
but we want to do something with it so we add a few other controls to control what we are doing.
First, we need a button, so we put the button in here
and we need a checkbox.
Position it, align it and we're done.
Now what do we want to do with the button?
This we use to open an image source for CVB which is called a driver.
So we give it a nice name and call it "Open button".
This would be the name we use later on in the source code.
And we need also a nice name for our user so we name this button "Open".
To do that we select a text property and give it a readable name which is then displayed on the button.
We also want to start or stop the aquisition.
For that, we go to the checkbox
and in CVB we call starting / stopping acquisition or acquisition handling in general grabbing.
Grabbing comes from the term frame grabber, so we grab an image.
So we call this checkbox "Grab checkbox"
and also have a nice display text for it.
We simply call it "Grab".
This is everything we need for our form.
So we now want to fill it with life.
So we go to the open button and double-click it to wire its click event handler.
So now we have an event function which is called on a click.
And to open a CVB image source we can use the image Active X Control.
Active X Controls are always prefixed by default with an AX in Visual Studio.
So if I type AX I see all Active X Controls
and go to the image control as utility method on this control which is called "load image" by dialogue.
This opens a file dialogue to choose a CVB driver.
To check if everything went OK, we put an if-clause around it.
If the function succeeds it returns true and we can go to the if body.
If everything is successful we need to make the display aware of the image we now loaded.
To do that we go via display
and use its image property.
This image property represents a CVB image.
So we need to simply assign the image property of the image control we used before loading the image
and assigning it to the display.
So now the display knows about the loaded image.
This is fine so far but we now want to enable and disable the grab, so life acquisition.
So we go to the "Grab" checkbox and also double-click it to wire the check / change event.
To enable and disable the grab we can use the image control's grab property.
This is a Boolean value.
If set to true the grab is enabled, so life acquisition is on.
And if false, life acquisition is disabled.
The grab checkbox we used before has a nice property.
It's called checked which is true if it's checked and false if not,
so simply enabling / disabling all acquisition.
So now we enabled the grab but we want to see images.
So we need to tell the display that the new image arrived in the system.
To do that, we go again to the image control and go to the "Events".
You need to do this here because the event we're using now is not a default event.
So we go now to the image snapped event.
This is called always when a new image arrives in the system.
To wire it, simply double-click in the text control right next to it.
What we simply want to do here is tell the display to redraw itself.
So we go to the display and call the refresh method.
That's all we need currently to show an image and grab it.
So we can fire up the application.
Now we see the application here.
I prepared a simple camera set-up with a GigE Vision camera.
So we want to open the GigE Vision camera.
We click on the "Open" button and now we get a file dialogue.
There's a simple or handy shortcut: you can use the environment variable CVB.
So you type %CVB% and then Enter which directly brings you to the Common Vision Blox directory on your disc.
Here you can go to the "Drivers" subdirectory
and now select the GenICam driver.
So you can see the driver by the Common Vision Blox symbol in front of it.
A GigE Vision device is a GenICam device so we can open it with a GenICam driver.
So we now open it
and we see it acquired a first image.
So now we want to introduce a life stream.
I can simply click on "Grab"
and if I now move the part a bit you see we have a life image.
So this is all you need to do to bring a life image in with CVB.
So to summarize everything:
you just need four simple lines of code to load an image source
which is done here by "load image by dialogue"
or you can use "load image" if you have a hard wired driver you want to use.
Then we need to make the image source known to the display
which we do here by assigning the image properties from the image handling control / the image control to the display control.
Then we want to enable / disable the grabbing,
so the life streaming which we do via the grab property by simply assigning the checked state.
And if a new image arrives we have the image snapped event
and here we simply tell the display to re-draw itself.
So these are the only four lines of Common Vision Blox source code you need.
This training was about to show how easy it is to acquire and display an image with Common Vision Blox.
For additional information on Common Vision Blox, additional trainings and onsite trainings,
please visit our website www.stemmer-imaging.com