JADAK VIDEO: Clarity Machine Vision Software – The Presence/Absence Plug-In – Part 1 and Part 2

This video demonstrates JADAK’s Clarity Machine Vision Software Presence/Absence Plugin. Find out why JADAK machine vision is used by more medical device companies and OEMs than any other vision provider.

*Want to learn more about JADAK’s Medical Machine Vision Platforms and Services?  Register for a Tech Consultation Day from the experts at JADAK! Also, be sure to visit our RFID Products and Services,  Barcode and Machine Vision pages.


Below is the video transcript.

Clarity 2.0 Machine Vision Software

Presence/Absence: Setting up the Scripts

In this video I’m going to show you how to use the Presence/Absence widget in Clarity. With Presence/Absence you can detect if something’s there or not there, depending on what you want to do. In this case I’m using pre-canned images that are on my desktop, which is normally how you’d develop a machine vision application, you would capture the images, you would store them on your laptop, and later on you would test in the live camera. And I’ll show you how to do that at the end.

What I’m going to do today is show you several different Presence/Absence functions. I’m going to show you how to detect if the test tube is present, I’m going to show you how to detect if the cap is present, and I’m going to show you how to detect if the barcode is present.

So let’s start out with the test tube body. I’m going to add a Presence/Absence widget [from the top menu bar]. You can see how it shows up over here in our step list [to the left]. Then I have this region of interest [highlighted block], so I’m going to place this region of interest right over the test tube itself. Then I’m going to select the Threshold method of Presence/Absence [below the image]. There are several different methods you can choose, so I’ll be exploring several of those today [at bottom below image].

The next thing I’m going to do is to set the pixel values that I want look at. So you can see how Clarity presents a histogram of the image that is up here. It’s actually of the region of interest at this point, and you can see how that histogram will change as I move the region of interest around [moving over picture with mouse]. I’m interested in this histogram here. So how I’m going to set this up is that I’m going to look for bright pixels, because if that test tube isn’t there I’m going to see this bright background. So I’m going to exclude below 200 [pixels]. I only want to be counting the bright pixels. I can set my threshold automatically or I can set it manually. In this case, I’m going to set it manually. Let’s set it up to 225 [moved the Threshold bar to 225]. I’m only going to look at pixels between 200 and 225, and I’m going to have a further threshold of above 225 where I’m going to consider them. Then I’m going to look at my Passing Range, and I’m going to set from 0 to 200 pixels. What this is saying is that if I have anywhere between 0 and 200 pixels that are above 224 counts, then my test tube is there. An alternate way to say it is here’s a case where my test tube is not there, and you can see I have over 7,000 of those bright pixels available, and so the step fails. I can set the name of that step to be “test tube present?” to make it more obvious what the step is actually doing.

Okay, the next thing I’m going to do is to add another present step to check for cap presence. So I’m going to add another step, and let’s make this step “cap present?” I’m going to go down here, and I’m going to select a different method to show you how it works. I’m going to select a Brightness method. Again, I have a region of interest, so I’m going to set that over this cap. And you can see my average value of Brightness, the average pixel value of that region is 67. And then I’m going to leave this alone, but I’m saying I only want to say the cap is there if this brightness value is low. So anywhere between 0 and about 150, if my average brightness value is between 0 and 150, then that cap is there. So let’s test that out. You can see my average value went to 255, because of this bright background I have, and so it fails because the cap is not there.

Now I’m going to go back to my first image. And I’m going to do one more thing, I’m going to look for that barcode. So let’s add another Presence/Absence step, and this time I’m going to choose the Edge Pixels method. In this barcode I have a lot of nice edges, which are the transitions between blacks and whites in the image. So I’m going to set up an area to look for those. Again, let’s change the name of our step to “barcode present?” I’m going to set my Edge Magnitude pretty high. I have really nice black and white edges here, so I’m not going to accept a magnitude transition between a black and a white that’s any less than 50 counts. Potentially I could make that higher, but I think it’s a pretty good value to start. The other thing I have to do is set the direction of the edges. That gets a little bit more complicated. So you can imagine on this dial that the center white circle is a pixel in the image. So you take any pixel in the image and it’s going to search in that horizontal direction looking for edges. We’re not interested in edges that are in this direction [moving dial in circle], we’re only interested in those barcode edges which are vertical in the image or orthogonal to this pixel. The other thing you should know is that Clarity sets up, is automatically looking for edges that go black to white. We’re also going to say we want to look for white to black edges. So this direction on the dial is white to black edges. You can see with this barcode that I have 729 Edge pixels. So what I’m going to do is change my pass criteria.  If I have anywhere between 100 and let’s say 2000 Edge pixels, then that barcode is present. Now let’s test it out.  Okay that’s good. It failed when there’s no tube present.  We have another image that the barcode is present, but the cap is not. Then I have another image where the tube is present, cap is present, but the barcode is turned around. You can see that also fails.

