cv.CreateMatND allocation problem (Bug #30)


Added by Vadim Pisarevsky about 15 years ago. Updated about 15 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:James Bowman % Done:

0%

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

Description

As reported by Jorge Scandaliaris:

"
Hi,
It seems as cv.CreateMatND() is not allocating memory (or something along the
line), contrary to what cv.CreateMat() does. Is this intended? I couldn't find
any warning in the docs, so I assume this is a bug, but if it isn't, how am I
supposed to use MatND from python?

Example with MatND:

In r2: import cv
In r3: import numpy as np
In r4: matnd = cv.CreateMatND((5,5),cv.CV_32FC1)
In r5: a = np.fromstring(matnd.tostring(), dtype = 'float32', count=25)
In r6: a
ViolaciĆ³n de segmento (Segmentation fault)

Now with Mat:

In r1: import cv
In r2: import numpy as np
In r3: mat = cv.CreateMat(5,5, cv.CV_32FC1)
In r4: a = np.fromstring(mat.tostring(), dtype = 'float32', count=25)
In r5: a
Outr5:
array([ 6.43756542e-34, 6.43760951e-34, 7.39426722e-34,
6.08832605e-34, 7.00819079e-34, 7.01185319e-34,
-1.30296248e-05, -1.30008557e-05, -1.26954692e-05,
7.15902508e-34, 7.01092749e-34, -1.30456174e-05,
-1.27425883e-05, 5.44992977e-34, 5.26212985e-34,
-1.30944827e-05, -1.30453263e-05, -1.30457047e-05,
-1.30005938e-05, -1.26384839e-05, -1.29979453e-05,
-1.29992259e-05, -1.29144173e-05, -1.26387749e-05,
-1.30708795e-05], dtype=float32)

Is there any workaround around this?

Cheers,

Jorge
"


Associated revisions

Revision 028fa775
Added by Marina Kolpakova about 12 years ago

Merge pull request #30 from jet47:new-gpu-demos-pack into 2.4

History

Updated by Jorge Scandaliaris about 15 years ago

Some more info. Further tests seem to indicate that CreateMatND() actually has allocated data, as OpenCV operations on the matrix work fine. I have working examples with histograms and ND matrices. What is not working is accessing the matrix data from python with the tostring() method. Element access works ok.

Updated by James Bowman about 15 years ago

Fixed in r2412

  • Status changed from Open to Done
  • (deleted custom field) set to fixed

Also available in: Atom PDF