1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00

fix CvContour for enabling to call CvSeq's methods

This commit is contained in:
ser1zw 2012-08-20 18:06:22 +09:00
parent 2e82111ee0
commit ae94135979
2 changed files with 7 additions and 6 deletions

View file

@ -80,8 +80,7 @@ define_ruby_class()
VALUE VALUE
rb_allocate(VALUE klass) rb_allocate(VALUE klass)
{ {
CvContour *ptr; return Data_Wrap_Struct(klass, mark_root_object, unregister_object, NULL);
return Data_Make_Struct(klass, CvContour, mark_root_object, unregister_object, ptr);
} }
VALUE VALUE
@ -95,15 +94,15 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
else else
storage = CHECK_CVMEMSTORAGE(storage); storage = CHECK_CVMEMSTORAGE(storage);
CvContour* contour = (CvContour*)DATA_PTR(self);
try { try {
contour = (CvContour*)cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvContour), DATA_PTR(self) = (CvContour*)cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvContour),
sizeof(CvPoint), CVMEMSTORAGE(storage)); sizeof(CvPoint), CVMEMSTORAGE(storage));
} }
catch (cv::Exception& e) { catch (cv::Exception& e) {
raise_cverror(e); raise_cverror(e);
} }
register_root_object((CvSeq*)contour, storage); cCvSeq::register_elem_class(CVSEQ(self), cCvPoint::rb_class());
register_root_object(CVSEQ(self), storage);
return self; return self;
} }

View file

@ -22,6 +22,8 @@ VALUE rb_class();
void define_ruby_class(); void define_ruby_class();
VALUE seqblock_class(void *ptr); VALUE seqblock_class(void *ptr);
void register_elem_class(CvSeq *seq, VALUE klass);
void unregister_elem_class(void *ptr);
VALUE rb_allocate(VALUE klass); VALUE rb_allocate(VALUE klass);