Son Nguyen
Son Nguyen

Reputation: 3

OpenCV showing extra windows with black bar?

I am working with OpenCV on Python and just from yesterday I encountered a very weird problem.

When I call a very simple method, imshow(), the program always spawn additional windows which has the same name as the main one and a black bar at the central.

Sometime, there is no extra window called, while sometime there are like 50 or 100 windows spawns in forever loop.

It is very strange and I encountered it since yesterday, when I uninstalled the opencv-python library and downloaded opencv-contrib-python. The first time I had this problem, the console log also gave me warning about the lack of GTK-Cambera module

Gtk-Message: Failed to load module "canberra-gtk-module"

However, I did try to fix it and download libraries on Ubuntu so that the warning is gone now. Furthermore, I try to reverse the opencv library by remove opencv-contrib-python and reuse opencv-python instead. Unfortunately, the problem still occurs.

In addition, I have a feeling that the more power the programs need, the more chance the "additional window" will appear.

The code I implemented:

import numpy as np
import cv2

cap = cv2.VideoCapture(4)

while(cap.isOpened()):
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Our operations on the frame come here
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    # Display the resulting frame
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

Here is the image of the error:

Error showing

Upvotes: 0

Views: 224

Answers (1)

Sebastian Liendo
Sebastian Liendo

Reputation: 811

I don't have enough reputation to comment, but are you using opencv 4.3 by any chance? I had the same problem, so I just downgraded to 4.2.

Upvotes: 1

Related Questions