Python cv2.moveWindow() Examples

The following are 30 code examples of cv2.moveWindow(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cv2 , or try the search function .
Example #1
Source File: pcrender.py    From midlevel-reps with MIT License 6 votes vote down vote up
def renderToScreenSetup(self):
        cv2.namedWindow('RGB cam')
        cv2.namedWindow('Depth cam')
        #if MAKE_VIDEO:
        #    cv2.moveWindow('RGB cam', -1 , self.showsz + LINUX_OFFSET['y_delta'])
        #    cv2.moveWindow('Depth cam', self.showsz + LINUX_OFFSET['x_delta'] + LINUX_OFFSET['y_delta'], -1)
        cv2.namedWindow('RGB prefilled')
        cv2.namedWindow('Semantics')
        cv2.namedWindow('Surface Normal')
        #    cv2.moveWindow('Surface Normal', self.showsz + self.showsz + LINUX_OFFSET['x_delta'] + LINUX_OFFSET['y_delta'], -1)
        #    cv2.moveWindow('RGB prefilled', self.showsz + LINUX_OFFSET['x_delta'] + LINUX_OFFSET['y_delta'], self.showsz + LINUX_OFFSET['y_delta'])
        #    cv2.moveWindow('Semantics', self.showsz + self.showsz + LINUX_OFFSET['x_delta'] + LINUX_OFFSET['y_delta'], self.showsz + LINUX_OFFSET['y_delta'])
        #elif HIGH_RES_MONITOR:
        #    cv2.moveWindow('RGB cam', -1 , self.showsz + LINUX_OFFSET['y_delta'])
        #    cv2.moveWindow('Depth cam', self.showsz + LINUX_OFFSET['x_delta'] + LINUX_OFFSET['y_delta'], self.showsz + LINUX_OFFSET['y_delta'])
        #
        #if LIVE_DEMO:
        #    cv2.moveWindow('RGB cam', -1 , 768)
        #    cv2.moveWindow('Depth cam', 512, 768) 
Example #2
Source File: img.py    From HUAWEIOCR-2019 with MIT License 6 votes vote down vote up
def imshow(winname, img, block = True, position = None, maximized = False, rgb = False):
    if isinstance(img, str):
        img = imread(path = img)
    
    cv2.namedWindow(winname, cv2.WINDOW_NORMAL)
    if rgb:
        img = rgb2bgr(img)
    cv2.imshow(winname, img)
    if position is not None:
#         cv2.moveWindow(winname, position[0], position[1])
        move_win(winname, position)
    
    if maximized:
        maximize_win(winname)  
        
        
    if block:
#         cv2.waitKey(0)
        event.wait_key(" ")
        cv2.destroyAllWindows() 
Example #3
Source File: img.py    From HUAWEIOCR-2019 with MIT License 6 votes vote down vote up
def imshow(winname, img, block = True, position = None, maximized = False, rgb = False):
    if isinstance(img, str):
        img = imread(path = img)
    
    cv2.namedWindow(winname, cv2.WINDOW_NORMAL)
    if rgb:
        img = rgb2bgr(img)
    cv2.imshow(winname, img)
    if position is not None:
#         cv2.moveWindow(winname, position[0], position[1])
        move_win(winname, position)
    
    if maximized:
        maximize_win(winname)  
        
        
    if block:
#         cv2.waitKey(0)
        event.wait_key(" ")
        cv2.destroyAllWindows() 
Example #4
Source File: img.py    From HUAWEIOCR-2019 with MIT License 6 votes vote down vote up
def imshow(winname, img, block = True, position = None, maximized = False, rgb = False):
    if isinstance(img, str):
        img = imread(path = img)
    
    cv2.namedWindow(winname, cv2.WINDOW_NORMAL)
    if rgb:
        img = rgb2bgr(img)
    cv2.imshow(winname, img)
    if position is not None:
#         cv2.moveWindow(winname, position[0], position[1])
        move_win(winname, position)
    
    if maximized:
        maximize_win(winname)  
        
        
    if block:
#         cv2.waitKey(0)
        event.wait_key(" ")
        cv2.destroyAllWindows() 
Example #5
Source File: LiveViewer.py    From RMS with GNU General Public License v3.0 6 votes vote down vote up
def updateImage(self, img, text, pause_time, banner_text=""):
        """ Update the image on the screen. 
        
        Arguments:
            img: [2D ndarray] Image to show on the screen as a numpy array.
            text: [str] Text that will be printed on the image.
        """

        img = drawText(img, text)

        if not banner_text:
            banner_text = "LiveViewer"

        # Update the image on the screen
        cv2.imshow(banner_text, img)

        # If this is the first image, move it to the upper left corner
        if self.first_image:
            
            cv2.moveWindow(banner_text, 0, 0)

            self.first_image = False


        cv2.waitKey(int(1000*pause_time)) 
Example #6
Source File: preview.py    From rtsp with MIT License 6 votes vote down vote up
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) 
Example #7
Source File: pose_utils.py    From hrnet with MIT License 6 votes vote down vote up
def plot_boxes(image, boxes, IDs, im_name=None):
    for i in range(len(boxes)):
        box = boxes[i]
        ID = IDs[i]
        bpt0, bpt1 = (int(box[0]), int(box[1])), (int(box[2]), int(box[3]))
        cv2.rectangle(image, bpt0, bpt1, colors[i], 3)
        cv2.putText(image, str(ID), bpt0, fontFace=font, fontScale=fontScale, color=colors[i], thickness=5)

    if not im_name:
        winname = 'image'
    else:
        winname = im_name
    cv2.namedWindow(winname)        # Create a named window
    cv2.moveWindow(winname, 1000,800)  # Move it to (40,30)
    cv2.imshow(winname, image)
    cv2.waitKey(950)
    if im_name:
        cv2.imwrite('test_imgs/' + im_name, image)
    #  cv2.destroyAllWindows() 
