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


Python cv2.setTrackbarPos方法代码示例

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


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

示例1: set_selected_bbox

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def set_selected_bbox(set_class):
    global is_bbox_selected, selected_bbox
    smallest_area = -1
    # if clicked inside multiple bboxes selects the smallest one
    for idx, obj in enumerate(img_objects):
        ind, x1, y1, x2, y2 = obj
        x1 = x1 - dragBBox.sRA
        y1 = y1 - dragBBox.sRA
        x2 = x2 + dragBBox.sRA
        y2 = y2 + dragBBox.sRA
        if pointInRect(mouse_x, mouse_y, x1, y1, x2, y2):
            is_bbox_selected = True
            tmp_area = get_bbox_area(x1, y1, x2, y2)
            if tmp_area < smallest_area or smallest_area == -1:
                smallest_area = tmp_area
                selected_bbox = idx
                if set_class:
                    # set class to the one of the selected bounding box
                    cv2.setTrackbarPos(TRACKBAR_CLASS, WINDOW_NAME, ind) 
开发者ID:Cartucho,项目名称:OpenLabeling,代码行数:21,代码来源:main.py

示例2: on_low_H_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_low_H_thresh_trackbar(val):
	global low_H
	global high_H
	low_H = val
	low_H = min(high_H-1, low_H)
	cv.setTrackbarPos(low_H_name, window_detection_name, low_H) 
开发者ID:ChengZhongShen,项目名称:Advanced_Lane_Lines,代码行数:8,代码来源:InRange.py

示例3: on_high_H_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_high_H_thresh_trackbar(val):
	global low_H
	global high_H
	high_H = val
	high_H = max(high_H, low_H+1)
	cv.setTrackbarPos(high_H_name, window_detection_name, high_H) 
开发者ID:ChengZhongShen,项目名称:Advanced_Lane_Lines,代码行数:8,代码来源:InRange.py

示例4: on_low_S_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_low_S_thresh_trackbar(val):
	global low_S 
	global high_S
	low_S = val
	low_S = min(high_S - 1, low_S)
	cv.setTrackbarPos(low_S_name, window_detection_name, low_S) 
开发者ID:ChengZhongShen,项目名称:Advanced_Lane_Lines,代码行数:8,代码来源:InRange.py

示例5: on_high_S_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_high_S_thresh_trackbar(val):
	global low_S
	global high_S
	high_S = val
	high_S = max(high_S, low_S+1)
	cv.setTrackbarPos(high_S_name, window_detection_name, high_S) 
开发者ID:ChengZhongShen,项目名称:Advanced_Lane_Lines,代码行数:8,代码来源:InRange.py

示例6: on_low_V_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_low_V_thresh_trackbar(val):
	global low_V 
	global high_V
	low_V = val
	low_V = min(high_V-1, low_V)
	cv.setTrackbarPos(low_V_name, window_detection_name, low_V) 
开发者ID:ChengZhongShen,项目名称:Advanced_Lane_Lines,代码行数:8,代码来源:InRange.py

