# Contours_Find

## Using of command

Function find contours in the source image. Source image must be single channel 8-bit image. Source image is calculated as binary image.Non-zero pixels are treated as 1, zero pixels remain 0.Binary image is converted from grayscale image by functions Conversion_AdaptiveThreshold, Conversion_Threshold,Conversion_Canny. Contours find by this function can be use in the objects description.

## Commands parameters

Command has 3 parameters:

1. Source picture: You need select source picture.Source picture must be activated before use of this function.Source picture must be single channel binary image. You can select Picture_0 to Picture_19.
2. Contours: You need select contour block where pointers for finded contour will be stored. You can select Contour_0 to Contour_19.
3. Mode: You need select retrieval mode:
   1. CV_RETR_EXTERNAL: retrives only the extreme outer contours
   2. CV_RETR_LIST: retrieves all of the contours and puts them in the list
   3. CV_RETR_CCOMP: retrieves all of the contours and organizes them into a two-level hierarchy: on the top level are the external boundaries of the components, on the second level are the boundaries of the holes
   4. CV_RETR_TREE: retrieves all of the contours and reconstructs the full hierarchy of nested contours
4. Method: You need select approximation method:
   1. CV_CHAIN_APPROX_NONE: translates all of the points from the chain code into points
   2. CV_CHAIN_APPROX_SIMPLE: compresses horizontal, vertical, and diagonal segments and leaves only their end points.
   3. CV_CHAIN_APPROX_TC89_L1: applies one of the flavors of the Teh-Chin chain approximation algorithm
   4. CV_CHAIN_APPROX_TC89_KCOS: applies one of the flavors of the Teh-Chin chain approximation algorithm
5. X ofset from: You can select from where x-ofset will be use. You can select Variable_0 to Variable_99 (in this case x-ofset will be read from this variable) or Number (in this case x-ofset will be use from next parameter). Ofset is pixel number by which every contour point is shifted.This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.
6. X ofset number: This option is active only when option "Number" was selected in previous parameter. You can write pixels number for x-ofset.
7. Y ofset from: You can select from where y-ofset will be use. You can select Variable_0 to Variable_99 (in this case y-ofset will be read from this variable) or Number (in this case y-ofset will be use from next parameter). Ofset is pixel number by which every contour point is shifted.This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.
8. Y ofset number: This option is active only when option "Number" was selected in previous parameter. You can write pixels number for y-ofset.
9. Results to: You can select where number of finded contours will be save. You can select option "None" (in this case number of finded contours will not be stored) or Variable_0 to Variable_99 (in this case number of finded contours will be stored in selected variable).

## Error codes

1. Error code -11:Bad x-ofset number variable index. X-ofset variable is not from range Variable_0 to Variable_99. Check test program file if command has correct format.
2. Error code -12:Bad y-offset number variable index. Y-ofset is not from range Variable_0 to Variable_99.Check test program file if command has correct format.
3. Error code -13:Bad position in result variable index. Result to variable is not form range Variable_0 to Variable_99. Check test program file if command has correct format.
4. Error code -14: Bad source picture position in picture array. Source picture is not in range 0-19. Check test program file if command has correct format.
5. Error code -15: Bad contour position index. Contour position is not from range Contour_0 to Contour_99. Check test program file if command has correct format.
6. Error code -16: Bad x-ofset number. X-offset can not be higher that image width.
7. Error code -17: Bad y-ofset number. Y-offset can not be higher than image height.
8. Error code -18: Source picture must be single channel.
9. Error code -100: OpenCV error. Explanation of this error will be displayed in result window.