當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。