Opencv, Why it draws the contour(the yellow line) around the frame. What i want
ID: 3907103 • Letter: O
Question
Opencv, Why it draws the contour(the yellow line) around the frame. What i want is draw contour only 2 rectangle(blue rectangle) i dont need it draw around the frame (orange background). So how to fix it ,i would appreciate if you have sample code. Thanks Contour Edit Source Refactor Navigale 3 framegrabbe... getboujava Fra teistest va testest? java 0 zeroblue1 java D checklmage java Selectionlece. rectestavie é import org.opencv.core.Scalar: 17 izport org . opencv .core . size: 18 import org.opencv.imgcodecs.Imgcodecs: 9 import org.opencv.imgproc.Imgproc: 20 public class classiI 2 public statie void main (string argst1) System. loadLibrary(Core.NATIVE LIBRARY NAME) string filepathiosert IDesktopl Irectest. png": Hat inage- new Nat 0: inage- Ingcodecs. inread(filepathy: double maxarea - Mat asknew Mat 0: Core. inRange (inage, new Scalar (0,0,150), new Scalar (85, 85,255), mask); System.out.printin "tinished"): addweighted (mask, a.9, mask,-1.0, 0, mask): List atotPoint> contours new ArrayListcMatofPoint> Inproc.findcontours (nask, contours, new Mat ( , Imgproc.CHAIN APPROX NONE, Imgproc. CHAIN APPROX_SIMPLE) tinti-0; ?ccontours .size thi.? atotPoint currentcontour contours.get () double curtentarea Imaproc.contourArea (eurrentcontour) tor 1 mproc.dravcont.ours (inage, contours,i, new Scalar (0,255,0).1) erectangle Ingproc.boundingRect (currentcontour): proc.rectangie inage, rectangle.t1 0 rectangle.bro. new Scalar (255, 255, 255),5) tours(inage, contours. i,new Scalar (50,200,255),5): 1-mgcontour Image) iExplanation / Answer
import java.awt.Color; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Point; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class CoreControl { public static class Grid extends JPanel { private List fillCells; public Grid() { fillCells = new ArrayList(25); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); for (Point fillCell : fillCells) { int cellX = 10 + (fillCell.x * 10); int cellY = 10 + (fillCell.y * 10); g.setColor(Color.BLUE); g.fillRect(cellX, cellY, 10, 10); } g.setColor(Color.ORANGE); g.drawRect(10, 10, 800, 500); for (int i = 10; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.