Example #8
Source File: utilitys.py    From hrnet with MIT License 6 votes vote down vote up
def plot_boxes(image, boxes, IDs, im_name=None):
    for i in range(len(boxes)):
        box = boxes[i]
        ID = IDs[i]
        bpt0, bpt1 = (int(box[0]), int(box[1])), (int(box[2]), int(box[3]))
        cv2.rectangle(image, bpt0, bpt1, colors[i], 3)
        cv2.putText(image, str(ID), bpt0, fontFace=font, fontScale=fontScale, color=colors[i], thickness=5)

    if not im_name:
        winname = 'image'
    else:
        winname = im_name
    cv2.namedWindow(winname)        # Create a named window
    cv2.moveWindow(winname, 1000,800)  # Move it to (40,30)
    cv2.imshow(winname, image)
    cv2.waitKey(950)
    if im_name:
        cv2.imwrite('test_imgs/' + im_name, image)
    #  cv2.destroyAllWindows() 
Example #9
Source File: wrapper.py    From AutoMask with MIT License 6 votes vote down vote up
def _show_modulate(im, score_viz):
        """
        show the current activations on top of the current crop
        """
        if score_viz is None: return # modulation is not active

        im = cv2.resize(im, (MEDIATE_SIZE, MEDIATE_SIZE)).astype(np.uint8)
        canvas = np.zeros([im.shape[0], im.shape[1], 3], dtype=np.uint8)

        # calculate the color map
        score_im_base = cv2.resize(score_viz[0], im.shape[:2])
        score_im_base = (255*score_im_base).astype(np.uint8)
        im_color = cv2.applyColorMap(score_im_base, cv2.COLORMAP_JET)

        # show the image
        overlayed_im = cv2.addWeighted(im, 0.8, im_color, 0.7, 0)
        canvas[:, :im.shape[1], :] = overlayed_im
        cv2.imshow('modulated', canvas)
        cv2.moveWindow('modulated', 1200, 800) 
Example #10
Source File: vis_utils.py    From PVN3D with MIT License 6 votes vote down vote up
def cv2_show_image(window_name, image,
                   size_wh=None, location_xy=None):
    """Helper function for specifying window size and location when
    displaying images with cv2.

    Args:
        window_name: str window name
        image: ndarray image to display
        size_wh: window size (w, h)
        location_xy: window location (x, y)
    """

    if size_wh is not None:
        cv2.namedWindow(window_name,
                        cv2.WINDOW_KEEPRATIO | cv2.WINDOW_GUI_NORMAL)
        cv2.resizeWindow(window_name, *size_wh)
    else:
        cv2.namedWindow(window_name, cv2.WINDOW_AUTOSIZE)

    if location_xy is not None:
        cv2.moveWindow(window_name, *location_xy)

    cv2.imshow(window_name, image) 
