error: (-215) mat.isContinuous() in function copyFrom
I run this simple code:
import cv2
im=cv2.imread('homer.jpg')
# 420 x 630
roi=im[0:209,0:209]
cv2.namedWindow('gl',cv2.WINDOW_OPENGL)
cv2.imshow('gl',roi)
cv2.waitKey(0)
cv2.destroyAllWindows()
I get this error each time I set the WINDOW_OPENGL flag with roi:
begueradj@begueradj-darwin:~/Desktop$ python here.py
(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 "here.py", line 9, in <module>
cv2.imshow('gl',roi)
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 ?
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 thank you, but it was just a typo. I get the error with roi
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 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.
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, thank you but i get strange results with it. I am going to try again GetSubRect
@berak you mean the flag does not disable that menu context in your case ?