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


Python cv2.destroyAllWindows方法代码示例

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


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

示例1: main

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def main():
	capture = cv2.VideoCapture(0)
	_, image = capture.read()
	previous = image.copy()
	
	
	while (cv2.waitKey(1) < 0):
		_, image = capture.read()
		diff = cv2.absdiff(image, previous)
		#image = cv2.flip(image, 3)
		#image = cv2.norm(image)
		_, diff = cv2.threshold(diff, 32, 0, cv2.THRESH_TOZERO)
		_, diff = cv2.threshold(diff, 0, 255, cv2.THRESH_BINARY)
		
		diff = cv2.medianBlur(diff, 5)
		
		cv2.imshow('video', diff)
		previous = image.copy()
		
	capture.release()
	cv2.destroyAllWindows() 
开发者ID:petern3,项目名称:crop_row_detection,代码行数:23,代码来源:camera_test.py

示例2: processFrames

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def processFrames(self):
        try:
            for img in self.anotations_list:
                img = img.split(';')
                # print(img)
                # ret,imgcv = cap.read()
                if self.video:
                    ret,imgcv = self.cap.read()
                else:
                    imgcv = cv2.imread(os.path.join('../',self.config["dataset"],img[0]))
                result = self.tfnet.return_predict(imgcv)
                print(result)
                imgcv = self.drawBoundingBox(imgcv,result)        
                cv2.imshow('detected objects',imgcv)
                if cv2.waitKey(10) == ord('q'):
                    print('exitting loop')
                    break
        except KeyboardInterrupt:
            cv2.destroyAllWindows()
            print('exitting program') 
开发者ID:AmeyaWagh,项目名称:Traffic_sign_detection_YOLO,代码行数:22,代码来源:objectDetectorYOLO.py

示例3: show

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def show(im, allobj, S, w, h, cellx, celly):
    for obj in allobj:
        a = obj[5] % S
        b = obj[5] // S
        cx = a + obj[1]
        cy = b + obj[2]
        centerx = cx * cellx
        centery = cy * celly
        ww = obj[3]**2 * w
        hh = obj[4]**2 * h
        cv2.rectangle(im,
            (int(centerx - ww/2), int(centery - hh/2)),
            (int(centerx + ww/2), int(centery + hh/2)),
            (0,0,255), 2)
    cv2.imshow('result', im)
    cv2.waitKey()
    cv2.destroyAllWindows() 
开发者ID:AmeyaWagh,项目名称:Traffic_sign_detection_YOLO,代码行数:19,代码来源:misc.py

示例4: __next__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def __next__(self):
        self.count += 1
        img0 = self.imgs.copy()
        if cv2.waitKey(1) == ord('q'):  # q to quit
            cv2.destroyAllWindows()
            raise StopIteration

        # Letterbox
        img = [letterbox(x, new_shape=self.img_size, interp=cv2.INTER_LINEAR)[0] for x in img0]

        # Stack
        img = np.stack(img, 0)

        # Normalize RGB
        img = img[:, :, :, ::-1].transpose(0, 3, 1, 2)  # BGR to RGB
        img = np.ascontiguousarray(img, dtype=np.float16 if self.half else np.float32)  # uint8 to fp16/fp32
        img /= 255.0  # 0 - 255 to 0.0 - 1.0

        return self.sources, img, img0, None 
开发者ID:zbyuan,项目名称:pruning_yolov3,代码行数:21,代码来源:datasets.py

示例5: main

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def main():
    device = cv2.CAP_OPENNI
    capture = cv2.VideoCapture(device)
    if not(capture.isOpened()):
        capture.open(device)

    capture.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
    capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)

    app = wx.App()
    frame = MyFrame(None, -1, 'chapter2.py', capture)
    frame.Show(True)
#   self.SetTopWindow(frame)
    app.MainLoop()

    # When everything done, release the capture
    capture.release()
    cv2.destroyAllWindows() 
开发者ID:PacktPublishing,项目名称:OpenCV-Computer-Vision-Projects-with-Python,代码行数:20,代码来源:chapter2.py

示例6: main

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def main():
    """
    Calibrate the live camera and optionally do a live display of the results
    """
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument("config", type=Path, help="camera config path")
    parser.add_argument("--height", type=int, default=4)
    parser.add_argument("--width", type=int, default=10)
    parser.add_argument("--count", type=int, default=10)
    parser.add_argument("--view", action="store_true")
    args = parser.parse_args()

    config = {"camera": derp.util.load_config(args.config)}
    camera = Camera(config)
    pattern_shape = (args.height, args.width)

    camera_matrix, distortion_coefficients = live_calibrate(camera, pattern_shape, args.count)
    print(camera_matrix)
    print(distortion_coefficients)
    if args.view:
        live_undistort(camera, camera_matrix, distortion_coefficients)
    cv2.destroyAllWindows() 
开发者ID:notkarol,项目名称:derplearning,代码行数:24,代码来源:calibrate_camera.py

