16
1 Visual Control Plugin for EasyPLC v.5

Visual Control Plugin

Embed Size (px)

DESCRIPTION

Manual del módulo de visión artificial de easyPLC

Citation preview

Page 1: Visual Control Plugin

1

Visual Control Plugin for EasyPLC v.5

Page 2: Visual Control Plugin

2

Table of Contents

1. Visual Control Editor

2. Visual Control Plugin

Page 3: Visual Control Plugin

3

www.nirtec.com

Page 4: Visual Control Plugin

4

Visual Control for EasyPLC

This guide helps you to use the Visual Control Plugin for the EasyPLC Software Suite.

The Visual Control Plugin allows you to use a simple webcam, as system of optic recognition.

You will be able to add to your logic programs a big quantity of resources, you will be able to take photographs in certain moments, to recognize parts/elements in function of their color, or for example, to activate a relay when the camera detects movement in the area or areas that previously you have configured.

Page 5: Visual Control Plugin

5

From left panel, select the video source you have available in your system (previously you have to install your webcam drivers) and select the resolution you want to use in the bottom combo box. Press Start Button to preview the webcam image. Press Camera Properties to access to your webcam image properties. Press Take Photo button to save the webcam image in your hard disk as a photograph.

1. Visual Control Editor

The Visual Control Editor is a stand-alone application that allow you to configure the Visual Control Plugin, in order to select the camera to use, the resolution, the regions to control, and the parts to detect.

Go to the EasyPLC\Plugins folder and execute the Visual Control Config.exe program.

Page 6: Visual Control Plugin

6

Regions. The Regions are used in V.C Plugin as an area to control. You can create as many regions you need, each one can detect movement or kinds of parts in function their colour.

To create a region, press the Create Region Button in the Regions tab.

First select the region colour, this is to see the marked area over the image, second press the mouse left button and drag a rectangle to fill the selected region area:

Page 7: Visual Control Plugin

7

In the regions grid you can change the region position and size, the colour, density and the Sensibility.

The Density is used for averaging the colour of all the pixels inside the region. The Sensibility is used to activate the motion detection in function of the color change of the pixels averaged.

Press Show Regions or Hide Regions to show/hide the created regions.

If Show Work is checked, when motion is detected, the region where the motion has been detected will be visible for a moment.

Page 8: Visual Control Plugin

8

Parts.

The Parts are used in V.C Plugin to recognize elements. You can create as many parts as you need.

First you need to create the regions to discriminate the parts, after create the Parts and configure the regions.

Example:

Put a part to be detected, create the regions (two in this example), press the Create New Part Button in the Parts tab, a new id is associated to this part and you can use the regions you need to recognize this part. If you want to use region 1 and 2, with the camera seeing the part, make double click in Part grid row for id 0, and Region 0 column:

Then make click in the id 0 row and Region 1 column.

As you can see, all the regions columns for each part, stores the colours (for Red, Green and Blue).

The Tolerance allows to give a margin of error for the light compensation or parts difference. Open it or close it in function of the restrictions you need.

Page 9: Visual Control Plugin

9

Press the Read Part Button to detect the part type.

Now let’s create other Part, this new part has a lateral yellow, the double click over the regions cell to configure the regions colours.

Now, put part 0 and press Read Part button:

Part 0 is detected!

Now place part 1 and press Read Part Button:

Part 1 is detected!

Page 10: Visual Control Plugin

10

Once the configuration is finished, can be saved. File -> Save.

Press the Calibrate Button to make a quickly capture of the colour of the regions for one Part, this is, instead of make double click in each region to learn the regions colour, press this button to calibrate the part. This must be done after create a part manually.

Page 11: Visual Control Plugin

11

2. Visual Control Plugin

Start EasyPLC Program and create a new program. On Project Explorer tree, make mouse right click on Plugins node, and select Add Plugin, from the Select Plugin window, select the VisualControlPLG.dll, click on the new VisualControlPLC node and you will be able to see all the methods & functions provided by the plugin.

Here is shown an example for motion detection:

First is necessary to initialize the plugin, in the init procedure, the program created with the Visual Control Editor must be passed, then for motion detection the call to the MotionDetection procedure must be called.

Page 12: Visual Control Plugin

12

Now in the main section the following program is written. Here are scanned two regions, when movement is detected, a digital output is active during 1.5 seconds and a sound is played. If the movement is detected in region 1, also a photograph is saved in the PC hard drive.

Use the Script Wizard tool to write the program (double click) and see the Plugin methods & functions.

Page 13: Visual Control Plugin

13

This example is used to detect parts.

Here two different kind of coins are detected:

Page 14: Visual Control Plugin

14

Here are explained the methods & functions available in Visual Control Plugin:

Void Init(string Filename) Initializes the webcam, and loads the program passed (created with the Visual Control Editor). String Message() Returns a string with message errors (useful for info in the camera initialization). Void ClosePanel() Closes the camera window, but the detection is still active. Void TakePhoto() Saves the current webcam frame in the PC Hard disk (in the EasyPLC installation folder and this the data_time file name). Void TakePhoto(string path) Saves the current webcam frame in the PC Hard disk in the passed path and file name. Object Frame() Returns the current webcam frame image. Void CheckMotion() Used to call manually to the motion detection routines (for timer user requirements) Int RegionsCount() Returns the number of regions for the current program. Bool CheckRegMotion(int n) Return true if is detected motion in the passed region. Void ResetDetections()

Page 15: Visual Control Plugin

15

Reset all the regions detections flag. Void ResetRegionDetection(int n) Reset the detection flag for the passed region. Byte CurrRegColorR(int n) Returns the Red Color of the passed region. Byte CurrRegColorG(int n) Returns the Green Color of the passed region. Byte CurrRegColorB(int n) Returns the Blue Color of the passed region. Void MotionDetection(bool v) Enables/Disables the motion detection. Void ShowRegions(bool v) Shows or hide in the V.C. window the regions. Void CheckRegions(bool v) If true shows the regions when motion or part detection. Int ReadPart() Return the Id of the detected Part. Bool Ready() Return true when V.C Plugin is ready to work (camera and program initialized ok!). Int CalibratePart(int id) Makes a calibration of the passed part id. (this is the regions colors are updated with the current camera values). String VersionInfo() Returns a string with the info of the V.C Plugin version. Void Stop() Closes the Plugin application.

Page 16: Visual Control Plugin

16

EasyPLC Software Suite www.nirtec.com

Idea, Design & Programming by Rafael Izquierdo Valencia (Spain) Copyright © Rafael Izquierdo 2014