Example #11
Source File: wrapper.py    From THOR with MIT License 6 votes vote down vote up
def _show_modulate(im, score_viz):
        """
        show the current activations on top of the current crop
        """
        if score_viz is None: return # modulation is not active

        im = cv2.resize(im, (MEDIATE_SIZE, MEDIATE_SIZE)).astype(np.uint8)
        canvas = np.zeros([im.shape[0], im.shape[1], 3], dtype=np.uint8)

        # calculate the color map
        score_im_base = cv2.resize(score_viz[0], im.shape[:2])
        score_im_base = (255*score_im_base).astype(np.uint8)
        im_color = cv2.applyColorMap(score_im_base, cv2.COLORMAP_JET)

        # show the image
        overlayed_im = cv2.addWeighted(im, 0.8, im_color, 0.7, 0)
        canvas[:, :im.shape[1], :] = overlayed_im
        cv2.imshow('modulated', canvas)
        cv2.moveWindow('modulated', 1200, 800) 
Example #12
Source File: augment.py    From Real-time-Text-Detection with Apache License 2.0 6 votes vote down vote up
def show_pic(img, bboxes=None, name='pic'):
    '''
    输入:
        img:图像array
        bboxes:图像的所有boudning box list, 格式为[[x_min, y_min, x_max, y_max]....]
        names:每个box对应的名称
    '''
    show_img = img.copy()
    if not isinstance(bboxes, np.ndarray):
        bboxes = np.array(bboxes)
    for point in bboxes.astype(np.int):
        cv2.line(show_img, tuple(point[0]), tuple(point[1]), (255, 0, 0), 2)
        cv2.line(show_img, tuple(point[1]), tuple(point[2]), (255, 0, 0), 2)
        cv2.line(show_img, tuple(point[2]), tuple(point[3]), (255, 0, 0), 2)
        cv2.line(show_img, tuple(point[3]), tuple(point[0]), (255, 0, 0), 2)
    # cv2.namedWindow(name, 0)  # 1表示原图
    # cv2.moveWindow(name, 0, 0)
    # cv2.resizeWindow(name, 1200, 800)  # 可视化的图片大小
    cv2.imshow(name, show_img)


# 图像均为cv2读取 
Example #13
Source File: cv_bridge_demo.py    From Learning-Robotics-using-Python-Second-Edition with MIT License 6 votes vote down vote up
def show_img_cb(self,event):
    	try: 


		cv2.namedWindow("RGB_Image", cv2.WINDOW_NORMAL)
		cv2.moveWindow("RGB_Image", 25, 75)
		
		cv2.namedWindow("Processed_Image", cv2.WINDOW_NORMAL)
		cv2.moveWindow("Processed_Image", 500, 75)

        	# And one for the depth image
		cv2.moveWindow("Depth_Image", 950, 75)
		cv2.namedWindow("Depth_Image", cv2.WINDOW_NORMAL)


        	cv2.imshow("RGB_Image",self.frame)
        	cv2.imshow("Processed_Image",self.display_image)
        	cv2.imshow("Depth_Image",self.depth_display_image)
      		cv2.waitKey(3)
    	except:
		pass 
Example #14
Source File: captures.py    From holodeck with MIT License 6 votes vote down vote up
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() 
Example #15
Source File: RtspClient.py    From ReolinkCameraAPI with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #16
Source File: opencv_windows_management.py    From OpenCV-Python-Tutorial with MIT License 6 votes vote down vote up
def show(self):
        lenw = len(self.windows)
        w_l = int(self.screen_size[0] / lenw)

        max_num_line = math.ceil(math.sqrt(lenw))  # 取平方根
        # TODO 权重

        for i, name in enumerate(self.windows):
            # if (i+1) >max_num_line:
            #     #TODO 换行
            #     cv2.moveWindow(name, w_l * i, h_x*j)
            #     pass

            win = self.windows[name]
            image = win.image
            # image = self.windows[name]
            # h_x = int(image.shape[1] / w_l * image.shape[0]) #保持比例
            h_x = int(w_l / win.lenght_y * win.hight_x)  # 保持比例
            # print((w_l,h_x))
            img2 = cv2.resize(image, (w_l, h_x))
            cv2.moveWindow(name, w_l * i, 0)
            cv2.imshow(name, img2) 
