当前位置: 首页>>代码示例>>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;未经允许,请勿转载。