0:00:11.581,0:00:14.226 Hello my name is Sascha Dorenbeck. 0:00:14.386,0:00:16.490 I'm Image Processing Senior Developper at STEMMER IMAGING. 0:00:16.828,0:00:25.096 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). 0:00:25.096,0:00:30.374 We're doing the application in Microsoft Visual Studio and I chose C#. 0:00:30.374,0:00:37.513 We can use any supported Common Vision Blox language but for simplicity and speed I simply chose C#. 0:00:37.513,0:00:44.733 First, we need to create a C# project, so I click on "New project". 0:00:44.733,0:00:48.894 Here, I make sure that I select the "Windows Forms" application 0:00:48.894,0:00:57.378 and give our example application a good name like "CVB Display". 0:00:57.378,0:01:04.060 Check that we have "Windows Forms" application and a nice name, then click OK. 0:01:04.060,0:01:09.089 After a short while you will see the form we will work on now. 0:01:09.089,0:01:14.547 First, we need to import the Common Vision Blox Active X controls to work with. 0:01:14.547,0:01:21.801 To do that, scroll down on the toolbox to the general tab and right-click on the area here 0:01:21.801,0:01:27.453 and in the context menu shown here you click on "Choose items". 0:01:28.238,0:01:34.480 In this dialoge we simply switch to "Com components tab" because Active X Controls are also com components. 0:01:34.480,0:01:37.265 We need two Active X Controls. 0:01:37.265,0:01:41.387 The first one is Common Vision Display control. 0:01:41.387,0:01:45.397 And the next one would be the Common Vision Image control. 0:01:45.397,0:01:49.908 Select both and click OK. 0:01:49.908,0:01:55.703 After that, we see that we have both the display and the image control in our tab. 0:01:55.703,0:02:00.547 Select the display control and left-click in the form. 0:02:00.547,0:02:06.081 Now Visual Studio will import the Active X Control in our Microsoft Visual Studio project. 0:02:06.081,0:02:09.923 The display is now shown here so we position it a bit. 0:02:09.923,0:02:16.809 As you would guess probably the display is used to display images or video streams. 0:02:16.809,0:02:22.764 To control the image streams, we use the Common Vision Blox image control. 0:02:22.764,0:02:27.984 So we also put it into our form. 0:02:29.476,0:02:34.359 What's important: the image control is not a visual user interface control, 0:02:34.359,0:02:37.568 it just helps us to implement our form or processing, 0:02:37.568,0:02:42.071 so you can position it anywhere it won't be shown later in the application. 0:02:42.071,0:02:44.031 So these are our core components 0:02:44.031,0:02:49.736 but we want to do something with it so we add a few other controls to control what we are doing. 0:02:49.736,0:02:54.712 First, we need a button, so we put the button in here 0:02:54.712,0:02:58.565 and we need a checkbox. 0:02:59.565,0:03:04.012 Position it, align it and we're done. 0:03:04.012,0:03:07.204 Now what do we want to do with the button? 0:03:07.204,0:03:12.884 This we use to open an image source for CVB which is called a driver. 0:03:12.884,0:03:20.522 So we give it a nice name and call it "Open button". 0:03:20.522,0:03:24.966 This would be the name we use later on in the source code. 0:03:24.966,0:03:30.701 And we need also a nice name for our user so we name this button "Open". 0:03:30.701,0:03:36.705 To do that we select a text property and give it a readable name which is then displayed on the button. 0:03:36.705,0:03:40.752 We also want to start or stop the aquisition. 0:03:41.292,0:03:43.704 For that, we go to the checkbox 0:03:43.704,0:03:49.165 and in CVB we call starting / stopping acquisition or acquisition handling in general grabbing. 0:03:49.856,0:03:54.561 Grabbing comes from the term frame grabber, so we grab an image. 0:03:54.561,0:03:59.313 So we call this checkbox "Grab checkbox" 0:03:59.313,0:04:02.847 and also have a nice display text for it. 0:04:03.078,0:04:06.431 We simply call it "Grab". 0:04:06.769,0:04:09.494 This is everything we need for our form. 0:04:09.494,0:04:12.509 So we now want to fill it with life. 0:04:12.509,0:04:20.900 So we go to the open button and double-click it to wire its click event handler. 0:04:20.900,0:04:24.210 So now we have an event function which is called on a click. 0:04:24.210,0:04:30.629 And to open a CVB image source we can use the image Active X Control. 0:04:30.629,0:04:36.205 Active X Controls are always prefixed by default with an AX in Visual Studio. 0:04:36.205,0:04:40.007 So if I type AX I see all Active X Controls 0:04:40.007,0:04:49.227 and go to the image control as utility method on this control which is called "load image" by dialogue. 0:04:49.227,0:04:54.881 This opens a file dialogue to choose a CVB driver. 0:04:55.897,0:05:02.691 To check if everything went OK, we put an if-clause around it. 0:05:04.062,0:05:09.763 If the function succeeds it returns true and we can go to the if body. 0:05:09.763,0:05:17.895 If everything is successful we need to make the display aware of the image we now loaded. 0:05:17.895,0:05:23.905 To do that we go via display 0:05:23.905,0:05:26.530 and use its image property. 0:05:26.530,0:05:29.093 This image property represents a CVB image. 0:05:29.093,0:05:37.373 So we need to simply assign the image property of the image control we used before loading the image 0:05:37.373,0:05:40.460 and assigning it to the display. 0:05:40.460,0:05:45.799 So now the display knows about the loaded image. 0:05:45.799,0:05:51.032 This is fine so far but we now want to enable and disable the grab, so life acquisition. 0:05:51.032,0:05:55.985 So we go to the "Grab" checkbox and also double-click it to wire the check / change event. 0:05:58.246,0:06:05.823 To enable and disable the grab we can use the image control's grab property. 0:06:05.823,0:06:08.333 This is a Boolean value. 0:06:08.333,0:06:11.432 If set to true the grab is enabled, so life acquisition is on. 0:06:11.432,0:06:15.571 And if false, life acquisition is disabled. 0:06:15.571,0:06:18.958 The grab checkbox we used before has a nice property. 0:06:18.958,0:06:23.727 It's called checked which is true if it's checked and false if not, 0:06:23.727,0:06:27.330 so simply enabling / disabling all acquisition. 0:06:27.330,0:06:30.107 So now we enabled the grab but we want to see images. 0:06:30.107,0:06:33.660 So we need to tell the display that the new image arrived in the system. 0:06:33.660,0:06:39.999 To do that, we go again to the image control and go to the "Events". 0:06:39.999,0:06:44.879 You need to do this here because the event we're using now is not a default event. 0:06:44.879,0:06:48.630 So we go now to the image snapped event. 0:06:48.630,0:06:51.996 This is called always when a new image arrives in the system. 0:06:51.996,0:06:57.456 To wire it, simply double-click in the text control right next to it. 0:06:57.456,0:07:01.208 What we simply want to do here is tell the display to redraw itself. 0:07:01.208,0:07:06.797 So we go to the display and call the refresh method. 0:07:06.797,0:07:12.068 That's all we need currently to show an image and grab it. 0:07:12.068,0:07:15.491 So we can fire up the application. 0:07:15.491,0:07:17.487 Now we see the application here. 0:07:17.487,0:07:21.561 I prepared a simple camera set-up with a GigE Vision camera. 0:07:21.561,0:07:25.063 So we want to open the GigE Vision camera. 0:07:25.063,0:07:29.739 We click on the "Open" button and now we get a file dialogue. 0:07:29.739,0:07:34.391 There's a simple or handy shortcut: you can use the environment variable CVB. 0:07:34.391,0:07:44.426 So you type %CVB% and then Enter which directly brings you to the Common Vision Blox directory on your disc. 0:07:44.426,0:07:47.424 Here you can go to the "Drivers" subdirectory 0:07:47.424,0:07:51.048 and now select the GenICam driver. 0:07:51.048,0:07:56.191 So you can see the driver by the Common Vision Blox symbol in front of it. 0:07:56.191,0:08:01.839 A GigE Vision device is a GenICam device so we can open it with a GenICam driver. 0:08:02.792,0:08:05.833 So we now open it 0:08:05.833,0:08:09.486 and we see it acquired a first image. 0:08:09.486,0:08:12.236 So now we want to introduce a life stream. 0:08:12.236,0:08:15.267 I can simply click on "Grab" 0:08:15.267,0:08:19.967 and if I now move the part a bit you see we have a life image. 0:08:19.967,0:08:26.734 So this is all you need to do to bring a life image in with CVB. 0:08:29.011,0:08:31.286 So to summarize everything: 0:08:31.286,0:08:37.069 you just need four simple lines of code to load an image source 0:08:37.069,0:08:41.198 which is done here by "load image by dialogue" 0:08:41.198,0:08:46.933 or you can use "load image" if you have a hard wired driver you want to use. 0:08:46.933,0:08:51.031 Then we need to make the image source known to the display 0:08:51.031,0:08:58.409 which we do here by assigning the image properties from the image handling control / the image control to the display control. 0:08:58.409,0:09:00.940 Then we want to enable / disable the grabbing, 0:09:00.940,0:09:08.817 so the life streaming which we do via the grab property by simply assigning the checked state. 0:09:08.817,0:09:12.190 And if a new image arrives we have the image snapped event 0:09:12.190,0:09:16.169 and here we simply tell the display to re-draw itself. 0:09:16.169,0:09:21.981 So these are the only four lines of Common Vision Blox source code you need. 0:09:22.551,0:09:29.651 This training was about to show how easy it is to acquire and display an image with Common Vision Blox. 0:09:29.651,0:09:34.528 For additional information on Common Vision Blox, additional trainings and onsite trainings, 0:09:34.528,0:09:37.596 please visit our website www.stemmer-imaging.com