當前位置: 首頁>>代碼示例>>Python>>正文


Python cv2.startWindowThread方法代碼示例

本文整理匯總了Python中cv2.startWindowThread方法的典型用法代碼示例。如果您正苦於以下問題:Python cv2.startWindowThread方法的具體用法?Python cv2.startWindowThread怎麽用?Python cv2.startWindowThread使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cv2的用法示例。


在下文中一共展示了cv2.startWindowThread方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: pick_corrs

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def pick_corrs(images, n_pts_to_pick=4):
    data = [ [[], 0, False, False, False, image, "Image %d" % i, n_pts_to_pick]
            for i, image in enumerate(images)]

    for d in data:
        win_name = d[6]
        cv2.namedWindow(win_name)
        cv2.setMouseCallback(win_name, corr_picker_callback, d)
        cv2.startWindowThread()
        cv2.imshow(win_name, d[5])

    key = None
    while key != '\n' and key != '\r' and key != 'q':
        key = cv2.waitKey(33)
        key = chr(key & 255) if key >= 0 else None

    cv2.destroyAllWindows()

    if key == 'q':
        return None
    else:
        return [d[0] for d in data] 
開發者ID:nelpy,項目名稱:nelpy,代碼行數:24,代碼來源:homography.py

示例2: dump_2dcoor

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def dump_2dcoor():
    camera = libcpm.Camera()
    camera.setup()
    runner = get_parallel_runner('../data/cpm.npy')
    cv2.namedWindow('color')
    cv2.startWindowThread()
    cnt = 0
    while True:
        cnt += 1
        m1 = camera.get_for_py(0)
        m1 = np.array(m1, copy=False)
        m2 = camera.get_for_py(1)
        m2 = np.array(m2, copy=False)

        o1, o2 = runner(m1, m2)
        pts = []
        for k in range(14):
            pts.append((argmax_2d(o1[:,:,k]),
                argmax_2d(o2[:,:,k])))
        pts = np.asarray(pts)
        np.save('pts{}.npy'.format(cnt), pts)
        cv2.imwrite("frame{}.png".format(cnt), m1);
        if cnt == 10:
            break 
開發者ID:ppwwyyxx,項目名稱:Stereo-Pose-Machines,代碼行數:26,代碼來源:main.py

示例3: main

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def main():
    '''
    Arguments to be set:
        showCam : determine if show the camera preview screen.
    '''
    print("Enter main() function")
    
    if args.testImage is not None:
        img = cv2.imread(args.testImage)
        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        img = cv2.resize(img, FACE_SHAPE)
        print(class_label[result[0]])
        sys.exit(0)

    showCam = 1

    capture = getCameraStreaming()

    if showCam:
        cv2.startWindowThread()
        cv2.namedWindow(windowsName, cv2.WND_PROP_FULLSCREEN)
        cv2.setWindowProperty(windowsName, cv2.WND_PROP_FULLSCREEN, cv2.WND_PROP_FULLSCREEN)
    
    showScreenAndDectect(capture) 
開發者ID:a514514772,項目名稱:Real-Time-Facial-Expression-Recognition-with-DeepLearning,代碼行數:26,代碼來源:webcam_detection.py

示例4: run

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def run(self):
        cv2.startWindowThread()
        while True:
            img = numpy.zeros((480, 640, 3))
            skeleton = kinect.tracked_skeleton
            if skeleton:
                for user, skel in skeleton.items():
                    for joint_name in skel.joints:
                        x, y = getattr(skel, joint_name).pixel_coordinate
                        pt = (int(x), int(y))
                        cv2.circle(img, pt, 5, (255, 255, 255), thickness=-1)
                kinect.remove_all_users()
            cv2.imshow('Skeleton', img)
            cv2.waitKey(50)

        self.sub_skel.close()
        self.context.term() 
開發者ID:poppy-project,項目名稱:pypot,代碼行數:19,代碼來源:sensor.py

示例5: __init__

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def __init__(self, rom_name, vis,frameskip=1,windowname='preview'):
    self.ale = ALEInterface()
    self.max_frames_per_episode = self.ale.getInt("max_num_frames_per_episode");
    self.ale.setInt("random_seed",123)
    self.ale.setInt("frame_skip",frameskip)
    romfile = str(ROM_PATH)+str(rom_name)
    if not os.path.exists(romfile):
      print('No ROM file found at "'+romfile+'".\nAdjust ROM_PATH or double-check the filt exists.')
    self.ale.loadROM(romfile)
    self.legal_actions = self.ale.getMinimalActionSet()
    self.action_map = dict()
    self.windowname = windowname
    for i in range(len(self.legal_actions)):
      self.action_map[self.legal_actions[i]] = i

    # print(self.legal_actions)
    self.screen_width,self.screen_height = self.ale.getScreenDims()
    print("width/height: " +str(self.screen_width) + "/" + str(self.screen_height))
    self.vis = vis
    if vis:
      cv2.startWindowThread()
      cv2.namedWindow(self.windowname, flags=cv2.WINDOW_AUTOSIZE) # permit manual resizing 
開發者ID:rdadolf,項目名稱:fathom,代碼行數:24,代碼來源:emulator.py

示例6: preview_stream

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def preview_stream(stream):
    """ Display stream in an OpenCV window until "q" key is pressed """
    # together with waitkeys later, helps to close the video window effectively
    _cv2.startWindowThread()
    
    for frame in stream.frame_generator():
        if frame is not None:
            _cv2.imshow('Video', frame)
            _cv2.moveWindow('Video',5,5)
        else:
            break
        key = _cv2.waitKey(1) & 0xFF
        if key == ord("q"):
            break
    _cv2.waitKey(1)
    _cv2.destroyAllWindows()
    _cv2.waitKey(1) 
開發者ID:statueofmike,項目名稱:rtsp,代碼行數:19,代碼來源:preview.py

示例7: __init__

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def __init__(self, src, window_name=None, org=None):
        self.src = src
        self.window_name = window_name if window_name else src

        cv2.startWindowThread()
        cv2.namedWindow(self.window_name, cv2.WINDOW_AUTOSIZE)
        if org:
            # Set the window position
            x, y = org
            cv2.moveWindow(self.window_name, x, y)

        super().__init__() 
開發者ID:jagin,項目名稱:detectron2-pipeline,代碼行數:14,代碼來源:display_video.py

示例8: resizeImage

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def resizeImage(file_path): 
    #Resize Cropping & Padding an image to the 640x480 pixel size
    if file_path is not -1:
        if check_image_with_pil(file_path):
            image = Image.open(file_path)
            image.thumbnail(size, Image.ANTIALIAS)
            image_size = image.size

            padding_0 = max( (size[0] - image_size[0]) / 2, 0 )
            padding_1 = max( (size[1] - image_size[1]) / 2, 0 )
            cv2.namedWindow('Original Image')
            cv2.namedWindow('Resized Image')
            cv2.startWindowThread()
            orig_img = cv2.imread(file_path, 0)
            cv2.imshow('Original Image',orig_img)
            cv2.waitKey(2)

            if((padding_0==0) & (padding_1==0)):
                image.save(file_path, img_save_type)
            else:
                thumb = image.crop( (0, 0, size[0], size[1]) )
                thumb = ImageChops.offset(thumb, int(padding_0), int(padding_1))
                thumb.save(file_path)

            resized_img = cv2.imread(file_path, 0)
            cv2.imshow('Resized Image',resized_img)
    else :
        cv2.destroyAllWindows()
        cv2.waitKey(2) 
開發者ID:DrewNF,項目名稱:Tensorflow_Object_Tracking_Video,代碼行數:31,代碼來源:Utils_Image.py

示例9: stereo_cpm_viewer

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def stereo_cpm_viewer():
    camera = libcpm.Camera()
    camera.setup()
    runner = get_parallel_runner('../data/cpm.npy')
    cv2.namedWindow('color')
    cv2.startWindowThread()
    cnt = 0
    while True:
        cnt += 1
        m1 = camera.get_for_py(0)
        m1 = np.array(m1, copy=False)
        m2 = camera.get_for_py(1)
        m2 = np.array(m2, copy=False)

        m1s = cv2.resize(m1, (368,368))
        m2s = cv2.resize(m2, (368,368))

        o1, o2 = runner(m1s, m2s)

        #buf = dumps([m1, m2, o1, o2])
        #f = open('recording/{:03d}.npy'.format(cnt), 'w')
        #f.write(buf)
        #f.close()

        c1 = colorize(m1, o1[:,:,:-1].sum(axis=2))
        c2 = colorize(m2, o2[:,:,:-1].sum(axis=2))
        viz = np.concatenate((c1, c2), axis=1)
        cv2.imshow('color', viz / 255.0) 
開發者ID:ppwwyyxx,項目名稱:Stereo-Pose-Machines,代碼行數:30,代碼來源:main.py

