diff --git a/opencv/cxtype.go b/opencv/cxtype.go index 9037ef0..984baa4 100644 --- a/opencv/cxtype.go +++ b/opencv/cxtype.go @@ -661,12 +661,6 @@ type Graph C.CvGraph type Chain C.CvChain type Contour C.CvContour -type ContourType struct { - mode C.int - method C.int - offset Point -} - const ( CV_RETR_EXTERNAL = C.CV_RETR_EXTERNAL CV_RETR_LIST = C.CV_RETR_LIST diff --git a/opencv/imgproc.go b/opencv/imgproc.go index 5d0676f..8861bab 100644 --- a/opencv/imgproc.go +++ b/opencv/imgproc.go @@ -53,13 +53,9 @@ func Crop(src *IplImage, x, y, width, height int) *IplImage { return dest } -func CreateContourType() *ContourType { - return &ContourType{mode: CV_RETR_EXTERNAL, method: CV_CHAIN_APPROX_SIMPLE, offset: Point{0, 0}} -} - -/* Returns a Seq of countours in an image, detected according to the parameters in ContourType. +/* Returns a Seq of countours in an image, detected according to the parameters. Caller must Release() the Seq returned */ -func (this *ContourType) FindContours(image *IplImage) *Seq { +func (image *IplImage) FindContours(mode, method int, offset Point) *Seq { storage := C.cvCreateMemStorage(0) header_size := (C.size_t)(unsafe.Sizeof(C.CvContour{})) var seq *C.CvSeq @@ -68,9 +64,9 @@ func (this *ContourType) FindContours(image *IplImage) *Seq { storage, &seq, C.int(header_size), - this.mode, - this.method, - C.cvPoint(C.int(this.offset.X), C.int(this.offset.Y))) + C.int(mode), + C.int(method), + C.cvPoint(C.int(offset.X), C.int(offset.Y))) return (*Seq)(seq) } diff --git a/opencv/imgproc_test.go b/opencv/imgproc_test.go index c986aec..9f4509b 100644 --- a/opencv/imgproc_test.go +++ b/opencv/imgproc_test.go @@ -77,8 +77,7 @@ func TestFindContours(t *testing.T) { defer edges.Release() Canny(grayscale, edges, 50, 200, 3) - contourType := CreateContourType() - seq := contourType.FindContours(edges) + seq := edges.FindContours(CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, Point{0, 0}) defer seq.Release() contours := CreateImage(grayscale.Width(), grayscale.Height(), grayscale.Depth(), grayscale.Channels())