-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cv2.imshow(img) is crashing the kernel #3935
Comments
I'm having a similar problem, the imshow() window is displayed it crashes when it would normally be destroyed. Even it's the last of 10 windows created and destroyed in a loop the last one will always freeze as the program moves on. Gives no errors when running identical code in a terminal. OSx Mojave 10.14.2 |
You can use this solution if you're using google colab: |
image is appearing too big.I use below code |
how to convert this to cv2_imshow? cv2.imshow('object detection', cv2.resize(image_np, (800, 600))) |
@Oshana just say - |
You can also consider using import matplotlib.pyplot as plt
import cv2
def cv2_imshow(a, **kwargs):
a = a.clip(0, 255).astype('uint8')
# cv2 stores colors as BGR; convert to RGB
if a.ndim == 3:
if a.shape[2] == 4:
a = cv2.cvtColor(a, cv2.COLOR_BGRA2RGBA)
else:
a = cv2.cvtColor(a, cv2.COLOR_BGR2RGB)
return plt.imshow(a, **kwargs) |
You can use this insted: |
This fix also works for opening image using imshow() function from OpenCV::
|
This is just showing some black blank image. |
Copying the mentioned function |
This approach worked for me, too. |
hi guys, here is the solution of the problem. If you are using a 64-bit machine, you will have to modify The full solution is like this:
|
Thank you. |
This is not a notebook issue and should probably have been redirected to ipykernel or ipython. However, the last few comments have been success stories, so, on that account, I'm closing this issue. |
If you have this issue, check if the numpy array is of type float, if so then multiply the array by 255. https://docs.opencv.org/2.4/modules/highgui/doc/user_interface.html?highlight=imshow#imshow |
As per title cv2.imshow(img) is crashing the server.
If we avoid
cv2.waitForKey()
andcv2.closeAllWindows()
, and keep the windows open, the notebook will continue running.Python version:
Kernel about:
To reproduce: (coming)
The text was updated successfully, but these errors were encountered: