Ejemplo n.º 1
0
def main():
    thresholdValue = [108]
    chooseInt = [0]

    # Size of trackbars
    trackbar_width = 400

    #init cvui
    cvui.init(WINDOW_NAME, 20)
    ui_frame = np.zeros((480, 640, 3), np.uint8)

    #camera setting
    cap = cv2.VideoCapture(0)
    cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 640)
    cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 480)

    #main loop
    while (True):
        ret, frame = cap.read()

        #print frame.dtype
        #to gray
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        ui_frame[:] = (49, 52, 49)
        cvui.beginColumn(ui_frame, 20, 20, -1, -1, 6)

        cvui.text('Threshold Adject')
        cvui.trackbar(trackbar_width, thresholdValue, 0, 255)

        cvui.counter(chooseInt)

        cvui.space(5)

        cvui.text(strArr[chooseInt[0]])

        if cvui.button('&Quit'):
            break

        cvui.space(5)

        cvui.endColumn()

        th1, gray = cv2.threshold(gray, thresholdValue[0], 255,
                                  chooseArr[chooseInt[0]])
        merged = cv2.merge([gray, gray, gray])

        dst = cv2.addWeighted(ui_frame, 1.0, merged, 0.4, 0.0)

        cvui.update()

        cv2.imshow(WINDOW_NAME, dst)

    cap.release()
    cv2.destroyAllWindows()
def main():
    frame = np.zeros((600, 800, 3), np.uint8)
    value = [50]

    settings = EnhancedWindow(20, 80, 200, 120, 'Settings')
    info = EnhancedWindow(250, 80, 330, 60, 'Info')

    # Init cvui and tell it to create a OpenCV window, i.e. cv2.namedWindow(WINDOW_NAME).
    cvui.init(WINDOW_NAME)

    while (True):
        # Fill the frame with a nice color
        frame[:] = (49, 52, 49)

        # Place some instructions on the screen regarding the
        # settings window
        cvui.text(
            frame, 20, 20,
            'The Settings and the Info windows below are movable and minimizable.'
        )
        cvui.text(frame, 20, 40,
                  'Click and drag any window\'s title bar to move it around.')

        # Render a movable and minimizable settings window using
        # the EnhancedWindow class.
        settings.begin(frame)
        if settings.isMinimized() == False:
            cvui.text('Adjust something')
            cvui.space(10)  # add 10px of space between UI components
            cvui.trackbar(settings.width() - 20, value, 5, 150)
        settings.end()

        # Render a movable and minimizable settings window using
        # the EnhancedWindow class.
        info.begin(frame)
        if info.isMinimized() == False:
            cvui.text('Moving and minimizable windows are awesome!')
        info.end()

        # Update all cvui internal stuff, e.g. handle mouse clicks, and show
        # everything on the screen.
        cvui.imshow(WINDOW_NAME, frame)

        # Check if ESC key was pressed
        if cv2.waitKey(20) == 27:
            break
Ejemplo n.º 3
0
def main():
	fruits = cv2.imread('fruits.jpg', cv2.IMREAD_COLOR)
	frame = np.zeros(fruits.shape, np.uint8)
	low_threshold = [50]
	high_threshold = [150]
	use_canny = [False]

	# Create a settings window using the EnhancedWindow class.
	settings = EnhancedWindow(10, 50, 270, 180, 'Settings')

	# Init cvui and tell it to create a OpenCV window, i.e. cv2.namedWindow(WINDOW_NAME).
	cvui.init(WINDOW_NAME)

	while (True):
		# Should we apply Canny edge?
		if use_canny[0]:
			# Yes, we should apply it.
			frame = cv2.cvtColor(fruits, cv2.COLOR_BGR2GRAY)
			frame = cv2.Canny(frame, low_threshold[0], high_threshold[0], 3)
			frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR)
		else: 
			# No, so just copy the original image to the displaying frame.
			frame[:] = fruits[:]

		# Render the settings window and its content, if it is not minimized.
		settings.begin(frame)
		if settings.isMinimized() == False:
			cvui.checkbox('Use Canny Edge', use_canny)
			cvui.trackbar(settings.width() - 20, low_threshold, 5, 150)
			cvui.trackbar(settings.width() - 20, high_threshold, 80, 300)
			cvui.space(20); # add 20px of empty space
			cvui.text('Drag and minimize this settings window', 0.4, 0xff0000)
		settings.end()

		# This function must be called *AFTER* all UI components. It does
		# all the behind the scenes magic to handle mouse clicks, etc.
		cvui.update()

		# Show everything on the screen
		cv2.imshow(WINDOW_NAME, frame)

		# Check if ESC key was pressed
		if cv2.waitKey(20) == 27:
			break
Ejemplo n.º 4
0
def main():
    lena = cv2.imread('lena.jpg', cv2.IMREAD_COLOR)
    frame = np.zeros(lena.shape, np.uint8)
    doubleBuffer = np.zeros(lena.shape, np.uint8)
    trackbarWidth = 130

    # Adjustments values for RGB and HSV
    rgb = [[1.], [1.], [1]]
    hsv = [[1.], [1.], [1]]

    # Copy the loaded image to the buffer
    doubleBuffer[:] = lena[:]

    # Init cvui and tell it to use a value of 20 for cv2.waitKey()
    # because we want to enable keyboard shortcut for
    # all components, e.g. button with label '&Quit'.
    # If cvui has a value for waitKey, it will call
    # waitKey() automatically for us within cvui.update().
    cvui.init(WINDOW_NAME, 20)

    while (True):
        frame[:] = doubleBuffer[:]
        frameRows, frameCols, frameChannels = frame.shape

        # Exit the application if the quit button was pressed.
        # It can be pressed because of a mouse click or because
        # the user pressed the 'q' key on the keyboard, which is
        # marked as a shortcut in the button label ('&Quit').
        if cvui.button(frame, frameCols - 100, frameRows - 30, '&Quit'):
            break

        # RGB HUD
        cvui.window(frame, 20, 50, 180, 240, 'RGB adjust')

        # Within the cvui.beginColumns() and cvui.endColumn(),
        # all elements will be automatically positioned by cvui.
        # In a columns, all added elements are vertically placed,
        # one under the other (from top to bottom).
        #
        # Notice that all component calls within the begin/end block
        # below DO NOT have (x,y) coordinates.
        #
        # Let's create a row at position (35,80) with automatic
        # width and height, and a padding of 10
        cvui.beginColumn(frame, 35, 80, -1, -1, 10)
        rgbModified = False

        # Trackbar accept a pointer to a variable that controls their value
        # They return true upon edition
        if cvui.trackbar(trackbarWidth, rgb[0], 0., 2., 2, '%3.02Lf'):
            rgbModified = True

        if cvui.trackbar(trackbarWidth, rgb[1], 0., 2., 2, '%3.02Lf'):
            rgbModified = True

        if cvui.trackbar(trackbarWidth, rgb[2], 0., 2., 2, '%3.02Lf'):
            rgbModified = True

        cvui.space(2)
        cvui.printf(0.35, 0xcccccc, '   RGB: %3.02lf,%3.02lf,%3.02lf',
                    rgb[0][0], rgb[1][0], rgb[2][0])

        if (rgbModified):
            b, g, r = cv2.split(lena)
            b = b * rgb[2][0]
            g = g * rgb[1][0]
            r = r * rgb[0][0]
            cv2.merge((b, g, r), doubleBuffer)
        cvui.endColumn()

        # HSV
        lenaRows, lenaCols, lenaChannels = lena.shape
        cvui.window(frame, lenaCols - 200, 50, 180, 240, 'HSV adjust')
        cvui.beginColumn(frame, lenaCols - 180, 80, -1, -1, 10)
        hsvModified = False

        if cvui.trackbar(trackbarWidth, hsv[0], 0., 2., 2, '%3.02Lf'):
            hsvModified = True

        if cvui.trackbar(trackbarWidth, hsv[1], 0., 2., 2, '%3.02Lf'):
            hsvModified = True

        if cvui.trackbar(trackbarWidth, hsv[2], 0., 2., 2, '%3.02Lf'):
            hsvModified = True

        cvui.space(2)
        cvui.printf(0.35, 0xcccccc, '   HSV: %3.02lf,%3.02lf,%3.02lf',
                    hsv[0][0], hsv[1][0], hsv[2][0])

        if hsvModified:
            hsvMat = cv2.cvtColor(lena, cv2.COLOR_BGR2HSV)
            h, s, v = cv2.split(hsvMat)
            h = h * hsv[0][0]
            s = s * hsv[1][0]
            v = v * hsv[2][0]
            cv2.merge((h, s, v), hsvMat)
            doubleBuffer = cv2.cvtColor(hsvMat, cv2.COLOR_HSV2BGR)

        cvui.endColumn()

        # Display the lib version at the bottom of the screen
        cvui.printf(frame, frameCols - 300, frameRows - 20, 0.4, 0xCECECE,
                    'cvui v.%s', cvui.VERSION)

        # This function must be called *AFTER* all UI components. It does
        # all the behind the scenes magic to handle mouse clicks, etc.
        #
        # Since cvui.init() received a param regarding waitKey,
        # there is no need to call cv2.waitKey() anymore. cvui.update()
        # will do it automatically.
        cvui.update()

        # Show everything on the screen
        cv2.imshow(WINDOW_NAME, frame)
Ejemplo n.º 5
0
             image = cv2.imdecode(np.fromfile(file_path, dtype=np.uint8),
                                  cv2.IMREAD_COLOR)
             if image.shape[0] > image.shape[1]:
                 imag = cv2.resize(
                     image,
                     (int(800 * image.shape[1] / image.shape[0]), 800),
                     interpolation=cv2.INTER_CUBIC)
             else:
                 imag = cv2.resize(
                     image,
                     (800, int(800 * image.shape[0] / image.shape[1])),
                     interpolation=cv2.INTER_CUBIC)
         except:
             file_path = "cannot open the image"
             image = None
 cvui.space(10)
 cvui.text(file_path, 0.4)
 cvui.space(10)
 cvui.text("Kernal Size Gauss", 0.4)
 cvui.space(5)
 cvui.trackbar(250, kernalSize, 1, 11, 5, '%d', cvui.TRACKBAR_DISCRETE, 2)
 cvui.space(10)
 cvui.text("Kernal Size Sobel", 0.4)
 cvui.space(5)
 cvui.trackbar(250, ksize, 1, 11, 5, '%d', cvui.TRACKBAR_DISCRETE, 2)
 cvui.space(10)
 cvui.text("Grey or Bright", 0.4)
 cvui.space(5)
 cvui.trackbar(250, alpha, 0, 1)
 cvui.space(10)
 cvui.text("Gradient Therehold Value", 0.4)
Ejemplo n.º 6
0
def main():
	intValue = [30]
	ucharValue = [30]
	charValue = [30]
	floatValue = [12.]
	doubleValue1 = [15.]
	doubleValue2 = [10.3]
	doubleValue3 = [2.25]
	frame = np.zeros((650, 450, 3), np.uint8)

	# Size of trackbars
	width = 400

	# Init cvui and tell it to use a value of 20 for cv2.waitKey()
	# because we want to enable keyboard shortcut for
	# all components, e.g. button with label '&Quit'.
	# If cvui has a value for waitKey, it will call
	# waitKey() automatically for us within cvui.update().
	cvui.init(WINDOW_NAME, 20)

	while (True):
		# Fill the frame with a nice color
		frame[:] = (49, 52, 49)

		cvui.beginColumn(frame, 20, 20, -1, -1, 6)
		
		cvui.text('int trackbar, no customization')
		cvui.trackbar(width, intValue, 0, 100)
		cvui.space(5)

		cvui.text('uchar trackbar, no customization')
		cvui.trackbar(width, ucharValue, 0, 255)
		cvui.space(5)

		cvui.text('signed char trackbar, no customization')
		cvui.trackbar(width, charValue, -128, 127)
		cvui.space(5)

		cvui.text('float trackbar, no customization')
		cvui.trackbar(width, floatValue, 10., 15.)
		cvui.space(5)

		cvui.text('float trackbar, 4 segments')
		cvui.trackbar(width, doubleValue1, 10., 20., 4)
		cvui.space(5)

		cvui.text('double trackbar, label %.1Lf, TRACKBAR_DISCRETE')
		cvui.trackbar(width, doubleValue2, 10., 10.5, 1, '%.1Lf', cvui.TRACKBAR_DISCRETE, 0.1)
		cvui.space(5)

		cvui.text('double trackbar, label %.2Lf, 2 segments, TRACKBAR_DISCRETE')
		cvui.trackbar(width, doubleValue3, 0., 4., 2, '%.2Lf', cvui.TRACKBAR_DISCRETE, 0.25)
		cvui.space(10)

		# Exit the application if the quit button was pressed.
		# It can be pressed because of a mouse click or because 
		# the user pressed the 'q' key on the keyboard, which is
		# marked as a shortcut in the button label ('&Quit').
		if cvui.button('&Quit'):
			break
		
		cvui.endColumn()

		# Since cvui.init() received a param regarding waitKey,
		# there is no need to call cv.waitKey() anymore. cvui.update()
		# will do it automatically.
		cvui.update()

		cv2.imshow(WINDOW_NAME, frame)
