opencvsharp - Convert Point2f[] to Mat[] OpenCV -


i trying convert point2f[] mat[] using opencvsharp library , have no idea start. appreciated.

rect = cv2.minarearect(c) box = np.int0(cv2.cv.boxpoints(rect)) 

this code trying translate opencvsharp detect barcodes in python

this first time have used opencvsharp can in linked page except lines have include.

i think ienumerable<ienumerable<point>> overload looking rather mat based one.

i able working selecting point.point , wrapping in dummy array. here's whole code using example image link:

// using nuget package opencvsharp-anycpu 2.4.10.20140320.  var image = cv2.imread("barcode_01.jpg"); var gray = image.cvtcolor(opencvsharp.colorconversion.bgratogray); var gradx = gray.sobel(mattype.cv_32f, 1, 0, -1); var grady = gray.sobel(mattype.cv_32f, 0, 1, -1); var gradient = gray.emptyclone(); cv2.subtract(gradx, grady, gradient); cv2.convertscaleabs(gradient, gradient);          var kernel = cv2.getstructuringelement(structuringelementshape.rect, new size(21, 7)); var closed = (gradient.blur(new size(9,9)).threshold(225, 255, opencvsharp.thresholdtype.binary)).morphologyex(opencvsharp.morphologyoperation.close, kernel);             mat[] contours; var hierarchy = inputoutputarray.create(new list<vec4i>());             closed.erode(kernel, null, 4).dilate(kernel, null, 4).findcontours(out contours, hierarchy, opencvsharp.contourretrieval.external, opencvsharp.contourchain.approxsimple);             var c = contours.tolist().orderbydescending(mat => mat.contourarea(false)).firstordefault(); if (c != null) {     var rect = cv2.minarearect(c);     var box = new[] { rect.points().select(p2f => new point(p2f.x, p2f.y)) };     cv2.drawcontours(image, box, -1, new scalar(0, 255, 0), 3);     image.saveimage(@"out.png"); } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -