Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Image processing in Unity. Roi and dilate

$
0
0
Hi! I am working with the Opencv Unity plugin. I am trying to make a ROI and using dilate function, but i don't know how to do it. I dont understand how the type Mat works exactly, so if anyone could help me... I need to know how to implement the element in dilate function. Here is my code; Imgproc.cvtColor (imMat, hsvMat, Imgproc.COLOR_RGB2HSV); Imgproc.cvtColor(hsvMat,imBw,Imgproc.COLOR_RGB2GRAY); Imgproc.equalizeHist (imBw, imBw); Imgproc.GaussianBlur (imBw,imBw,new Size(25, 25),0); Imgproc.threshold (imBw, imBw, 0, 255, Imgproc.THRESH_BINARY | Imgproc.THRESH_OTSU); Imgproc.Canny (imBw, imCanny, 0.1, 20); //hough transform Imgproc.HoughLinesP (imCanny, lineas,2, Mathf.PI / 360, 50, 100,10); int[] linesArray = new int[lineas.cols () * lineas.rows () * lineas.channels ()]; lineas.get (0, 0, linesArray); int Ymin = 10000000, Ymax = 0; //print lines for (int i = 0; i < linesArray.Length; i=i+4) { //just the verticals lines if((Mathf.Abs(linesArray[i + 0]-linesArray [i + 2]))<(Mathf.Abs(linesArray [i + 1]-linesArray [i + 3]))){ if (linesArray [i + 0] < Ymin) {Ymin = linesArray [i + 0];} if (linesArray [i + 2] < Ymin) {Ymin = linesArray [i + 2];} if (linesArray [i + 0] > Ymax) {Ymax = linesArray [i + 0];} if (linesArray [i + 2] > Ymax) {Ymax = linesArray [i + 2];} Imgproc.line (imLineas, new Point (linesArray [i + 0], linesArray [i + 1]), new Point (linesArray [i + 2], linesArray [i + 3]), new Scalar (255,255,255), 1); } } //i want to create a roi here (with the Y parameters i found with the lines) Imgproc.findContours (/*here the roi*/, contornos, hier, Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE); for(int i=0; i

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>