示例7: display_multiple

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def display_multiple(images: List[Tuple[List, Optional[str]]]):
    """Displays one or more captures in a CV2 window. Useful for debugging

    Args:
        images: List of tuples containing MxNx3 pixel arrays and optional titles OR
            list of image data
    """
    for image in images:
        if isinstance(image, tuple):
            image_data = image[0]
        else:
            image_data = image

        if isinstance(image, tuple) and len(image) > 1:
            title = image[1]
        else:
            title = "Camera Output"

        cv2.namedWindow(title)
        cv2.moveWindow(title, 500, 500)
        cv2.imshow(title, image_data)
    cv2.waitKey(0)
    cv2.destroyAllWindows() 
开发者ID:BYU-PCCL,项目名称:holodeck,代码行数:25,代码来源:captures.py

示例8: write

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def write(self, filename, frames, fps, show=False):
        fps = max(1, fps)
        out = None

        try:
            for image in frames:
                frame = cv2.imread(image)
                if show:
                    cv2.imshow('video', frame)

                if not out:
                    height, width, channels = frame.shape
                    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
                    out = cv2.VideoWriter(filename, fourcc, 20, (width, height))

                out.write(frame)

        finally:
            out and out.release()
            cv2.destroyAllWindows() 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:22,代码来源:mp4.py

示例9: _run

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def _run(self, n_frames=500, width=1280, height=720, with_threading=False):
        if with_threading:
            cap = VideoCaptureTreading(0)
        else:
            cap = cv2.VideoCapture(0)
        cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
        cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
        if with_threading:
            cap.start()
        t0 = time.time()
        i = 0
        while i < n_frames:
            _, frame = cap.read()
            cv2.imshow('Frame', frame)
            cv2.waitKey(1) & 0xFF
            i += 1
        print('[i] Frames per second: {:.2f}, with_threading={}'.format(n_frames / (time.time() - t0), with_threading))
        if with_threading:
            cap.stop()
        cv2.destroyAllWindows() 
开发者ID:gilbertfrancois,项目名称:video-capture-async,代码行数:22,代码来源:videocapturethreading.py

示例10: preview

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def preview(self):
        """ Blocking function. Opens OpenCV window to display stream. """
        self.connect()
        win_name = 'RTSP'
        cv2.namedWindow(win_name, cv2.WINDOW_AUTOSIZE)
        cv2.moveWindow(win_name, 20, 20)

        while True:
            cv2.imshow(win_name, self.get_frame())
            # if self._latest is not None:
            #    cv2.imshow(win_name,self._latest)
            if cv2.waitKey(25) & 0xFF == ord('q'):
                break
        cv2.waitKey()
        cv2.destroyAllWindows()
        cv2.waitKey() 
开发者ID:Benehiko,项目名称:ReolinkCameraAPI,代码行数:18,代码来源:RtspClient.py

示例11: run

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def run(self):
        while cv2.getWindowProperty('img', 0) != -1 or cv2.getWindowProperty('watershed', 0) != -1:
            ch = cv2.waitKey(50)
            if ch == 27:
                break
            if ch >= ord('1') and ch <= ord('7'):
                self.cur_marker = ch - ord('0')
                print('marker: ', self.cur_marker)
            if ch == ord(' ') or (self.sketch.dirty and self.auto_update):
                self.watershed()
                self.sketch.dirty = False
            if ch in [ord('a'), ord('A')]:
                self.auto_update = not self.auto_update
                print('auto_update if', ['off', 'on'][self.auto_update])
            if ch in [ord('r'), ord('R')]:
                self.markers[:] = 0
                self.markers_vis[:] = self.img
                self.sketch.show()
        cv2.destroyAllWindows() 
开发者ID:makelove,项目名称:OpenCV-Python-Tutorial,代码行数:21,代码来源:watershed.py

示例12: show2

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def show2(im, allobj):
    for obj in allobj:
        cv2.rectangle(im,
            (obj[1], obj[2]), 
            (obj[3], obj[4]), 
            (0,0,255),2)
    cv2.imshow('result', im)
    cv2.waitKey()
    cv2.destroyAllWindows() 
开发者ID:AmeyaWagh,项目名称:Traffic_sign_detection_YOLO,代码行数:11,代码来源:misc.py

示例13: __del__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def __del__(self):
        global TERMINATE
        TERMINATE = True
        self.sock.close()
        try:
            cv2.destroyAllWindows()
        except:
            pass 
开发者ID:11ze,项目名称:The-chat-room,代码行数:10,代码来源:vachat.py

示例14: test_recognition

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def test_recognition(c1, c2):
    extracted_face1 = extract_face_features(gray1, face1[0], (c1, c2))
    print(predict_face_is_smiling(extracted_face1))
    extracted_face2 = extract_face_features(gray2, face2[0], (c1, c2))
    print(predict_face_is_smiling(extracted_face2))
    cv2.imshow('gray1', extracted_face1)
    cv2.imshow('gray2', extracted_face2)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

# test_recognition(0.3, 0.05)

# ------------------- LIVE FACE RECOGNITION ----------------------------------- 
开发者ID:its-izhar,项目名称:Emotion-Recognition-Using-SVMs,代码行数:15,代码来源:Train Classifier and Test Video Feed.py

示例15: __del__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import destroyAllWindows [as 别名]
def __del__(self):
        """Deconstructor to close window"""
        cv2.destroyAllWindows() 
开发者ID:notkarol,项目名称:derplearning,代码行数:5,代码来源:label.py


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