NVIDIA Jetson TX1 image display with imshow


I have followed this tutorial
and apply it using NVIDIA Jetson TX1 but I get an error
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in
imshow, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/highgui/src/window.cpp,
line 261
terminate called after throwing an instance of ‘cv::Exception’
what(): /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/highgui/src/window.cpp:261:
error: (-215) size.width>0 && size.height>0 in function imshow


I searched that error and found that it means that the image is empty meanwhile it is a valid image and it works properly when displayed with image viewer.
I couldn’t find solution to this error

Hi Omar_Merghany,
Is you error coming from imshow?

If so, please try to export ENV “export DISPLAY=:0” before running program.

Hi WayneWWW,
Thanks for your reply
I have tried to execute your command in the terminal and nothing changed.
I am not sure that the error is coming from “imshow”, I believe it came from the “imread” because I put if statement
cout<<“image not loaded”<<endl;}
and it displayed that message.

  • I do not know why it is not read the image itself.
    I am using HDMI cable to connect the screen but the screen boarder is cropped, Does this affect my problem and the screen need to be adjusted ?

I wonder your video has correct format. Could you share the code and video?

my code is as shown in the above video:
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/opencv.hpp>
#include <stdio.h>
int main()
cv::Mat img = cv::imread (“lena10.jpg”);
cv::namedWindow(“My Image”);

    std::cout<<"Image not loaded "<<std::endl;
cv::imshow("My Image", img);

return 1;


the picture is in the same directory as the code,

I wonder is there a problem in decoding the image.
Is there packages or some installation needed as the video did not mention any ?
Do I have to set the pipeline of “Gstreamer pipelines for Tegra X1”
https://developer.ridgerun.com/wiki/index.php?title=Gstreamer_pipelines_for_Tegra_X1 ?

Sorry for the late reply.

Do you fix your problem?

Thanks WayneWWW for your help.