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


Python cv2.destroyWindow方法代碼示例

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


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

示例1: run

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def run(self):
        window_name = "Olympe Streaming Example"
        cv2.namedWindow(window_name, cv2.WINDOW_NORMAL)
        main_thread = next(
            filter(lambda t: t.name == "MainThread", threading.enumerate())
        )
        while main_thread.is_alive():
            with self.flush_queue_lock:
                try:
                    yuv_frame = self.frame_queue.get(timeout=0.01)
                except queue.Empty:
                    continue
                try:
                    self.show_yuv_frame(window_name, yuv_frame)
                except Exception:
                    # We have to continue popping frame from the queue even if
                    # we fail to show one frame
                    traceback.print_exc()
                finally:
                    # Don't forget to unref the yuv frame. We don't want to
                    # starve the video buffer pool
                    yuv_frame.unref()
        cv2.destroyWindow(window_name) 
開發者ID:Parrot-Developers,項目名稱:olympe,代碼行數:25,代碼來源:streaming.py

示例2: main

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [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

示例3: main

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [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

示例4: main

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def main():
    window_name = "Live Video Feed"
    cv2.namedWindow(window_name)

    capture = cv2.VideoCapture(0)

    capture.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
    capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)

    if capture.isOpened():
        flag, frame = capture.read()
    else:
        flag = False

    while flag:

        flag, frame = capture.read()

        cv2.imshow(window_name, frame)
        if cv2.waitKey(1) & 0xFF == 27:
            break

    cv2.destroyWindow(window_name)
    capture.release() 
開發者ID:amarlearning,項目名稱:Finger-Detection-and-Tracking,代碼行數:26,代碼來源:VideoCamera.py

示例5: __rendering_loop

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def __rendering_loop(cls):
        window_names = set()
        while cls._rendering_thread:
            try:
                winname, img = cls._rendering_queue.get(block=False)
                cv2.imshow(winname, img)
                window_names.add(winname)
            except queue.Empty:
                pass

            event_time = max(1000 // cls.FPS, 1)
            key = cv2.waitKey(event_time)
            if key != -1:
                cls._keys_queue.put(key)
        
        # finalize
        for winname in window_names:
            cv2.destroyWindow(winname) 
開發者ID:TUMFTM,項目名稱:CameraRadarFusionNet,代碼行數:20,代碼來源:visualization_helpers.py

示例6: test_minicap

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def test_minicap():
    from atx.drivers.android_minicap import AndroidDeviceMinicap

    cv2.namedWindow("preview")
    d = AndroidDeviceMinicap()

    while True:
        try:
            h, w = d._screen.shape[:2]
            img = cv2.resize(d._screen, (w/2, h/2))
            cv2.imshow('preview', img)
            key = cv2.waitKey(1)
            if key == 100: # d for dump
                filename = time.strftime('%Y%m%d%H%M%S.png')
                cv2.imwrite(filename, d._screen)
        except KeyboardInterrupt:
            break
    cv2.destroyWindow('preview') 
開發者ID:NetEaseGame,項目名稱:ATX,代碼行數:20,代碼來源:test_android.py

示例7: stitch

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def stitch(self, image):
        print "stitch called"
        # cv2.imshow("StitchImage", utils.image_resize(image, height = 400))
        # cv2.waitKey()
        # cv2.destroyWindow("StitchImage")
        gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        rightKps, rightDescriptor = self.detectAndDescribe(gray)
        H = self.getHomography(rightKps, rightDescriptor)
        if H is None:
            return None
        leftImageShape = self.leftImage.shape
        result = cv2.warpPerspective(image, H, (leftImageShape[1] + image.shape[1], image.shape[0]))
        result[0:leftImageShape[0], 0:leftImageShape[1]] = self.leftImage

    #     Update leftImage stats
    #     print(H)
        print("Stitch done!")
        self.leftImage = result
        self.leftKps = rightKps
        self.leftDescriptor = rightDescriptor
        # cv2.imshow("StitchImage", utils.image_resize(result, height = 400))
        # cv2.waitKey()
        # cv2.destroyWindow("StitchImage")
        return 
開發者ID:shekkizh,項目名稱:ImageProcessingProjects,代碼行數:26,代碼來源:StitchingFromVideo.py

示例8: stitch

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def stitch(self, image):
        print "stitch called"
        # cv2.imshow("StitchImage", utils.image_resize(image, height = 400))
        # cv2.waitKey()
        # cv2.destroyWindow("StitchImage")
        gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        rightKps, rightDescriptor = self.detectAndDescribe(gray)
        H = self.getHomography(rightKps, rightDescriptor)
        if H is None:
            return None
        leftImageShape = self.leftImage.shape
        result = cv2.warpPerspective(image, H, (leftImageShape[1] + image.shape[1], image.shape[0]))
        result[0:leftImageShape[0], 0:leftImageShape[1]] = self.leftImage

    #     Update leftImage stats
        print("Stitch done!")
        self.leftImage = result
        self.leftKps = rightKps
        self.leftDescriptor = rightDescriptor
        return 
開發者ID:shekkizh,項目名稱:ImageProcessingProjects,代碼行數:22,代碼來源:ImageStitching.py

示例9: main

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def main():
    previewWindow = cv2.namedWindow(WINDOW_NAME) # open a window to show debugging images

    vc = cv2.VideoCapture(0) # Initialize the default camera
    if vc.isOpened(): # try to get the first frame
        (readSuccessful, frame) = vc.read()
    else:
        print "Could not open the system camera. Is another instance already running?"
        readSuccessful = False

    while readSuccessful:
        handleFrame(frame, allowDebugDisplay=True)
        key = cv2.waitKey(10)
        if key == 27: # exit on ESC
#            cv2.imwrite( "lastOutput.png", frame) #save the last-displayed image to file, for our report
            break
        # Get Image from camera
        readSuccessful, frame = vc.read()
    vc.release() #close the camera
    cv2.destroyWindow(WINDOW_NAME) #close the window 
開發者ID:LukeAllen,項目名稱:optimeyes,代碼行數:22,代碼來源:testHaarCascade.py

示例10: main

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def main():
    cv2.namedWindow(WINDOW_NAME) # open a window to show debugging images
    vc = cv2.VideoCapture(0) # Initialize the default camera
    try:
        if vc.isOpened(): # try to get the first frame
            (readSuccessful, frame) = vc.read()
        else:
            raise(Exception("failed to open camera."))
            readSuccessful = False
    
        while readSuccessful:
            pupilOffsetXYList = getOffset(frame, allowDebugDisplay=True)
            key = cv2.waitKey(10)
            if key == 27: # exit on ESC
                cv2.imwrite( "lastOutput.png", frame) #save the last-displayed image to file, for our report
                break
            # Get Image from camera
            readSuccessful, frame = vc.read()
    finally:
        vc.release() #close the camera
        cv2.destroyWindow(WINDOW_NAME) #close the window 
開發者ID:LukeAllen,項目名稱:optimeyes,代碼行數:23,代碼來源:eyeDetect.py

示例11: drawFloorCrop

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def drawFloorCrop(event, x, y, flags, params):
    global perspectiveMatrix, name, RENEW_TETRAGON
    imgCroppingPolygon = np.zeros_like(params['imgFloorCorners'])
    if event == cv2.EVENT_RBUTTONUP:
        cv2.destroyWindow(f'Floor Corners for {name}')
    if len(params['croppingPolygons'][name]) > 4 and event == cv2.EVENT_LBUTTONUP:
        RENEW_TETRAGON = True
        h = params['imgFloorCorners'].shape[0]
        # delete 5th extra vertex of the floor cropping tetragon
        params['croppingPolygons'][name] = np.delete(params['croppingPolygons'][name], -1, 0)
        params['croppingPolygons'][name] = params['croppingPolygons'][name] - [h,0]
        
        # Sort cropping tetragon vertices counter-clockwise starting with top left
        params['croppingPolygons'][name] = counterclockwiseSort(params['croppingPolygons'][name])
        # Get the matrix of perspective transformation
        params['croppingPolygons'][name] = np.reshape(params['croppingPolygons'][name], (4,2))
        tetragonVertices = np.float32(params['croppingPolygons'][name])
        tetragonVerticesUpd = np.float32([[0,0], [0,h], [h,h], [h,0]])
        perspectiveMatrix[name] = cv2.getPerspectiveTransform(tetragonVertices, tetragonVerticesUpd)
    if event == cv2.EVENT_LBUTTONDOWN:
        if len(params['croppingPolygons'][name]) == 4 and RENEW_TETRAGON:
            params['croppingPolygons'][name] = np.array([[0,0]])
            RENEW_TETRAGON = False
        if len(params['croppingPolygons'][name]) == 1:
            params['croppingPolygons'][name][0] = [x,y]
        params['croppingPolygons'][name] = np.append(params['croppingPolygons'][name], [[x,y]], axis=0)
    if event == cv2.EVENT_MOUSEMOVE and not (len(params['croppingPolygons'][name]) == 4 and RENEW_TETRAGON):
        params['croppingPolygons'][name][-1] = [x,y]
        if len(params['croppingPolygons'][name]) > 1:
            cv2.fillPoly(
                imgCroppingPolygon,
                [np.reshape(
                    params['croppingPolygons'][name],
                    (len(params['croppingPolygons'][name]),2)
                )],
                BGR_COLOR['green'], cv2.LINE_AA)
            imgCroppingPolygon = cv2.addWeighted(params['imgFloorCorners'], 1.0, imgCroppingPolygon, 0.5, 0.)
            cv2.imshow(f'Floor Corners for {name}', imgCroppingPolygon) 
開發者ID:colinlaney,項目名稱:animal-tracking,代碼行數:40,代碼來源:track.py

示例12: run

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def run(self):
        while True:
            try:
                self.sock.connect(self.ADDR)
                break
            except:
                time.sleep(3)
                continue
        if self.showme:
            cv2.namedWindow('You', cv2.WINDOW_NORMAL)
        print("VEDIO client connected...")
        while self.cap.isOpened():
            ret, frame = self.cap.read()
            if self.showme:
                cv2.imshow('You', frame)
                if cv2.waitKey(1) & 0xFF == 27:
                    self.showme = False
                    cv2.destroyWindow('You')
            sframe = cv2.resize(frame, (0, 0), fx=self.fx, fy=self.fx)
            data = pickle.dumps(sframe)
            zdata = zlib.compress(data, zlib.Z_BEST_COMPRESSION)
            try:
                self.sock.sendall(struct.pack("L", len(zdata)) + zdata)
            except:
                break
            for i in range(self.interval):
                self.cap.read() 
開發者ID:11ze,項目名稱:The-chat-room,代碼行數:29,代碼來源:vachat.py

示例13: show_webcam_and_run

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def show_webcam_and_run(model, emoticons, window_size=None, window_name='webcam', update_time=10):
    """
    Shows webcam image, detects faces and its emotions in real time and draw emoticons over those faces.
    :param model: Learnt emotion detection model.
    :param emoticons: List of emotions images.
    :param window_size: Size of webcam image window.
    :param window_name: Name of webcam image window.
    :param update_time: Image update time interval.
    """
    cv2.namedWindow(window_name, WINDOW_NORMAL)
    if window_size:
        width, height = window_size
        cv2.resizeWindow(window_name, width, height)

    vc = cv2.VideoCapture(0)
    if vc.isOpened():
        read_value, webcam_image = vc.read()
    else:
        print("webcam not found")
        return

    while read_value:
        for normalized_face, (x, y, w, h) in find_faces(webcam_image):
            prediction = model.predict(normalized_face)  # do prediction
            if cv2.__version__ != '3.1.0':
                prediction = prediction[0]

            image_to_draw = emoticons[prediction]
            draw_with_alpha(webcam_image, image_to_draw, (x, y, w, h))

        cv2.imshow(window_name, webcam_image)
        read_value, webcam_image = vc.read()
        key = cv2.waitKey(update_time)

        if key == 27:  # exit on ESC
            break

    cv2.destroyWindow(window_name) 
開發者ID:PiotrDabrowskey,項目名稱:facemoji,代碼行數:40,代碼來源:webcam.py

示例14: testModel

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def testModel(self):
        """ 
        This method is to test the trained classifier

        read all images from testing path 
        use BOVHelpers.predict() function to obtain classes of each image

        """

        self.testImages, self.testImageCount = self.file_helper.getFiles(self.test_path)

        predictions = []

        for word, imlist in self.testImages.iteritems():
            print "processing " ,word
            for im in imlist:
                # print imlist[0].shape, imlist[1].shape
                print im.shape
                cl = self.recognize(im)
                print cl
                predictions.append({
                    'image':im,
                    'class':cl,
                    'object_name':self.name_dict[str(int(cl[0]))]
                    })

        print predictions
        for each in predictions:
            # cv2.imshow(each['object_name'], each['image'])
            # cv2.waitKey()
            # cv2.destroyWindow(each['object_name'])
            # 
            plt.imshow(cv2.cvtColor(each['image'], cv2.COLOR_GRAY2RGB))
            plt.title(each['object_name'])
            plt.show() 
開發者ID:kushalvyas,項目名稱:Bag-of-Visual-Words-Python,代碼行數:37,代碼來源:Bag.py

示例15: stop

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import destroyWindow [as 別名]
def stop():
    ximea.release()
    cv2.destroyAllWindows()
    cv2.destroyWindow("Displayer") 
開發者ID:LaboratoireMecaniqueLille,項目名稱:crappy,代碼行數:6,代碼來源:example.py


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