error: (-215) mat.isContinuous() in function copyFrom

asked 2015-04-13 07:39:22 -0600

begueradj gravatar image

updated 2015-04-13 07:54:29 -0600

I run this simple code:

import cv2    
# 420 x 630    

I get this error each time I set the WINDOW_OPENGL flag with roi:

begueradj@begueradj-darwin:~/Desktop$ python 
(420, 630, 3)
init done 
opengl support available 
OpenCV Error: Assertion failed (mat.isContinuous()) in copyFrom, file /home/begueradj/opencv/opencv-2.4.10/modules/core/src/opengl_interop.cpp, line 1151
Traceback (most recent call last):
  File "", line 9, in <module>
cv2.error: /home/begueradj/opencv/opencv-2.4.10/modules/core/src/opengl_interop.cpp:1151: error: (-215) mat.isContinuous() in function copyFrom

Note that this error disappears when I display im instead (with the same flag)

Why is this ? How to fix it ?

edit retag flag offensive close merge delete



im1 simply does not exist, is empty/invalid.

also, you should use an opengl window to render 3d (points), not to draw an image.

berak gravatar imageberak ( 2015-04-13 07:51:00 -0600 )edit

@berak thank you, but it was just a typo. I get the error with roi

begueradj gravatar imagebegueradj ( 2015-04-13 07:54:05 -0600 )edit

now, please explain, why you want an opengl window for this.

(the image needs to be uploaded to gpu, which is problematic with a ROI / non-continuous memory)

berak gravatar imageberak ( 2015-04-13 07:59:09 -0600 )edit

@berak The error exists when I set that flag. This is a fact. Why I use WINDOW_OPENGL flag ? Well, this is just a piece of code of a larger application I am doing. I need this flag otherwise when I right click on the mouse, I get a pop up menu contect related to QT , which does not let me to do what I want. This flag disables it.

begueradj gravatar imagebegueradj ( 2015-04-13 08:03:14 -0600 )edit

this flag does a lot more, than you expect ! (and is probably not appropriate here)

if you insist doing it this way, you'll need cv2.imshow('gl',roi.copy()) # deep copy makes continuous image

again, using opengl to avoid a qt-related context-menu problem sounds broken to me.

berak gravatar imageberak ( 2015-04-13 08:07:24 -0600 )edit

@berak, thank you but i get strange results with it. I am going to try again GetSubRect

begueradj gravatar imagebegueradj ( 2015-04-13 08:12:50 -0600 )edit

@berak you mean the flag does not disable that menu context in your case ?

begueradj gravatar imagebegueradj ( 2015-04-13 08:13:30 -0600 )edit