def main():
    frame = np.zeros((600, 800, 3), np.uint8)

    # Create variables used by some components
    values = []
    checked = [False]
    checked2 = [False]
    value = [1.0]
    value2 = [1.0]
    value3 = [1.0]
    padding = 10
    img = cv2.imread('lena-face.jpg', cv2.IMREAD_COLOR)
    imgRed = cv2.imread('lena-face-red.jpg', cv2.IMREAD_COLOR)
    imgGray = cv2.imread('lena-face-gray.jpg', cv2.IMREAD_COLOR)

    # Fill the vector with a few random values
    for i in range(0, 20):
        values.append(random.uniform(0., 300.0))

    # Init cvui and tell it to create a OpenCV window, i.e. cv::namedWindow(WINDOW_NAME).
    cvui.init(WINDOW_NAME)

    while (True):
        # Fill the frame with a nice color
        frame[:] = (49, 52, 49)

        # In a row, all added elements are
        # horizontally placed, one next the other (from left to right)
        #
        # Within the cvui.beginRow() and cvui.endRow(),
        # all elements will be automatically positioned by cvui.
        #
        # Notice that all component calls within the begin/end block
        # DO NOT have (x,y) coordinates.
        #
        # Let's create a row at position (10,20) with width 100 and height 50.
        cvui.beginRow(frame, 10, 20, 100, 50)
        cvui.text('This is ')
        cvui.printf('a row')
        cvui.checkbox('checkbox', checked)
        cvui.window(80, 80, 'window')
        cvui.rect(50, 50, 0x00ff00, 0xff0000)
        cvui.sparkline(values, 50, 50)
        cvui.counter(value)
        cvui.button(100, 30, 'Fixed')
        cvui.image(img)
        cvui.button(img, imgGray, imgRed)
        cvui.endRow()

        # Here is another row, this time with a padding of 50px among components.
        padding = 50
        cvui.beginRow(frame, 10, 150, 100, 50, padding)
        cvui.text('This is ')
        cvui.printf('another row')
        cvui.checkbox('checkbox', checked2)
        cvui.window(80, 80, 'window')
        cvui.button(100, 30, 'Fixed')
        cvui.printf('with 50px padding.')
        cvui.endRow()

        # Another row mixing several components
        cvui.beginRow(frame, 10, 250, 100, 50)
        cvui.text('This is ')
        cvui.printf('another row with a trackbar ')
        #cvui.trackbar(150, &value2, 0., 5.);
        cvui.printf(' and a button ')
        cvui.button(100, 30, 'button')
        cvui.endRow()

        # In a column, all added elements are vertically placed,
        # one below the other, from top to bottom. Let's create
        # a column at (50, 300) with width 100 and height 200.
        cvui.beginColumn(frame, 50, 330, 100, 200)
        cvui.text('Column 1 (no padding)')
        cvui.button('button1')
        cvui.button('button2')
        cvui.text('End of column 1')
        cvui.endColumn()

        # Here is another column, using a padding value of 10,
        # which will add an space of 10px between each component.
        padding = 10
        cvui.beginColumn(frame, 300, 330, 100, 200, padding)
        cvui.text('Column 2 (padding = 10)')
        cvui.button('button1')
        cvui.button('button2')
        #cvui.trackbar(150, &value3, 0., 5., 1, '%3.2Lf', cvui.TRACKBAR_DISCRETE, 0.25);
        cvui.text('End of column 2')
        cvui.endColumn()

        # You can also add an arbitrary amount of space between
        # components by calling cvui.space().
        #
        # cvui.space() is aware of context, so if it is used
        # within a beginColumn()/endColumn() block, the space will
        # be vertical. If it is used within a beginRow()/endRow()
        # block, space will be horizontal.
        cvui.beginColumn(frame, 550, 330, 100, 200)
        cvui.text('Column 3 (use space)')
        # Add 5 pixels of (vertical) space.
        cvui.space(5)
        cvui.button('button1 5px below')
        # Add 50 pixels of (vertical) space.
        cvui.space(50)
        cvui.text('Text 50px below')
        # Add 20 pixels of (vertical) space.
        cvui.space(20)
        cvui.button('Button 20px below')
        # Add 40 pixels of (vertical) space.
        cvui.space(40)
        cvui.text('End of column 2 (40px below)')
        cvui.endColumn()

        # This function must be called *AFTER* all UI components. It does
        # all the behind the scenes magic to handle mouse clicks, etc.
        cvui.update()

        # Show everything on the screen
        cv2.imshow(WINDOW_NAME, frame)

        # Check if ESC key was pressed
        if cv2.waitKey(20) == 27:
            break
