当前位置: 首页>>代码示例>>Python>>正文


Python cv2.createTrackbar方法代码示例

本文整理汇总了Python中cv2.createTrackbar方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.createTrackbar方法的具体用法?Python cv2.createTrackbar怎么用?Python cv2.createTrackbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv2的用法示例。


在下文中一共展示了cv2.createTrackbar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createFigureAndSlider

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def createFigureAndSlider(name, state_dim):
    """
    Creating a window for the latent space visualization, an another for the slider to control it
    :param name: name of model (str)
    :param state_dim: (int)
    :return:
    """
    # opencv gui setup
    cv2.namedWindow(name, cv2.WINDOW_NORMAL)
    cv2.resizeWindow(name, 500, 500)
    cv2.namedWindow('slider for ' + name)
    # add a slider for each component of the latent space
    for i in range(state_dim):
        # the sliders MUST be between 0 and max, so we placed max at 100, and start at 50
        # So that when we substract 50 and divide 10 we get [-5,5] for each component
        cv2.createTrackbar(str(i), 'slider for ' + name, 50, 100, (lambda a: None)) 
开发者ID:araffin,项目名称:srl-zoo,代码行数:18,代码来源:enjoy_latent.py

示例2: _initialize_window

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def _initialize_window(self):
        """Creates the window."""
        cv.namedWindow(self.name)
        for i, (chname, min_, max_) in enumerate(
            zip(self.channel_names, self.channel_mins, self.channel_maxes)
        ):
            cv.createTrackbar(
                chname + MIN_SUFFIX,
                self.name,
                min_,
                max_,
                partial(self._update_lowerb, i),
            )
            cv.setTrackbarMin(chname + MIN_SUFFIX, self.name, min_)
            cv.createTrackbar(
                chname + MAX_SUFFIX,
                self.name,
                max_,
                max_,
                partial(self._update_upperb, i),
            )
        self._update() 
开发者ID:alkasm,项目名称:colorfilters,代码行数:24,代码来源:__init__.py

示例3: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def __init__(self):
        self.norm_rgb=np.zeros((config.height,config.width,3),np.uint8)
        self.dst=np.zeros((config.height,config.width),np.uint8)
        self.b=0
        self.g=0
        self.r=0
        
        self.lb=0
        self.lg=0
        self.lr=0
        
        self.m=np.zeros((config.height,config.width),np.uint8)
        #self.win=cv2.namedWindow("detect")
        #self.dst=cv.CreateImage((config.width,config.height),8,1)
        
        #cv2.createTrackbar("blue", "detect",0,255,self.change_b)
        #cv2.createTrackbar("green","detect",0,255,self.change_g)
        #cv2.createTrackbar("red","detect",0,255,self.change_r)
        
        #cv2.createTrackbar("low_blue", "detect",0,255,self.change_lb)
        #cv2.createTrackbar("low_green","detect",0,255,self.change_lg)
        #cv2.createTrackbar("low_red","detect",0,255,self.change_lr) 
开发者ID:akash0x53,项目名称:virtual-dressing-room,代码行数:24,代码来源:Tshirt.py

示例4: main

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def main():
    windowname = "OpenCV Media Player"
    cv2.namedWindow(windowname)

    videoFilePath = "/media/amarpandey/Media Files/Movies/Game Of Thrones/Season Seven/Game.of.Thrones.S07E03.720p.WEB.h264-TBS[eztv].mkv"

    capture = cv2.VideoCapture(videoFilePath)
    cv2.createTrackbar('FrameSpeed', windowname, 10, 600, passFunction)

    while (capture.isOpened()):

        FrameSpeed = cv2.getTrackbarPos('FrameSpeed', windowname)
        flag, frame = capture.read()

        if FrameSpeed <= 0: FrameSpeed = 1

        if flag:
            cv2.imshow(windowname, frame)
            if cv2.waitKey(FrameSpeed) & 0xFF == 27:  # because 33 * FPS == 1 second
                break
        else:
            break

    cv2.destroyWindow(windowname)
    capture.release() 
开发者ID:amarlearning,项目名称:Finger-Detection-and-Tracking,代码行数:27,代码来源:MediaPlayer.py

示例5: main

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def main():
    windowName = "OpenCV BGR Color Palette"
    imageData = np.zeros((512, 512, 3), np.uint8)

    cv2.namedWindow(windowName)

    cv2.createTrackbar('Blue', windowName, 0, 255, passFunction)
    cv2.createTrackbar('Green', windowName, 0, 255, passFunction)
    cv2.createTrackbar('Red', windowName, 0, 255, passFunction)

    while (True):
        cv2.imshow(windowName, imageData)

        if cv2.waitKey(1) & 0xFF == 27:
            break

        blue = cv2.getTrackbarPos('Blue', windowName)
        green = cv2.getTrackbarPos('Green', windowName)
        red = cv2.getTrackbarPos('Red', windowName)

        imageData[:] = [blue, green, red]
        print(blue, green, red)

    cv2.destroyWindow(windowName) 
开发者ID:amarlearning,项目名称:Finger-Detection-and-Tracking,代码行数:26,代码来源:ColorPalette.py

示例6: main

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def main():
    windowName = "Transition Effect"

    cv2.namedWindow("Transition Effect")

    imageOne = cv2.imread("../data/lena_color_512.tif", 1)
    imageTwo = cv2.imread("../data/mandril_color.tif", 1)

    cv2.createTrackbar("Alpha", windowName, 0, 1000, passFunction)

    while True:

        alpha = cv2.getTrackbarPos("Alpha", windowName) / 1000
        beta = 1 - alpha

        output = cv2.addWeighted(imageOne, alpha, imageTwo, beta, 0)

        cv2.imshow(windowName, output)

        if cv2.waitKey(1) & 0xFF == 27:
            break

    cv2.destroyAllWindows() 
开发者ID:amarlearning,项目名称:Finger-Detection-and-Tracking,代码行数:25,代码来源:Transition.py

示例7: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def __init__(self, src):
        self.cap = video.create_capture(src, presets['book'])
        self.frame = None
        self.paused = False
        self.tracker = PlaneTracker()

        cv2.namedWindow('plane')
        cv2.createTrackbar('focal', 'plane', 25, 50, common.nothing)
        self.rect_sel = common.RectSelector('plane', self.on_rect) 
开发者ID:makelove,项目名称:OpenCV-Python-Tutorial,代码行数:11,代码来源:plane_ar.py

示例8: main

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def main(argv):

   if (len(sys.argv) < 3):
      print 'Not enough parameters'
      print 'Usage:\nmatch_template_demo.py <image_name> <template_name> [<mask_name>]'
      return -1

   ## [load_image]
   global img
   global templ
   img = cv2.imread(sys.argv[1], cv2.IMREAD_COLOR)
   templ = cv2.imread(sys.argv[2], cv2.IMREAD_COLOR)

   if (len(sys.argv) > 3):
      global use_mask
      use_mask = True
      global mask
      mask = cv2.imread( sys.argv[3], cv2.IMREAD_COLOR )

   if ((img is None) or (templ is None) or (use_mask and (mask is None))):
      print 'Can\'t read one of the images'
      return -1
   ## [load_image]

   ## [create_windows]
   cv2.namedWindow( image_window, cv2.WINDOW_AUTOSIZE )
   cv2.namedWindow( result_window, cv2.WINDOW_AUTOSIZE )
   ## [create_windows]

   ## [create_trackbar]
   trackbar_label = 'Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED'
   cv2.createTrackbar( trackbar_label, image_window, match_method, max_Trackbar, MatchingMethod )
   ## [create_trackbar]

   MatchingMethod(match_method)

   ## [wait_key]
   cv2.waitKey(0)
   return 0
   ## [wait_key] 
开发者ID:makelove,项目名称:OpenCV-Python-Tutorial,代码行数:42,代码来源:match_template.py

示例9: update_category

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def update_category(category_id):
    global g_image_filenames, g_category_id
    g_category_id = category_id
    g_image_filenames = glob.glob(category_folders[category_id] + '/*.jpg')
    cv.createTrackbar("image", 'marker', 0,
                      len(g_image_filenames) - 1, update_image)
    cv.setTrackbarMax('image', 'marker', len(g_image_filenames) - 1)
    update_image(0) 
开发者ID:jing-vision,项目名称:lightnet,代码行数:10,代码来源:auto_marker.py