示例7: update_image

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def update_image(image_id, category_id = 0, image_filenames=[], enable_vis=True, enable_marker_dump=False):
    try:
        global contours, hierarchy, img, gray, g_image_filenames
        if len(image_filenames) > 0:
            g_image_filenames=image_filenames
        img=cv.imread(g_image_filenames[image_id])
        # print(g_image_filenames[image_id])
        cv.setTrackbarPos('image', 'marker', image_id)

        gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
        gray[np.where(gray <= [3])] = [187]
        gray = cv.medianBlur(gray, 11)

        if enable_vis:
            cv.imshow('gray', gray)

        if CANNY_MODE:
            thrs1 = cv.getTrackbarPos('thrs1', 'marker')
            thrs2 = cv.getTrackbarPos('thrs2', 'marker')
            bin = cv.Canny(gray, thrs1, thrs2, apertureSize=5)
        else:
            bin = cv.adaptiveThreshold(
                gray, 255, cv.ADAPTIVE_THRESH_MEAN_C, cv.THRESH_BINARY_INV, 31, 10)

        if enable_vis:
            cv.imshow('bin', bin)

        _, contours0, hierarchy = cv.findContours(
            bin.copy(), cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
        contours = [cnt for cnt in contours0 if cv.contourArea(cnt) > 200]

        if enable_vis:
            cv.imshow('image', img)
        update_contour(category_id, image_id, enable_vis, enable_marker_dump)
    except Exception:
        import traceback
        traceback.print_exc()
        raise 
开发者ID:jing-vision,项目名称:lightnet,代码行数:40,代码来源:auto_marker.py

示例8: on_low_H_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_low_H_thresh_trackbar(self, val):
        self.low_H = val
        self.low_H = min(self.high_H-1, self.low_H)
        cv2.setTrackbarPos(self.low_H_name, self.window_name, self.low_H) 
开发者ID:jpnaterer,项目名称:smashscan,代码行数:6,代码来源:thresholding.py

示例9: on_high_H_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_high_H_thresh_trackbar(self, val):
        self.high_H = val
        self.high_H = max(self.high_H, self.low_H+1)
        cv2.setTrackbarPos(self.high_H_name, self.window_name, self.high_H) 
开发者ID:jpnaterer,项目名称:smashscan,代码行数:6,代码来源:thresholding.py

示例10: on_low_S_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_low_S_thresh_trackbar(self, val):
        self.low_S = val
        self.low_S = min(self.high_S-1, self.low_S)
        cv2.setTrackbarPos(self.low_S_name, self.window_name, self.low_S) 
开发者ID:jpnaterer,项目名称:smashscan,代码行数:6,代码来源:thresholding.py

示例11: on_high_S_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_high_S_thresh_trackbar(self, val):
        self.high_S = val
        self.high_S = max(self.high_S, self.low_S+1)
        cv2.setTrackbarPos(self.high_S_name, self.window_name, self.high_S) 
开发者ID:jpnaterer,项目名称:smashscan,代码行数:6,代码来源:thresholding.py

示例12: on_low_V_thresh_trackbar

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def on_low_V_thresh_trackbar(self, val):
        self.low_V = val
        self.low_V = min(self.high_V-1, self.low_V)
        cv2.setTrackbarPos(self.low_V_name, self.window_name, self.low_V) 
开发者ID:jpnaterer,项目名称:smashscan,代码行数:6,代码来源:thresholding.py

示例13: setValue

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def setValue(self, value):
        cv2.setTrackbarPos(self._param_name, self._win_name, value) 
开发者ID:tody411,项目名称:PyIntroduction,代码行数:4,代码来源:trackbar.py

示例14: preview

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def preview(filename, classifier):
    cv2.namedWindow('video')

    duration = int(get_video_duration(filename))

    def trackbar_change(t):
        cap.set(cv2.cv.CV_CAP_PROP_POS_MSEC, t*1000)

    trackbar_prompt = 'Current position:'
    cv2.createTrackbar(trackbar_prompt, 'video', 0, duration, trackbar_change)

    cap = cv2.VideoCapture(filename)

    classification_result = None
    previous_time_in_seconds = None
    current_pos = 0

    tmp = tempfile.NamedTemporaryFile(suffix=".png")    
    
    while cap.isOpened():
        ret, frame = cap.read()

        cv2.imwrite(tmp.name, frame)

        if ret:
            current_pos = get_current_position(cap)

            if current_pos != previous_time_in_seconds:
                previous_time_in_seconds = current_pos
                classification_result = classifier.classify_image(tmp.name)
            
            if classification_result:
                add_text_to_frame(frame, format_classification(classification_result))

            cv2.imshow('video', frame)
        
        cv2.setTrackbarPos(trackbar_prompt, 'video', current_pos)
    
        k = cv2.waitKey(1) & 0xFF
        if k == 27:
            break

    cap.release()
    cv2.destroyAllWindows() 
开发者ID:agermanidis,项目名称:thingscoop,代码行数:46,代码来源:preview.py

示例15: init_trackers

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import setTrackbarPos [as 别名]
def init_trackers(self, bboxes, classIds, json_file_data,json_file_path, img_path):
        global img_index

        anchor_id = json_file_data['n_anchor_ids']
        frame_data_dict = json_file_data['frame_data_dict']
        image = cv2.imread(img_path)
        for box, classId in zip(bboxes, classIds):
            # Init trackers with those classId and anchorId
            anchor_id = anchor_id + 1
            tracker = Tracker(self.tracker_type, anchorId=anchor_id, classId=classId)
            initial_bbox = (box[0], box[1], box[2], box[3])
            tracker.instance.init(self.init_frame, initial_bbox)
            self.trackers.append(tracker)

            # Initialize trackers on json files.
            pred_counter  = 0
            xmin, ymin, w, h = map(int, box)
            xmax = xmin + w
            ymax = ymin + h
            obj = [int(classId), xmin, ymin, xmax, ymax]
            frame_data_dict = json_file_add_object(frame_data_dict, img_path, anchor_id, pred_counter, obj)

            # Save prediction
            annotation_paths = get_annotation_paths(img_path, annotation_formats)
            save_bounding_box(annotation_paths, int(classId), (xmin, ymin), (xmax, ymax), self.img_w, self.img_h)



            #Draw
            color = class_rgb[int(tracker.classId)].tolist()
            cv2.rectangle(image, (xmin, ymin), (xmax, ymax), color, LINE_THICKNESS)

        img_index = increase_index(img_index, last_img_index)
        cv2.setTrackbarPos(TRACKBAR_IMG, WINDOW_NAME, img_index)
        cv2.imshow(WINDOW_NAME, image)
        pressed_key = cv2.waitKey(DELAY)

        json_file_data.update({'n_anchor_ids': (anchor_id + 1)})

        # save the updated data
        with open(json_file_path, 'w') as outfile:
            json.dump(json_file_data, outfile, sort_keys=True, indent=4) 
开发者ID:Cartucho,项目名称:OpenLabeling,代码行数:44,代码来源:main_auto.py


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