Ejemplo n.º 8
0
def draw_settings(ctrl_frame, control_panes, canny_state, threshold_state,
                  stage_mode, focus_mode, tracker_mode):

    # define the mutually-exclusive mode toggles

    stage_manual = [stage_mode == 'MANUAL']
    stage_auto = [stage_mode == 'AUTO']
    stage_paused = [stage_mode == 'PAUSED']

    focus_manual = [focus_mode == 'MANUAL']
    focus_sharpness = [focus_mode == 'SHARPNESS']
    focus_depth = [focus_mode == 'DEPTH']

    tracker_box_kcf = [tracker_mode == 'KCF']
    tracker_box_canny = [tracker_mode == 'CANNY']
    tracker_box_threshold = [tracker_mode == 'THRESHOLD']
    macro_resweep = False
    ll_resweep = False

    control_panes.stage_control_pane.begin(ctrl_frame)
    if not control_panes.stage_control_pane.isMinimized():
        cvui.space(100)  # add 20px of empty space
        cvui.checkbox('Stage Paused', stage_paused)
        cvui.checkbox('Stage Manual', stage_manual)
        cvui.checkbox('Stage Auto', stage_auto)
    control_panes.stage_control_pane.end()

    control_panes.focus_control_pane.begin(ctrl_frame)
    if not control_panes.focus_control_pane.isMinimized():
        cvui.space(80)  # add 20px of empty space
        cvui.checkbox('Focus Manual', focus_manual)
        cvui.checkbox('Focus Sharpness', focus_sharpness)
        cvui.checkbox('Focus Depth', focus_depth)
    control_panes.focus_control_pane.end()

    control_panes.tracker_select_pane.begin(ctrl_frame)
    if not control_panes.tracker_select_pane.isMinimized():
        cvui.space(60)  # add 20px of empty space
        cvui.checkbox('KCF Tracker', tracker_box_kcf)
        cvui.checkbox('Canny Tracker', tracker_box_canny)
        cvui.checkbox('Threshold Tracker', tracker_box_threshold)
    control_panes.tracker_select_pane.end()

    control_panes.canny_settings_pane.begin(ctrl_frame)
    if not control_panes.canny_settings_pane.isMinimized():
        cvui.space(40)  # add 20px of empty space
        cvui.text('Canny Low Threshold')
        cvui.trackbar(control_panes.canny_settings_pane.width() - 20,
                      canny_state.canny_low, 5, 150)
        cvui.text('Canny High Threshold')
        cvui.trackbar(control_panes.canny_settings_pane.width() - 20,
                      canny_state.canny_high, 80, 300)
    control_panes.canny_settings_pane.end()

    control_panes.threshold_setting_pane.begin(ctrl_frame)
    if not control_panes.threshold_setting_pane.isMinimized():
        cvui.space(20)  # add 20px of empty space
        cvui.text('Binarization Threshold')
        cvui.trackbar(control_panes.threshold_setting_pane.width() - 20,
                      threshold_state.threshold, 0, 255)
        cvui.checkbox('Show Binary Image', threshold_state.show_binary)
        cvui.text('MOVE THESE!!!!')
        if cvui.button('Force Macro Focus Sweep'):
            macro_resweep = True
        else:
            macro_resweep = False
        if cvui.button('Liquid Lens Focus Sweep'):
            ll_resweep = True
        else:
            ll_resweep = False
    control_panes.threshold_setting_pane.end()

    if stage_manual[0] and not stage_mode == 'MANUAL':
        stage_mode = 'MANUAL'
    elif stage_auto[0] and not stage_mode == 'AUTO':
        stage_mode = 'AUTO'
    elif stage_paused[0] and not stage_mode == 'PAUSED':
        stage_mode = 'PAUSED'

    if focus_manual[0] and not focus_mode == 'MANUAL':
        focus_mode = 'MANUAL'
    elif focus_sharpness[0] and not focus_mode == 'SHARPNESS':
        focus_mode = 'SHARPNESS'
    elif focus_depth[0] and not focus_mode == 'DEPTH':
        focus_mode = 'DEPTH'

    if tracker_box_kcf[0] and not tracker_mode == 'KCF':
        tracker_mode = 'KCF'
    elif tracker_box_canny[0] and not tracker_mode == 'CANNY':
        tracker_mode = 'CANNY'
    elif tracker_box_threshold and not tracker_mode == 'THRESHOLD':
        tracker_mode = 'THRESHOLD'

    return stage_mode, focus_mode, tracker_mode, macro_resweep, ll_resweep
Ejemplo n.º 9
0
def main():
	# We have one mat for each window.
	frame1 = np.zeros((600, 800, 3), np.uint8)
	frame2 = np.zeros((600, 800, 3), np.uint8)

	# Create variables used by some components
	window1_values = []
	window2_values = []
	window1_checked = [False]
	window1_checked2 = [False]
	window2_checked = [False]
	window2_checked2 = [False]
	window1_value = [1.0]
	window1_value2 = [1.0]
	window1_value3 = [1.0]
	window2_value = [1.0]
	window2_value2 = [1.0]
	window2_value3 = [1.0]

	img = cv2.imread('lena-face.jpg', cv2.IMREAD_COLOR)
	imgRed = cv2.imread('lena-face-red.jpg', cv2.IMREAD_COLOR)
	imgGray = cv2.imread('lena-face-gray.jpg', cv2.IMREAD_COLOR)

	padding = 10

	# Fill the vector with a few random values
	for i in range(0, 20):
		window1_values.append(random.uniform(0., 300.0))
		window2_values.append(random.uniform(0., 300.0))

	# Start two OpenCV windows
	cv2.namedWindow(WINDOW1_NAME)
	cv2.namedWindow(WINDOW2_NAME)
	
	# Init cvui and inform it to use the first window as the default one.
	# cvui.init() will automatically watch the informed window.
	cvui.init(WINDOW1_NAME)

	# Tell cvui to keep track of mouse events in window2 as well.
	cvui.watch(WINDOW2_NAME)

	while (True):
		# Inform cvui that all subsequent component calls and events are related to window 1.
		cvui.context(WINDOW1_NAME)

		# Fill the frame with a nice color
		frame1[:] = (49, 52, 49)

		cvui.beginRow(frame1, 10, 20, 100, 50)
		cvui.text('This is ')
		cvui.printf('a row')
		cvui.checkbox('checkbox', window1_checked)
		cvui.window(80, 80, 'window')
		cvui.rect(50, 50, 0x00ff00, 0xff0000)
		cvui.sparkline(window1_values, 50, 50)
		cvui.counter(window1_value)
		cvui.button(100, 30, 'Fixed')
		cvui.image(img)
		cvui.button(img, imgGray, imgRed)
		cvui.endRow()

		padding = 50
		cvui.beginRow(frame1, 10, 150, 100, 50, padding)
		cvui.text('This is ')
		cvui.printf('another row')
		cvui.checkbox('checkbox', window1_checked2)
		cvui.window(80, 80, 'window')
		cvui.button(100, 30, 'Fixed')
		cvui.printf('with 50px paddin7hg.')
		cvui.endRow()

		cvui.beginRow(frame1, 10, 250, 100, 50)
		cvui.text('This is ')
		cvui.printf('another row with a trackbar ')
		cvui.trackbar(150, window1_value2, 0., 5.)
		cvui.printf(' and a button ')
		cvui.button(100, 30, 'button')
		cvui.endRow()

		cvui.beginColumn(frame1, 50, 330, 100, 200)
		cvui.text('Column 1 (no padding)')
		cvui.button('button1')
		cvui.button('button2')
		cvui.text('End of column 1')
		cvui.endColumn()

		padding = 10
		cvui.beginColumn(frame1, 300, 330, 100, 200, padding)
		cvui.text('Column 2 (padding = 10)')
		cvui.button('button1')
		cvui.button('button2')
		cvui.trackbar(150, window1_value3, 0., 5., 1, '%3.2Lf', cvui.TRACKBAR_DISCRETE, 0.25)
		cvui.text('End of column 2')
		cvui.endColumn()

		cvui.beginColumn(frame1, 550, 330, 100, 200)
		cvui.text('Column 3 (use space)')
		cvui.space(5)
		cvui.button('button1 5px below')
		cvui.space(50)
		cvui.text('Text 50px below')
		cvui.space(20)
		cvui.button('Button 20px below')
		cvui.space(40)
		cvui.text('End of column 2 (40px below)')
		cvui.endColumn()
		
		# Update all components of window1, e.g. mouse clicks, and show it.
		cvui.update(WINDOW1_NAME)
		cv2.imshow(WINDOW1_NAME, frame1)
		
		# From this point on, we are going to render the second window. We need to inform cvui
		# that all updates and components from now on are connected to window 2.
		# We do that by calling cvui.context().
		cvui.context(WINDOW2_NAME)
		frame2[:] = (49, 52, 49)
		
		cvui.beginRow(frame2, 10, 20, 100, 50)
		cvui.text('This is ')
		cvui.printf('a row')
		cvui.checkbox('checkbox', window2_checked)
		cvui.window(80, 80, 'window')
		cvui.rect(50, 50, 0x00ff00, 0xff0000)
		cvui.sparkline(window2_values, 50, 50)
		cvui.counter(window2_value)
		cvui.button(100, 30, 'Fixed')
		cvui.image(img)
		cvui.button(img, imgGray, imgRed)
		cvui.endRow()
		
		padding = 50
		cvui.beginRow(frame2, 10, 150, 100, 50, padding)
		cvui.text('This is ')
		cvui.printf('another row')
		cvui.checkbox('checkbox', window2_checked2)
		cvui.window(80, 80, 'window')
		cvui.button(100, 30, 'Fixed')
		cvui.printf('with 50px paddin7hg.')
		cvui.endRow()
		
		# Another row mixing several components 
		cvui.beginRow(frame2, 10, 250, 100, 50)
		cvui.text('This is ')
		cvui.printf('another row with a trackbar ')
		cvui.trackbar(150, window2_value2, 0., 5.)
		cvui.printf(' and a button ')
		cvui.button(100, 30, 'button')
		cvui.endRow()

		cvui.beginColumn(frame2, 50, 330, 100, 200)
		cvui.text('Column 1 (no padding)')
		cvui.button('button1')
		cvui.button('button2')
		cvui.text('End of column 1')
		cvui.endColumn()
		
		padding = 10
		cvui.beginColumn(frame2, 300, 330, 100, 200, padding)
		cvui.text('Column 2 (padding = 10)')
		cvui.button('button1')
		cvui.button('button2')
		cvui.trackbar(150, window2_value3, 0., 5., 1, '%3.2Lf', cvui.TRACKBAR_DISCRETE, 0.25)
		cvui.text('End of column 2')
		cvui.endColumn()

		cvui.beginColumn(frame2, 550, 330, 100, 200)
		cvui.text('Column 3 (use space)')
		cvui.space(5)
		cvui.button('button1 5px below')
		cvui.space(50)
		cvui.text('Text 50px below')
		cvui.space(20)
		cvui.button('Button 20px below')
		cvui.space(40)
		cvui.text('End of column 2 (40px below)')
		cvui.endColumn()
		
		# Update all components of window2, e.g. mouse clicks, and show it.
		cvui.update(WINDOW2_NAME)
		cv2.imshow(WINDOW2_NAME, frame2)

		# Check if ESC key was pressed
		if cv2.waitKey(20) == 27:
			break