示例10: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def __init__(self, video_location, start_fnum=0, stop_fnum=0):

        self.capture = cv2.VideoCapture(video_location)
        self.start_fnum = start_fnum
        self.stop_fnum = stop_fnum
        if stop_fnum == 0:
            self.stop_fnum = int(self.capture.get(cv2.CAP_PROP_FRAME_COUNT))

        self.window_name = 'Object Detection'
        self.low_H_name = 'Low H'
        self.low_S_name = 'Low S'
        self.low_V_name = 'Low V'
        self.high_H_name = 'High H'
        self.high_S_name = 'High S'
        self.high_V_name = 'High V'

        self.low_H, self.low_S, self.low_V = 0, 0, 0
        self.high_H, self.high_S, self.high_V = 180, 255, 255

        cv2.namedWindow(self.window_name)
        cv2.createTrackbar(self.low_H_name, self.window_name,
            self.low_H, 180, self.on_low_H_thresh_trackbar)
        cv2.createTrackbar(self.high_H_name, self.window_name,
            self.high_H, 180, self.on_high_H_thresh_trackbar)
        cv2.createTrackbar(self.low_S_name, self.window_name,
            self.low_S, 255, self.on_low_S_thresh_trackbar)
        cv2.createTrackbar(self.high_S_name, self.window_name,
            self.high_S, 255, self.on_high_S_thresh_trackbar)
        cv2.createTrackbar(self.low_V_name, self.window_name,
            self.low_V, 255, self.on_low_V_thresh_trackbar)
        cv2.createTrackbar(self.high_V_name, self.window_name,
            self.high_V, 255, self.on_high_V_thresh_trackbar)


    # The standard test iterates through the entire video with multiple track
    # bars to vary HSV thresholds. Results can be seen in a separate window. 
开发者ID:jpnaterer,项目名称:smashscan,代码行数:38,代码来源:thresholding.py

示例11: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def __init__(self, name, parent_window_name, init_value=0, max_value=255):
        self.parent_window_name = parent_window_name
        self.name = name
        self.init_value = init_value
        self.max_value = max_value

        cv2.createTrackbar(self.name, self.parent_window_name, self.init_value, self.max_value, lambda x: x) 
开发者ID:gaborvecsei,项目名称:Color-Tracker,代码行数:9,代码来源:color_range_detector.py

示例12: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def __init__(self, style_path, img_size=512, scale=1, alpha=1, interpolate=False):
        self.style_imgs = get_files(style_path)

        # Create room for two styles for interpolation
        self.style_rgbs = [None, None]

        self.img_size = img_size
        self.crop_size = 256
        self.scale = scale
        self.alpha = alpha

        cv2.namedWindow('Style Controls')
        if len(self.style_imgs) > 1:
            # Select style image by index
            cv2.createTrackbar('index','Style Controls', 0, len(self.style_imgs)-1, self.set_idx)
        
        # Blend param for AdaIN transform
        cv2.createTrackbar('alpha','Style Controls', 100, 100, self.set_alpha)

        # Resize style to this size before cropping
        cv2.createTrackbar('size','Style Controls', img_size, 2048, self.set_size)

        # Size of square crop box for style
        cv2.createTrackbar('crop size','Style Controls', 256, 2048, self.set_crop_size)

        # Scale the content before processing
        cv2.createTrackbar('scale','Style Controls', int(scale*100), 200, self.set_scale)

        self.set_style(random=True, window='Style Controls', style_idx=0)

        if interpolate:
            # Create a window to show second style image for interpolation
            cv2.namedWindow('style2')
            self.interp_weight = 1.
            cv2.createTrackbar('interpolation','Style Controls', 100, 100, self.set_interp)
            self.set_style(random=True, style_idx=1, window='style2') 
开发者ID:eridgd,项目名称:AdaIN-TF,代码行数:38,代码来源:webcam.py

示例13: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def __init__(self, param_name, win_name, param_min, param_max, update_func=doNothing):
        self._update_func = update_func
        self._trackbar = cv2.createTrackbar(param_name, win_name, param_min, param_max, self._callback)
        self._param_name = param_name
        self._win_name = win_name

    # Trackbarの値を参照 
开发者ID:tody411,项目名称:PyIntroduction,代码行数:9,代码来源:trackbar.py

示例14: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def __init__(self):
        global color
        self.rgb=np.zeros((config.height,config.width,3),np.uint8)
        self.mask=np.zeros((config.height,config.width),np.uint8)
        self.hue_val=color
        self.scratch=np.zeros((config.height,config.width,3),np.uint8)
        
        #cv2.namedWindow("hue")
        #cv2.createTrackbar("hue", "hue",self.hue_val,255,self.change) 
开发者ID:akash0x53,项目名称:virtual-dressing-room,代码行数:11,代码来源:color_replace.py

示例15: _initialize_trackbars

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import createTrackbar [as 别名]
def _initialize_trackbars(self):
        """
        Initialize trackbars by discovering ``block_matcher``'s parameters.
        """
        for parameter in self.block_matcher.parameter_maxima.keys():
            maximum = self.block_matcher.parameter_maxima[parameter]
            if not maximum:
                maximum = self.shortest_dimension
            cv2.createTrackbar(parameter, self.window_name,
                               self.block_matcher.__getattribute__(parameter),
                               maximum,
                               partial(self._set_value, parameter)) 
开发者ID:erget,项目名称:StereoVision,代码行数:14,代码来源:ui_utils.py


注:本文中的cv2.createTrackbar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。