Example #17
Source File: vis_utils.py    From ip_basic with MIT License 6 votes vote down vote up
def cv2_show_image(window_name, image,
                   size_wh=None, location_xy=None):
    """Helper function for specifying window size and location when
    displaying images with cv2.

    Args:
        window_name: str window name
        image: ndarray image to display
        size_wh: window size (w, h)
        location_xy: window location (x, y)
    """

    if size_wh is not None:
        cv2.namedWindow(window_name,
                        cv2.WINDOW_KEEPRATIO | cv2.WINDOW_GUI_NORMAL)
        cv2.resizeWindow(window_name, *size_wh)
    else:
        cv2.namedWindow(window_name, cv2.WINDOW_AUTOSIZE)

    if location_xy is not None:
        cv2.moveWindow(window_name, *location_xy)

    cv2.imshow(window_name, image) 
Example #18
Source File: main.py    From FaceSwap with MIT License 6 votes vote down vote up
def videoize(func, args, src = 0, win_name = "Cam", delim_wait = 1, delim_key = 27):
    cap = cv2.VideoCapture(src)
    while(1):
        ret, frame = cap.read()
        # To speed up processing; Almost real-time on my PC
        frame = cv2.resize(frame, dsize=None, fx=0.5, fy=0.5)
        frame = cv2.flip(frame, 1)
        out = func(frame, args)
        if out is None:
            continue
        out = cv2.resize(out, dsize=None, fx=1.4, fy=1.4)
        cv2.imshow(win_name, out)
        cv2.moveWindow(win_name, (s_w - out.shape[1])/2, (s_h - out.shape[0])/2)
        k = cv2.waitKey(delim_wait)

        if k == delim_key:
            cv2.destroyAllWindows()
            cap.release()
            return 
Example #19
Source File: cv_bridge_demo.py    From Learning-Robotics-using-Python-Second-Edition with MIT License 6 votes vote down vote up
def show_img_cb(self,event):
    	try: 


		cv2.namedWindow("RGB_Image", cv2.WINDOW_NORMAL)
		cv2.moveWindow("RGB_Image", 25, 75)
		
		cv2.namedWindow("Processed_Image", cv2.WINDOW_NORMAL)
		cv2.moveWindow("Processed_Image", 500, 75)

        	# And one for the depth image
		cv2.moveWindow("Depth_Image", 950, 75)
		cv2.namedWindow("Depth_Image", cv2.WINDOW_NORMAL)


        	cv2.imshow("RGB_Image",self.frame)
        	cv2.imshow("Processed_Image",self.display_image)
        	cv2.imshow("Depth_Image",self.depth_display_image)
      		cv2.waitKey(3)
    	except:
		pass 
Example #20
Source File: util.py    From OpenCV-Video-Label with GNU General Public License v3.0 5 votes vote down vote up
def get_rect(im, title='get_rect'):
    mouse_params = {'tl': None, 'br': None, 'current_pos': None,
                    'released_once': False}

    cv2.namedWindow(title)
    cv2.moveWindow(title, 100, 100)

    def onMouse(event, x, y, flags, param):

        param['current_pos'] = (x, y)

        if param['tl'] is not None and not (flags & cv2.EVENT_FLAG_LBUTTON):
            param['released_once'] = True

        if flags & cv2.EVENT_FLAG_LBUTTON:
            if param['tl'] is None:
                param['tl'] = param['current_pos']
            elif param['released_once']:
                param['br'] = param['current_pos']

    cv2.setMouseCallback(title, onMouse, mouse_params)
    cv2.imshow(title, im)

    while mouse_params['br'] is None:
        im_draw = np.copy(im)

        if mouse_params['tl'] is not None:
            cv2.rectangle(im_draw, mouse_params['tl'],
                          mouse_params['current_pos'], (255, 0, 0))

        cv2.imshow(title, im_draw)
        _ = cv2.waitKey(10)

    cv2.destroyWindow(title)

    tl = (min(mouse_params['tl'][0], mouse_params['br'][0]),
          min(mouse_params['tl'][1], mouse_params['br'][1]))
    br = (max(mouse_params['tl'][0], mouse_params['br'][0]),
          max(mouse_params['tl'][1], mouse_params['br'][1]))

    return (tl, br) 
Example #21
Source File: img.py    From HUAWEIOCR-2019 with MIT License 5 votes vote down vote up
def move_win(winname, position = (0, 0)):
    """
    move pyplot window
    """
    cv2.moveWindow(winname, position[0], position[1]) 
Example #22
Source File: wrapper.py    From THOR with MIT License 5 votes vote down vote up
def _show_templates(self, mode='lt'):
        if mode=='st' and not self._cfg.K_st: return
        mem = self.st_module if mode=='st' else self.lt_module
        y_plot = 50 if mode=='st' else 300

        temp_canvas = mem.canvas.copy()
        cv2.imshow(f"Templates {mode}", temp_canvas)
        cv2.moveWindow(f"Templates {mode}", 1200, y_plot) 