The last thing I’m going to do is add an output step. Now that we have Clarity running and working, we have to have some way of communicating the results to our host. So I’m going to take the output, and the first thing I’m going to do is for each of these steps I’m going to add some kind of text string and the results.

So let’s start out I’m going to add text, I’m going to add output, and I’m going to change this to “tube present.” Then I’m going to take the test tube present result. I’m going to take all of these parameters that I can output to. I can see all of these different parameters which I can output. I can output the result itself which is what I’m interested here, but I can also output the time, the number of pixels, the pixel count for that particular region of interest, the actual threshold used, and so on.

I’m going to add another text string and say “Cap Present,” then let’s add our Cap Present result. Then I’m going to add one more text string “Barcode Present,” and then let’s add our Barcode Present result. And now I can go and see what the output looks like. In this particular case, you can see Tube Present is true, Cap Present is true, and Barcode present is false.

I can run on this one [new image], where they should all be true, true, true. I can add a little delimiter here between these steps to make it clear. Next one, I get there’s no tube, no cap, no barcode. Then the last image, tube is there, cap is not there, but the barcode is there.

So this is a quick way you can take a look at using Presence/Absence to detect something in the image.

Video 2: Clarity Machine Vision Software

Presence/Absence Using the Scripts

I’m going to show you how to run the script in the device and test in the actual camera. I restarted Clarity and I’m going to select FM-5, which is the camera that we’re actually using here. Before I was working offline from images on my hard drive. Now I’m going to select USB, I know my camera is set up on Com6, and let’s click next. I already have the job loaded into the device. Now I’m just going to reload it here from the camera back to my PC. I’m going to acquire image. So now I have a good image here that I can test.

You can see my test tube in the fixture that I can test. I have a few different variations and I can play around with that test tube and see really what happens and how well I set up my script. To start you see the test tube is present, the cap is present, and the barcode is present. And all those different steps pass, which is a good thing.

So let’s just take the whole thing out [removed test tube] and run and everything should fail. Well that’s good. If that didn’t work, it would be very bad.

Now I’m going to take the cap off the test tube and set it off to the side there. We’re going to run it again. And hopefully everything will pass, except for cap presence. Which is exactly what it did.

Let’s put the cap back on, run again, and everything should pass this time.

The one thing I want to start playing with now is the barcode. Because the barcode can be rotated really anywhere, 360 degrees around this test tube. So let’s start first with it all the way around. Okay barcode is not present, which is good, because you can’t see any of it. But let’s see what happens if I just have that text in the front. Because I wouldn’t want to detect that text and have the camera think it’s a barcode. That failed, and it’s actually a good thing. Because you can see from the image from my area of interest that I have very little of the barcode in there but I have the text in there. So this is where you’re going to want to adjust our threshold to make sure we don’t detect handwriting or text like this as the barcode.

You can see I have 710 edge pixels, well I have my threshold at 700. So let’s raise that a ways, say 860 and see what happens. You can see it failed there. Now let’s just turn the barcode a little bit and see at what point it actually starts to pass. Okay, at 1038 pixels there, the barcode is turned mostly in front of the image, so that seems to be passing. So this is an example where we’d want to take a whole bunch of images of this barcode, maybe rotate that test tube in very controlled steps. And gather all those different images to make sure our script is actually performing the way we want it to.

Now that I’ve adjusted that threshold, I want to take that script and send it back to the device. There it is. And I’m also going to save the script to the hard drive.

That’s a quick presentation of how you would test the images and test the script in the device.



News & Resources

JADAK Releases Clarity 2.0 Machine Vision & Image Analysis Software

New Release Includes Enhanced Features and Two New Plug-Ins  

June 2, 2017

Machine Vision for Molecular Diagnostics

As the demand for differentiated molecular testing solutions continues to

June 2, 2017

WEBINAR: JADAK’s Smart RFID Technologies — Especially for European Market

Due to increased interest from our European audience, we are

June 2, 2017