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