示例10: main

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def main():
    '''
    Arguments to be set:
        showCam : determine if show the camera preview screen.
    '''
    print("Enter main() function")
    
    capture = getCameraStreaming()

    cv2.startWindowThread()
    cv2.namedWindow(windowsName, cv2.WND_PROP_FULLSCREEN)
    cv2.setWindowProperty(windowsName, cv2.WND_PROP_FULLSCREEN, cv2.WND_PROP_FULLSCREEN)
    
    while True:
        recContent = speechRecognition()
        if recContent is not None:
            emotion = showScreenAndDectect(capture)
            if emotion == "Angry":
                emoji = " >:O"
            elif emotion == "Fear":
                emoji = " :-S"
            elif emotion == "Happy":
                emoji = " :-D"
            elif emotion == "Sad":
                emoji = " :'("
            elif emotion == "Surprise":
                emoji = " :-O"
            else:
                emoji = " "
            print("Output result: " + recContent + emoji) 
開發者ID:a514514772,項目名稱:Real-Time-Facial-Expression-Recognition-with-DeepLearning,代碼行數:32,代碼來源:gen_sentence_with_emoticons.py

示例11: test_ssd

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def test_ssd():
    face_detector = FaceDetectorSSDMobilenetV2()
    image = os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            "samples/blackpink/blackpink4.jpg")
    print("image path is: " + image)
    test_image = cv2.imread(image, cv2.IMREAD_COLOR)
    faces = face_detector.detect(test_image)

    for face in faces:
      cv2.rectangle(test_image,(int(face.x),int(face.y)),(int(face.x + face.w), int(face.y + face.h)), (0,255,0),3)

    window_name = "image"
    cv2.namedWindow(window_name, cv2.WND_PROP_AUTOSIZE)
    cv2.startWindowThread()

    cv2.imshow('image', test_image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    cv2.waitKey(1)
    print("done showing face annotated image!")

    for face in faces:
      print(face.face_landmark)

    print("done") 
開發者ID:ildoonet,項目名稱:deepface,代碼行數:28,代碼來源:test_scripts.py

示例12: test_ssd_webcam

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def test_ssd_webcam():
    cap = cv2.VideoCapture(0)
    # Define the codec and create VideoWriter object
    fourcc = cv2.VideoWriter_fourcc(*'MP4V')
    out = cv2.VideoWriter('ssd_output.mp4', fourcc, 60.0, (640, 480))

    face_detector = FaceDetectorSSDMobilenetV2()
    while(True):
        ret, frame = cap.read()

        test_image = frame
        faces = face_detector.detect(test_image)

        for face in faces:
          cv2.rectangle(test_image,(int(face.x),int(face.y)),(int(face.x + face.w), int(face.y + face.h)), (0,255,0),3)

        window_name = "image"
        cv2.namedWindow(window_name, cv2.WND_PROP_AUTOSIZE)
        cv2.startWindowThread()

        out.write(test_image)
        cv2.imshow(window_name, test_image)

        if cv2.waitKey(5) & 0xFF == ord('q'):
            break

    cap.release()
    out.release()
    cv2.destroyAllWindows() 
開發者ID:ildoonet,項目名稱:deepface,代碼行數:31,代碼來源:test_scripts.py

示例13: imshow

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def imshow(image):
    import cv2 as cv
    if isinstance(image, str):
        image = cv.imread(image)
    cv.startWindowThread()
    cv.namedWindow('Image', cv.WINDOW_NORMAL)
    cv.imshow('Image', image) 
開發者ID:BCV-Uniandes,項目名稱:AUNets,代碼行數:9,代碼來源:get_augmentation.py

示例14: imshow

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def imshow(image, name=0):
    import cv2 as cv
    if isinstance(image, str):
        image = cv.imread(image)
    cv.startWindowThread()
    cv.namedWindow(str(name), cv.WINDOW_NORMAL)
    cv.imshow(str(name), image) 
開發者ID:BCV-Uniandes,項目名稱:AUNets,代碼行數:9,代碼來源:OF_resizeBP4D.py

示例15: __init__

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import startWindowThread [as 別名]
def __init__(self, src, window_name=None, org=None):
        self.src = src
        self.window_name = window_name if window_name else src

        cv2.startWindowThread()
        cv2.namedWindow(self.window_name, cv2.WINDOW_AUTOSIZE)
        if org:
            # Set the window position
            x, y = org
            cv2.moveWindow(self.window_name, x, y)

        super(DisplayVideo, self).__init__() 
開發者ID:jagin,項目名稱:image-processing-pipeline,代碼行數:14,代碼來源:display_video.py


注:本文中的cv2.startWindowThread方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。