# Conversion_Roi

## Using of command

Function sets region of interest on selected picture. Region of interest is represented by rectange. If region of interest is sets on selected picture, all next operation on this picture will be execute only in this region. Operation only in region of interest save function time.

## Commands parameters

Command has 10 parameters:

1. Source picture: You can select picture where ROI is set or reset. You can select Picture_0 to Picture_19.
2. X-coordinate: You can select from where X coordinate of the left most rectangle corner will be use. You can select Variable_0 to Variable_99 (in this case x-coordinate will be value from selected variable) or "Number". When option "NUmber" is selected, x-coordinate will be set from number in next parameter. X-coordinate is value in pixel from left corner of picture.
3. X-cor Number: If option "Number" in previous parameter was select you can write x-cor number in pixeles in this line.
4. Y-coordinate: You can select from where Y-coordinate of the top most rectangle corner will be use. You can select Variable_0 to Variable_99 (in this case y-coordinate will be value from selected variable) or "Number". When option "Number" is selected, y-coordinate will be set from number in next parameter. Y-coordinate is value in pixel from top corner of picture.
5. Y-cor Number: If option "Number" in previous parameter was selected you can write y-cor number in pixeles in this line.
6. Width: You can select from where Width of ROI will be select. You can select Variable_0 to Variable_99 (in this case width will be value from selected variable) or "Number". When option "Number" is selected, width will be set from number in next parameter. Width number is in pixels.
7. Width Number: If option "Number" in previous parameter was selected you can write width number in pixels in this line.
8. Height:You can select from where height of ROI will be select. You can select Variable_0 to Variable_99 (in this case height will be value from selected variable) or "Number". When option "Number" is selected, height will be set from number in next parameter. Height number is in pixels.
9. Height Number: If option "Number" in previous parameter was selected you can write height number in pixels in this line.

## Edit mode

You can select ROI area directly on tested picture.You need set break on line with Conversion_Roi command when option set is select. Then you need run program in debug mode. When program stop on line with Coversion_Roi command, select option Run one step from toolbar or menu. Then Edit window with tested picture will display. Red rectangle on picture show ROI are with current setup. You can change this area by left click on the one corner of new area than move cursor on the second corner of ROI area and release left button. New area will be show by red rectangle and parameter numbers will be recalculate to new values. When you press Exit button ,you can select if you want use new data in test program. If you select yes test program will use new data. This option sets all dimension parameters to "Number". So if you use variables as dimension parameters, this parameters will be rewrite to Number.

## Error codes

1. Error code -11: Bad position in picture array. Error means than Picture intex is not in range 0 to 19. Check test program file if command has correct format.
2. Error code -12: Bad position in variable array.Error means taht variable index is not in range 0 to 99. Check test program file if command has correct format.
3. Error code -13: X_cor is less than 0. X- coordinate must be more or equal than 0.
4. Error code -14: X-cor is more than picture width. X-coordinate must be less than width of selected picture.
5. Error code -15: Y_cor is less than 0. Y-coordinate must be more or equal than 0.
6. Error code -16: Y-cor is more than picture height. Y-coordinate must be less than height of selected picture.
7. Error code -17: Width is less or equal 0. Width value must be more than 0.
8. Error code -18: Width is more than picture width. Width value + X-coordinate must be less or equal than picture width
9. Error code -19: Height is less or equal 0. Height value must be more than 0.
10. Error code -20: Height is more than picture height. Height value+ Y-coordinate must be less or equal tha picture height.
11. Error code -100: OpenCv error: Error was generated by OpenCV function cvSetImageROI or cvResetImageROI. Explanation of this error will be display in command window.