Ejemplo n.º 10
0
def main():
    # We have one mat for each window.
    frame1 = np.zeros((600, 800, 3), np.uint8)
    frame2 = np.zeros((600, 800, 3), np.uint8)

    # Create variables used by some components
    window1_values = []
    window2_values = []
    window1_checked = [False]
    window1_checked2 = [False]
    window2_checked = [False]
    window2_checked2 = [False]
    window1_value = [1.0]
    window1_value2 = [1.0]
    window1_value3 = [1.0]
    window2_value = [1.0]
    window2_value2 = [1.0]
    window2_value3 = [1.0]

    img = cv2.imread('lena-face.jpg', cv2.IMREAD_COLOR)
    imgRed = cv2.imread('lena-face-red.jpg', cv2.IMREAD_COLOR)
    imgGray = cv2.imread('lena-face-gray.jpg', cv2.IMREAD_COLOR)

    padding = 10

    # Fill the vector with a few random values
    for i in range(0, 20):
        window1_values.append(random.uniform(0., 300.0))
        window2_values.append(random.uniform(0., 300.0))

    # Start two OpenCV windows
    cv2.namedWindow(WINDOW1_NAME)
    cv2.namedWindow(WINDOW2_NAME)

    # Init cvui and inform it to use the first window as the default one.
    # cvui.init() will automatically watch the informed window.
    cvui.init(WINDOW1_NAME)

    # Tell cvui to keep track of mouse events in window2 as well.
    cvui.watch(WINDOW2_NAME)

    while (True):
        # Inform cvui that all subsequent component calls and events are related to window 1.
        cvui.context(WINDOW1_NAME)

        # Fill the frame with a nice color
        frame1[:] = (49, 52, 49)

        cvui.beginRow(frame1, 10, 20, 100, 50)
        cvui.text('This is ')
        cvui.printf('a row')
        cvui.checkbox('checkbox', window1_checked)
        cvui.window(80, 80, 'window')
        cvui.rect(50, 50, 0x00ff00, 0xff0000)
        cvui.sparkline(window1_values, 50, 50)
        cvui.counter(window1_value)
        cvui.button(100, 30, 'Fixed')
        cvui.image(img)
        cvui.button(img, imgGray, imgRed)
        cvui.endRow()

        padding = 50
        cvui.beginRow(frame1, 10, 150, 100, 50, padding)
        cvui.text('This is ')
        cvui.printf('another row')
        cvui.checkbox('checkbox', window1_checked2)
        cvui.window(80, 80, 'window')
        cvui.button(100, 30, 'Fixed')
        cvui.printf('with 50px paddin7hg.')
        cvui.endRow()

        cvui.beginRow(frame1, 10, 250, 100, 50)
        cvui.text('This is ')
        cvui.printf('another row with a trackbar ')
        cvui.trackbar(150, window1_value2, 0., 5.)
        cvui.printf(' and a button ')
        cvui.button(100, 30, 'button')
        cvui.endRow()

        cvui.beginColumn(frame1, 50, 330, 100, 200)
        cvui.text('Column 1 (no padding)')
        cvui.button('button1')
        cvui.button('button2')
        cvui.text('End of column 1')
        cvui.endColumn()

        padding = 10
        cvui.beginColumn(frame1, 300, 330, 100, 200, padding)
        cvui.text('Column 2 (padding = 10)')
        cvui.button('button1')
        cvui.button('button2')
        cvui.trackbar(150, window1_value3, 0., 5., 1, '%3.2Lf',
                      cvui.TRACKBAR_DISCRETE, 0.25)
        cvui.text('End of column 2')
        cvui.endColumn()

        cvui.beginColumn(frame1, 550, 330, 100, 200)
        cvui.text('Column 3 (use space)')
        cvui.space(5)
        cvui.button('button1 5px below')
        cvui.space(50)
        cvui.text('Text 50px below')
        cvui.space(20)
        cvui.button('Button 20px below')
        cvui.space(40)
        cvui.text('End of column 2 (40px below)')
        cvui.endColumn()

        # Update all components of window1, e.g. mouse clicks, and show it.
        cvui.update(WINDOW1_NAME)
        cv2.imshow(WINDOW1_NAME, frame1)

        # From this point on, we are going to render the second window. We need to inform cvui
        # that all updates and components from now on are connected to window 2.
        # We do that by calling cvui.context().
        cvui.context(WINDOW2_NAME)
        frame2[:] = (49, 52, 49)

        cvui.beginRow(frame2, 10, 20, 100, 50)
        cvui.text('This is ')
        cvui.printf('a row')
        cvui.checkbox('checkbox', window2_checked)
        cvui.window(80, 80, 'window')
        cvui.rect(50, 50, 0x00ff00, 0xff0000)
        cvui.sparkline(window2_values, 50, 50)
        cvui.counter(window2_value)
        cvui.button(100, 30, 'Fixed')
        cvui.image(img)
        cvui.button(img, imgGray, imgRed)
        cvui.endRow()

        padding = 50
        cvui.beginRow(frame2, 10, 150, 100, 50, padding)
        cvui.text('This is ')
        cvui.printf('another row')
        cvui.checkbox('checkbox', window2_checked2)
        cvui.window(80, 80, 'window')
        cvui.button(100, 30, 'Fixed')
        cvui.printf('with 50px paddin7hg.')
        cvui.endRow()

        # Another row mixing several components
        cvui.beginRow(frame2, 10, 250, 100, 50)
        cvui.text('This is ')
        cvui.printf('another row with a trackbar ')
        cvui.trackbar(150, window2_value2, 0., 5.)
        cvui.printf(' and a button ')
        cvui.button(100, 30, 'button')
        cvui.endRow()

        cvui.beginColumn(frame2, 50, 330, 100, 200)
        cvui.text('Column 1 (no padding)')
        cvui.button('button1')
        cvui.button('button2')
        cvui.text('End of column 1')
        cvui.endColumn()

        padding = 10
        cvui.beginColumn(frame2, 300, 330, 100, 200, padding)
        cvui.text('Column 2 (padding = 10)')
        cvui.button('button1')
        cvui.button('button2')
        cvui.trackbar(150, window2_value3, 0., 5., 1, '%3.2Lf',
                      cvui.TRACKBAR_DISCRETE, 0.25)
        cvui.text('End of column 2')
        cvui.endColumn()

        cvui.beginColumn(frame2, 550, 330, 100, 200)
        cvui.text('Column 3 (use space)')
        cvui.space(5)
        cvui.button('button1 5px below')
        cvui.space(50)
        cvui.text('Text 50px below')
        cvui.space(20)
        cvui.button('Button 20px below')
        cvui.space(40)
        cvui.text('End of column 2 (40px below)')
        cvui.endColumn()

        # Update all components of window2, e.g. mouse clicks, and show it.
        cvui.update(WINDOW2_NAME)
        cv2.imshow(WINDOW2_NAME, frame2)

        # Check if ESC key was pressed
        if cv2.waitKey(20) == 27:
            break
