Segmentation fault: GLib-CRITICAL error when calling opencv cv2.namedWindow('test')

Hi all

I have the following problem on a freshly installed Jetson Nano when I call cv2.namedWindow(‘test’).

This is a minimal program to reproduce the problem:

import cv2
cv2.namedWindow('test')

GLib-CRITICAL **: 16:07:09.319: g_once_init_leave: assertion ‘result != 0’ failed

I have installed tensorflow as per the instructions on the Jetson to overcome the initial “ImportError: numpy.core.multiarray failed to import”

This is under python 3.6 (there is no such error on python2)

Full stack below:

(python3.6:7732): GLib-GObject-WARNING **: 16:07:09.319: cannot register existing type 'GdkDisplayManager'
(python3.6:7732): GLib-CRITICAL **: 16:07:09.319: g_once_init_leave: assertion 'result != 0' failed
(python3.6:7732): GLib-GObject-CRITICAL **: 16:07:09.319: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed
(python3.6:7732): GLib-GObject-WARNING **: 16:07:09.319: invalid (NULL) pointer instance
(python3.6:7732): GLib-GObject-CRITICAL **: 16:07:09.319: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(python3.6:7732): GLib-GObject-WARNING **: 16:07:09.319: invalid (NULL) pointer instance
(python3.6:7732): GLib-GObject-CRITICAL **: 16:07:09.319: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(python3.6:7732): GLib-GObject-WARNING **: 16:07:09.325: cannot register existing type 'GdkDisplay'
(python3.6:7732): GLib-CRITICAL **: 16:07:09.325: g_once_init_leave: assertion 'result != 0' failed
(python3.6:7732): GLib-GObject-CRITICAL **: 16:07:09.325: g_type_register_static: assertion 'parent_type > 0' failed
(python3.6:7732): GLib-CRITICAL **: 16:07:09.325: g_once_init_leave: assertion 'result != 0' failed
(python3.6:7732): GLib-GObject-CRITICAL **: 16:07:09.325: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed
Segmentation fault (core dumped)

Other parts of opencv seem to be fine (in terms of reading/resizing images), but I cannot display them. I can use matplotlib, but I have feeling this will probably bite me later when I’m trying to grab images from a camera.

Any help would be greatly appreciated.

Many thanks

Mark

Hi,

Could you set this parameter to see if helps?

export DISPLAY=:0

Thanks.

Fantastic - thank you! Works like a charm.

I’ve added it to my .bashrc

Is there any reason this isn’t set by default?

Hi,

The default display should be the one which is executing the command.
In the remote use case, the application will try to enable the host display, which is usually limited.

Setting the parameter will tell x11 to use local display instead.

Thanks.