Example #23
Source File: img.py    From HUAWEIOCR-2019 with MIT License 5 votes vote down vote up
def move_win(winname, position = (0, 0)):
    """
    move pyplot window
    """
    cv2.moveWindow(winname, position[0], position[1]) 
Example #24
Source File: pdf-to-csv-cv.py    From pdf-to-csv-table-extactor with Do What The F*ck You Want To Public License 5 votes vote down vote up
def show_wait_destroy(winname, img):
    cv2.namedWindow(winname,cv2.WINDOW_NORMAL)
    cv2.imshow(winname, img)
    cv2.resizeWindow(winname, 1000,800)
    cv2.moveWindow(winname, 500, 0)
    cv2.waitKey(0)
    cv2.destroyWindow(winname) 
Example #25
Source File: Detection.py    From RMS with GNU General Public License v3.0 5 votes vote down vote up
def show2(name, img):
    """ Show the given image. """

    cv2.imshow(name, img)
    cv2.moveWindow(name, 0, 0)
    cv2.waitKey(0)
    cv2.destroyWindow(name) 
Example #26
Source File: Detection.py    From RMS with GNU General Public License v3.0 5 votes vote down vote up
def show(name, img):
    """ COnvert the given image to uint8 and show it. """

    cv2.imshow(name, img.astype(np.uint8)*255)
    cv2.moveWindow(name, 0, 0)
    cv2.waitKey(0)
    cv2.destroyWindow(name) 
Example #27
Source File: xavier_surveillance.py    From homesecurity with MIT License 5 votes vote down vote up
def open_display_window(width, height):
    """Open the cv2 window for displaying images with bounding boxeses."""
    cv2.namedWindow(WINDOW_NAME, cv2.WINDOW_NORMAL)
    cv2.resizeWindow(WINDOW_NAME, width, height)
    cv2.moveWindow(WINDOW_NAME, 0, 0)
    cv2.setWindowTitle(WINDOW_NAME, WINDOW_NAME)
    set_full_screen(True) 
Example #28
Source File: display_video.py    From image-processing-pipeline with MIT License 5 votes vote down vote up
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__() 
Example #29
Source File: icon.py    From IkaLog with Apache License 2.0 5 votes vote down vote up
def normalize_icon_image(self, img):
        h, w = img.shape[0:2]

        laplacian_threshold = 60
        img_laplacian = cv2.Laplacian(img, cv2.CV_64F)
        img_laplacian_abs = cv2.convertScaleAbs(img_laplacian)
        img_laplacian_gray = \
            cv2.cvtColor(img_laplacian_abs, cv2.COLOR_BGR2GRAY)
        ret, img_laplacian_mask = \
            cv2.threshold(img_laplacian_gray, laplacian_threshold, 255, 0)
        out_img = self.down_sample_2d(img_laplacian_mask, 12, 12)

        if False:
            cv2.imshow('orig', cv2.resize(img, (160, 160)))
            cv2.imshow('laplacian_abs', cv2.resize(
                img_laplacian_abs, (160, 160)))
            cv2.imshow('laplacian_gray', cv2.resize(
                img_laplacian_gray, (160, 160)))
            cv2.imshow('out', cv2.resize(out_img, (160, 160)))
            cv2.moveWindow('orig', 80, 20)
            cv2.moveWindow('laplacian_abs', 80, 220)
            cv2.moveWindow('laplacian_gray', 80, 420)
            cv2.moveWindow('out', 80, 820)
            ch = 0xFF & cv2.waitKey(1)
            if ch == ord('q'):
                sys.exit()
        return [
            out_img,
            img,
            img,  # ununsed
        ]

    # Define feature extraction algorithm. 
Example #30
Source File: ffmpegstream.py    From rtsp with MIT License 5 votes vote down vote up
def preview(self):
        """ Blocking function. Opens OpenCV window to display stream. """
        win_name = 'Camera'
        cv2.namedWindow(win_name, cv2.WINDOW_AUTOSIZE)
        cv2.moveWindow(win_name,20,20)
        self.open()
        while(self.isOpened()):
            cv2.imshow(win_name,self._stream.read()[1])
            if cv2.waitKey(25) & 0xFF == ord('q'):
                break
        cv2.waitKey()
        cv2.destroyAllWindows()
        cv2.waitKey()