Ejemplo n.º 11
0
def main():
    intValue = [30]
    ucharValue = [30]
    charValue = [30]
    floatValue = [12.]
    doubleValue1 = [15.]
    doubleValue2 = [10.3]
    doubleValue3 = [2.25]
    frame = np.zeros((650, 450, 3), np.uint8)

    # Size of trackbars
    width = 400

    # Init cvui and tell it to use a value of 20 for cv2.waitKey()
    # because we want to enable keyboard shortcut for
    # all components, e.g. button with label '&Quit'.
    # If cvui has a value for waitKey, it will call
    # waitKey() automatically for us within cvui.update().
    cvui.init(WINDOW_NAME, 20)

    while (True):
        # Fill the frame with a nice color
        frame[:] = (49, 52, 49)

        cvui.beginColumn(frame, 20, 20, -1, -1, 6)

        cvui.text('int trackbar, no customization')
        cvui.trackbar(width, intValue, 0, 100)
        cvui.space(5)

        cvui.text('uchar trackbar, no customization')
        cvui.trackbar(width, ucharValue, 0, 255)
        cvui.space(5)

        cvui.text('signed char trackbar, no customization')
        cvui.trackbar(width, charValue, -128, 127)
        cvui.space(5)

        cvui.text('float trackbar, no customization')
        cvui.trackbar(width, floatValue, 10., 15.)
        cvui.space(5)

        cvui.text('float trackbar, 4 segments')
        cvui.trackbar(width, doubleValue1, 10., 20., 4)
        cvui.space(5)

        cvui.text('double trackbar, label %.1Lf, TRACKBAR_DISCRETE')
        cvui.trackbar(width, doubleValue2, 10., 10.5, 1, '%.1Lf',
                      cvui.TRACKBAR_DISCRETE, 0.1)
        cvui.space(5)

        cvui.text(
            'double trackbar, label %.2Lf, 2 segments, TRACKBAR_DISCRETE')
        cvui.trackbar(width, doubleValue3, 0., 4., 2, '%.2Lf',
                      cvui.TRACKBAR_DISCRETE, 0.25)
        cvui.space(10)

        # Exit the application if the quit button was pressed.
        # It can be pressed because of a mouse click or because
        # the user pressed the 'q' key on the keyboard, which is
        # marked as a shortcut in the button label ('&Quit').
        if cvui.button('&Quit'):
            break

        cvui.endColumn()

        # Since cvui.init() received a param regarding waitKey,
        # there is no need to call cv.waitKey() anymore. cvui.update()
        # will do it automatically.
        cvui.update()

        cv2.imshow(WINDOW_NAME, frame)
def main():
	frame = np.zeros((600, 800, 3), np.uint8)
	values = []
	checked = [False]
	value = [1.0]

	# Fill the vector with a few random values
	for i in range(0, 20):
		values.append(random.uniform(0., 300.0))

	# Init cvui and tell it to create a OpenCV window, i.e. cv.namedWindow(WINDOW_NAME).
	cvui.init(WINDOW_NAME)

	while (True):
		# Fill the frame with a nice color
		frame[:] = (49, 52, 49)

		# Define a row at position (10, 50) with width 100 and height 150.
		cvui.beginRow(frame, 10, 50, 100, 150)
		# The components below will be placed one beside the other.
		cvui.text('Row starts')
		cvui.button('here')

		# When a column or row is nested within another, it behaves like
		# an ordinary component with the specified size. In this case,
		# let's create a column with width 100 and height 50. The
		# next component added will behave like it was added after
		# a component with width 100 and heigth 150.
		cvui.beginColumn(100, 150)
		cvui.text('Column 1')
		cvui.button('button1')
		cvui.button('button2')
		cvui.button('button3')
		cvui.text('End of column 1')
		cvui.endColumn()

		# Add two pieces of text
		cvui.text('Hi again,')
		cvui.text('its me!')

		# Start a new column
		cvui.beginColumn(100, 50)
		cvui.text('Column 2')
		cvui.button('button1')
		cvui.button('button2')
		cvui.button('button3')
		cvui.space()
		cvui.text('Another text')
		cvui.space(40)
		cvui.text('End of column 2')
		cvui.endColumn()

		# Add more text
		cvui.text('this is the ')
		cvui.text('end of the row!')
		cvui.endRow()

		# Here is another nested row/column
		cvui.beginRow(frame, 50, 300, 100, 150)
		
		# If you don't want to calculate the size of any row/column WITHIN
		# a begin*()/end*() block, just use negative width/height when
		# calling beginRow() or beginColumn() (or don't provide width/height at all!)

		# For instance, the following column will have its width/height
		# automatically adjusted according to its content.
		cvui.beginColumn()
		cvui.text('Column 1')
		cvui.button('button with very large label')
		cvui.text('End of column 1')
		cvui.endColumn()

		# Add two pieces of text
		cvui.text('Hi again,')
		cvui.text('its me!')

		# Start a new column
		cvui.beginColumn()
		cvui.text('Column 2')
		cvui.button('btn')
		cvui.space()
		cvui.text('text')
		cvui.button('btn2')
		cvui.text('text2')
		if cvui.button('&Quit'):
			break
		cvui.endColumn()

		# Add more text
		cvui.text('this is the ')
		cvui.text('end of the row!')
		cvui.endRow()

		# This function must be called *AFTER* all UI components. It does
		# all the behind the scenes magic to handle mouse clicks, etc.
		cvui.update()

		# Show everything on the screen
		cv2.imshow(WINDOW_NAME, frame)

		# Check if ESC key was pressed
		if cv2.waitKey(20) == 27:
			break
Ejemplo n.º 13
0
def main():
	lena = cv2.imread('lena.jpg', cv2.IMREAD_COLOR)
	frame = np.zeros(lena.shape, np.uint8)
	doubleBuffer = np.zeros(lena.shape, np.uint8)
	trackbarWidth = 130

	# Adjustments values for RGB and HSV
	rgb = [[1.], [1.], [1]]
	hsv = [[1.], [1.], [1]]

	# Copy the loaded image to the buffer
	doubleBuffer[:] = lena[:]

	# Init cvui and tell it to use a value of 20 for cv2.waitKey()
	# because we want to enable keyboard shortcut for
	# all components, e.g. button with label '&Quit'.
	# If cvui has a value for waitKey, it will call
	# waitKey() automatically for us within cvui.update().
	cvui.init(WINDOW_NAME, 20)

	while (True):
		frame[:] = doubleBuffer[:]
		frameRows,frameCols,frameChannels = frame.shape

		# Exit the application if the quit button was pressed.
		# It can be pressed because of a mouse click or because 
		# the user pressed the 'q' key on the keyboard, which is
		# marked as a shortcut in the button label ('&Quit').
		if cvui.button(frame, frameCols - 100, frameRows - 30, '&Quit'):
			break

		# RGB HUD
		cvui.window(frame, 20, 50, 180, 240, 'RGB adjust')

		# Within the cvui.beginColumns() and cvui.endColumn(),
		# all elements will be automatically positioned by cvui.
		# In a columns, all added elements are vertically placed,
		# one under the other (from top to bottom).
		#
		# Notice that all component calls within the begin/end block
		# below DO NOT have (x,y) coordinates.
		#
		# Let's create a row at position (35,80) with automatic
		# width and height, and a padding of 10
		cvui.beginColumn(frame, 35, 80, -1, -1, 10)
		rgbModified = False

		# Trackbar accept a pointer to a variable that controls their value
		# They return true upon edition
		if cvui.trackbar(trackbarWidth, rgb[0], 0., 2., 2, '%3.02Lf'):
			rgbModified = True

		if cvui.trackbar(trackbarWidth, rgb[1], 0., 2., 2, '%3.02Lf'):
			rgbModified = True

		if cvui.trackbar(trackbarWidth, rgb[2], 0., 2., 2, '%3.02Lf'):
			rgbModified = True
			
		cvui.space(2)
		cvui.printf(0.35, 0xcccccc, '   RGB: %3.02lf,%3.02lf,%3.02lf', rgb[0][0], rgb[1][0], rgb[2][0])

		if (rgbModified):
			b,g,r = cv2.split(lena)
			b = b * rgb[2][0]
			g = g * rgb[1][0]
			r = r * rgb[0][0]
			cv2.merge((b,g,r), doubleBuffer)
		cvui.endColumn()

		# HSV
		lenaRows,lenaCols,lenaChannels = lena.shape
		cvui.window(frame, lenaCols - 200, 50, 180, 240, 'HSV adjust')
		cvui.beginColumn(frame, lenaCols - 180, 80, -1, -1, 10)
		hsvModified = False
			
		if cvui.trackbar(trackbarWidth, hsv[0], 0., 2., 2, '%3.02Lf'):
			hsvModified = True

		if cvui.trackbar(trackbarWidth, hsv[1], 0., 2., 2, '%3.02Lf'):
			hsvModified = True

		if cvui.trackbar(trackbarWidth, hsv[2], 0., 2., 2, '%3.02Lf'):
			hsvModified = True

		cvui.space(2)
		cvui.printf(0.35, 0xcccccc, '   HSV: %3.02lf,%3.02lf,%3.02lf', hsv[0][0], hsv[1][0], hsv[2][0])

		if hsvModified:
			hsvMat = cv2.cvtColor(lena, cv2.COLOR_BGR2HSV)
			h,s,v = cv2.split(hsvMat)
			h = h * hsv[0][0]
			s = s * hsv[1][0]
			v = v * hsv[2][0]
			cv2.merge((h,s,v), hsvMat)
			doubleBuffer = cv2.cvtColor(hsvMat, cv2.COLOR_HSV2BGR)

		cvui.endColumn()

		# Display the lib version at the bottom of the screen
		cvui.printf(frame, frameCols - 300, frameRows - 20, 0.4, 0xCECECE, 'cvui v.%s', cvui.VERSION)

		# This function must be called *AFTER* all UI components. It does
		# all the behind the scenes magic to handle mouse clicks, etc.
		#
		# Since cvui.init() received a param regarding waitKey,
		# there is no need to call cv2.waitKey() anymore. cvui.update()
		# will do it automatically.
		cvui.update()

		# Show everything on the screen
		cv2.imshow(WINDOW_NAME, frame)
