How can I get data from the return object of pyrSegmentation

40 views
Skip to first unread message

HYRY

unread,
Jun 22, 2010, 6:07:43 PM6/22/10
to ctypes-opencv
Here is the code:
--------------------------
img = cv.imread("fruits.jpg")
img2 = img.clone()
storage = cv.createMemStorage()
result = cv.pyrSegmentation(img, img2, storage, 4, 200, 20)
--------------------------

the result is a CvSeq object:

In [2]: result
Out[2]: <pyopencv.pyopencvext.CvSeq object at 0x01A75C38>

I think result.first is the first element of this sequence:

In [4]: result.first
Out[4]: <pyopencv.pyopencvext.CvSeqBlock object at 0x02D05A08>

Searching for attributes of it:

In [5]: obj = result.first

In [6]: obj.
obj.__class__ obj.__module__ obj.__weakref__
obj.__delattr__ obj.__new__ obj.count
obj.__dict__ obj.__reduce__ obj.data
obj.__doc__ obj.__reduce_ex__ obj.next
obj.__format__ obj.__repr__ obj.prev
obj.__getattribute__ obj.__setattr__ obj.start_index
obj.__hash__ obj.__sizeof__ obj.this
obj.__init__ obj.__str__
obj.__instance_size__ obj.__subclasshook__

It looks obj.data is the information I need, but I can't access it:

In [10]: obj.data
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)

TypeError: No to_python (by-value) converter found for C++ type:
signed char

Minh-Tri Pham

unread,
Jul 16, 2010, 12:37:59 PM7/16/10
to ctypes...@googlegroups.com
Hi HYRY,

If you could tell me the type of every element stored in the CvSeq instance
returned by the cvPyrSegmentation(), I should be able to create a C++-style
Seq_XXXXX class (where XXXXX is the type of the elements) that provides
access to the elements of the CvSeq instance.

Cheers,
Minh-Tri

--
Dr. Minh-Tri Pham
Research Fellow, University of Surrey, UK
Email: t.p...@surrey.ac.uk or pmt...@gmail.com
Mob: +44 (0) 778 774 1089 | Tel: +44 (0) 148 368 4711

Reply all
Reply to author
Forward
0 new messages