Matrix slice operations on images fail (Bug #1393)


Added by Ulrik Stephansen about 3 years ago. Updated almost 2 years ago.


Status:Done Start date:
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:python bindings
Target version:2.4.3
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

Doing simple matrix slice operations on images makes subsequent OpenCV methods working on the same image fail, i.e.:

Extracting a single channel:

1import cv2
2image = cv2.imread('door.png')
3image = image[:,:,1]
4cv2.imshow(u'Image', image)
5cv2.waitKey()

will output:
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /tmp/homebrew-opencv-2.3.1a-SZiB/OpenCV-2.3.1/modules/core/src/array.cpp, line 2482
Traceback (most recent call last):
  File "./bwe.py", line 8, in <module>
    cv2.imshow(u'Image', image)
cv2.error: /tmp/homebrew-opencv-2.3.1a-SZiB/OpenCV-2.3.1/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat

Another example: Mirroring the image:

1import cv2
2image = cv2.imread('door.png')
3image = image[:,-1::-1,:]
4cv2.imshow(u'Image', image)
5cv2.waitKey()

will output:
OpenCV Error: Assertion failed (src.dims <= 2 && esz <= (size_t)32) in transpose, file /tmp/homebrew-opencv-2.3.1a-SZiB/OpenCV-2.3.1/modules/core/src/matrix.cpp, line 1680
terminate called throwing an exceptionAbort trap: 6

The funny thing is that inserting the following line of code after the matrix slice operation (line 3) will make both examples work as expected without errors:

image = image * 1

I'm using Mac OS X 10.7.1 with Xcode 4.1, Python 2.7.2 and OpenCV 2.3.1a; with Python and OpenCV installed using Homebrew.


Related issues (Add)


Associated revisions

Revision d652cc72
Added by Vadim Pisarevsky about 2 years ago

fixed bugs #2100 (kind of) and #1393

[edit: cleaned whitespace]

History

Updated by Pieter Eendebak about 3 years ago

I can confirm this issue on Ubuntu 11.10, Python 2.7.2

Updated by Alexander Shishkov over 2 years ago

  • Description changed from Doing simple matrix slice operations on images makes subsequent [[OpenCV]] me... to Doing simple matrix slice operations on images makes subsequent OpenCV method... More

Updated by Alexander Shishkov over 2 years ago

  • Description changed from Doing simple matrix slice operations on images makes subsequent OpenCV method... to Doing simple matrix slice operations on images makes subsequent OpenCV method... More
  • Target version deleted ()

Updated by Alexander Shishkov over 2 years ago

  • Assignee deleted (Vadim Pisarevsky)

Updated by Alexander Shishkov over 2 years ago

  • Target version deleted ()

Updated by Vadim Pisarevsky about 2 years ago

I think, it relates to #2100

  • Target version deleted ()

Updated by Kirill Kornyakov almost 2 years ago

  • Target version set to Next Hackathon

Updated by Vadim Pisarevsky almost 2 years ago

Actually, the problem has been fixed about a week ago in 2.4 branch

  • Status changed from Open to Done
  • Target version changed from Next Hackathon to 2.4.3
  • Assignee set to Vadim Pisarevsky

Also available in: Atom PDF