Ejemplo n.º 14
0
    ###########################################################################
    # GUI
    ###########################################################################
    # Render the settings window to house the checkbox and the trackbars below
    cvui.window(frame, 10, 10, 200, 250, 'Settings')
    options = cvui.TRACKBAR_DISCRETE | cvui.TRACKBAR_HIDE_SEGMENT_LABELS

    cvui.beginColumn(frame, 10, 40, -1, -1, 6)

    if cs == 'hsv':
        cvui.text('Hue low')
    elif cs == 'lab':
        cvui.text('L low')
    cvui.trackbar(width, lowCh0, limitsCh0[0], limitsCh0[1], 10, '%.0Lf',
                  options, 1)
    cvui.space(space)

    if cs == 'hsv':
        cvui.text('Sat low')
    elif cs == 'lab':
        cvui.text('a* low')
    cvui.trackbar(width, lowCh1, limitsCh1[0], limitsCh1[1], 10, '%.0Lf',
                  options, 1)
    cvui.space(space)

    if cs == 'hsv':
        cvui.text('Val low')
    elif cs == 'lab':
        cvui.text('b* low')
    cvui.trackbar(width, lowCh2, limitsCh2[0], limitsCh2[1], 10, '%.0Lf',
                  options, 1)
Ejemplo n.º 15
0
def main():
	frame = np.zeros((600, 800, 3), np.uint8)
	
	# Create variables used by some components
	values = []
	checked = [False]
	checked2 = [False]
	value = [1.0]
	value2 = [1.0]
	value3 = [1.0]
	padding = 10
	img = cv2.imread('lena-face.jpg', cv2.IMREAD_COLOR)
	imgRed = cv2.imread('lena-face-red.jpg', cv2.IMREAD_COLOR)
	imgGray = cv2.imread('lena-face-gray.jpg', cv2.IMREAD_COLOR)

	# Fill the vector with a few random values
	for i in range(0, 20):
		values.append(random.uniform(0., 300.0))
	
	# Init cvui and tell it to create a OpenCV window, i.e. cv::namedWindow(WINDOW_NAME).
	cvui.init(WINDOW_NAME)

	while (True):
		# Fill the frame with a nice color
		frame[:] = (49, 52, 49)

		# In a row, all added elements are
		# horizontally placed, one next the other (from left to right)
		#
		# Within the cvui.beginRow() and cvui.endRow(),
		# all elements will be automatically positioned by cvui.
		# 
		# Notice that all component calls within the begin/end block
		# DO NOT have (x,y) coordinates. 
		#
		# Let's create a row at position (10,20) with width 100 and height 50.
		cvui.beginRow(frame, 10, 20, 100, 50)
		cvui.text('This is ')
		cvui.printf('a row')
		cvui.checkbox('checkbox', checked)
		cvui.window(80, 80, 'window')
		cvui.rect(50, 50, 0x00ff00, 0xff0000);
		cvui.sparkline(values, 50, 50);
		cvui.counter(value)
		cvui.button(100, 30, 'Fixed')
		cvui.image(img)
		cvui.button(img, imgGray, imgRed)
		cvui.endRow()

		# Here is another row, this time with a padding of 50px among components.
		padding = 50;
		cvui.beginRow(frame, 10, 150, 100, 50, padding)
		cvui.text('This is ')
		cvui.printf('another row')
		cvui.checkbox('checkbox', checked2)
		cvui.window(80, 80, 'window')
		cvui.button(100, 30, 'Fixed')
		cvui.printf('with 50px padding.')
		cvui.endRow()

		# Another row mixing several components 
		cvui.beginRow(frame, 10, 250, 100, 50)
		cvui.text('This is ')
		cvui.printf('another row with a trackbar ')
		#cvui.trackbar(150, &value2, 0., 5.);
		cvui.printf(' and a button ')
		cvui.button(100, 30, 'button')
		cvui.endRow()

		# In a column, all added elements are vertically placed,
		# one below the other, from top to bottom. Let's create
		# a column at (50, 300) with width 100 and height 200.
		cvui.beginColumn(frame, 50, 330, 100, 200)
		cvui.text('Column 1 (no padding)')
		cvui.button('button1')
		cvui.button('button2')
		cvui.text('End of column 1')
		cvui.endColumn()

		# Here is another column, using a padding value of 10,
		# which will add an space of 10px between each component.
		padding = 10
		cvui.beginColumn(frame, 300, 330, 100, 200, padding)
		cvui.text('Column 2 (padding = 10)')
		cvui.button('button1')
		cvui.button('button2')
		#cvui.trackbar(150, &value3, 0., 5., 1, '%3.2Lf', cvui.TRACKBAR_DISCRETE, 0.25);
		cvui.text('End of column 2')
		cvui.endColumn()

		# You can also add an arbitrary amount of space between
		# components by calling cvui.space().
		#
		# cvui.space() is aware of context, so if it is used
		# within a beginColumn()/endColumn() block, the space will
		# be vertical. If it is used within a beginRow()/endRow()
		# block, space will be horizontal.
		cvui.beginColumn(frame, 550, 330, 100, 200)
		cvui.text('Column 3 (use space)')
		# Add 5 pixels of (vertical) space.
		cvui.space(5)
		cvui.button('button1 5px below')
		# Add 50 pixels of (vertical) space. 
		cvui.space(50)
		cvui.text('Text 50px below')
		# Add 20 pixels of (vertical) space.
		cvui.space(20)
		cvui.button('Button 20px below')
		# Add 40 pixels of (vertical) space.
		cvui.space(40)
		cvui.text('End of column 2 (40px below)')
		cvui.endColumn()

		# This function must be called *AFTER* all UI components. It does
		# all the behind the scenes magic to handle mouse clicks, etc.
		cvui.update()

		# Show everything on the screen
		cv2.imshow(WINDOW_NAME, frame)

		# Check if ESC key was pressed
		if cv2.waitKey(20) == 27:
			break