You can draw makers on an image using the drawMarker() method of the org.opencv.imgproc.Imgproc class. This method accepts the following parameters −img − A Mat object representing the input image.position − An object of the class Point to specify the position of the marker.color − An object of the class Scalar to specify the color of the marker.markerType − An integer constant specifying the type of the marker.size − An integer value specifying the size of the marker.thickness − An integer value specifying the thickness of the marker.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.Point; import org.opencv.core.Scalar; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import ... Read More
The detect() method of the org.opencv.features2d.Feature2D (abstract) class detects the key points of the given image. To this method, you need to pass a Mat object representing the source image and an empty MatOfKeyPoint object to hold the read key points.The drawMatches() method of the org.opencv.features2d.Feature2D class finds the matches between the key points of the two given images and draws them. This method accepts the following parameters −src1 − An object of the Mat class representing the first source image.keypoints1 − An object of the MatOfKeyPoint class representing the Key points of the first source image.src2 − An object of the ... Read More
The detect() method of the org.opencv.features2d.Feature2D (abstract) class detects the key points of the given image. To this method, you need to pass a Mat the object representing the source image and an empty MatOfKeyPoint object to hold the read key points.You can draw the draw key points on the image using the drawKeypoints() method of the org.opencv.features2d.Features2d class.NoteSince Feature2D is an abstract class you need to instantiate one of its subclasses to invoke the detect() method. Here we have used the FastFeatureDetector class.Features2D and Features2d are two different classes of the package features2d don’t get confused...Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; ... Read More
Contours are nothing but the line joining all the points along the boundary of a particular shape. Using this you can −Find the shape of an object.Calculate the area of an object.Detect an object.Recognize an object.You can find the contours of various shapes, objects in an image using the findContours() method. In the same way you can drawYou can also find the area of the shapes in the given input images. To do so you need to invoke the contourArea() method of the Imgproc class. This method accepts the contour of a particular shape, finds and returns its area.ExampleFollowing java ... Read More
Contours are nothing but the line joining all the points along the boundary of a particular shape. Using this you can −Find the shape of an object.Calculate the area of an object.Detect an object.Recognize an object.You can find the contours of various shapes, objects in an image using the findContours() method. This method accepts the following parameters −A binary image.An empty list object of type MatOfPoint to store the contours.An empty Mat object to store the image topology.Two integer variables to specify the mode and method to find the contours of the given image.Exampleimport java.util.ArrayList; import java.util.Iterator; import java.util.List; import ... Read More
JShell tool has introduced in Java 9 that provides a fast and friendly environment that enables us to quickly explore, discover, and experiment with Java language features and extensive libraries.When the code entered into the JShell console, it is processed by JLine. It is a Java library that allows us to capture on a console. Once the code has been entered, it is parsed by JShell parser in order to determine its type (method, variable, etc.).JShell Parser is wrapped in a class with the following rules:All imports are placed at the top of this class.Variables, methods and class declarations become static members ... Read More
You can compute bitwise conjunction between two images using the bitwise_and() method of the org.opencv.core.Core class.This method accepts three Mat objects representing the source, destination and result matrices, calculates the bitwise conjunction of each every element in the source matrices and stores the result in the destination matrix.ExampleIn the following Java example we are converting an image into binary and gray scale and calculating the bitwise conjunction of the results.import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class BitwiseAndExample { public static void main(String args[]) throws Exception { //Loading the OpenCV core library ... Read More
Using color space protocol you can represent the colors in an image. There are several color spaces available in OpenCV some of them are −BGR − RGB is the most widely used color space in this, each pixel is actually formed by three different colors (intensity) values: red, blue and green, it is the default color space in OpenCV but it is stored as BGR.HSV − In HSV color space the different colors are formed by changing the hue, saturation, and brightness.CMK − This is a subtractive color space, in this the different colors are formed by subtracting the Cyan, ... Read More
You can drop an existing collection from MongoDB using the drop() method.Syntaxdb.coll.drop()Where, db is the database.coll is the collection (name) in which you want to insert the documentExampleAssume we have created 3 collections in a MongoDB database as shown below −> use sampleDatabase switched to db sampleDatabase > db.createCollection("students") { "ok" : 1 } > db.createCollection("teachers") { "ok" : 1 } > db.createCollection("sample") { "ok" : 1 } > show collections sample students teachersThe following query deletes the collection named sample.> db.sample.drop() true > show collections example students teachersUsing Java programIn Java, you can drop a collection using the in ... Read More
You can delete a document from an existing collection in MongoDB using the remove() method.Syntaxdb.coll.remove(DELLETION_CRITTERIA)Where, db is the database.coll is the collection (name) in which you want to insert the documentExampleAssume we have a collection named students in the MongoDB database with the following documents −{name:"Ram", age:26, city:"Mumbai"} {name:"Roja", age:28, city:"Hyderabad"} {name:"Ramani", age:35, city:"Delhi"}The following query deletes the document with name value as Ram.> db.test.remove({'name': 'Ram'}) WriteResult({ "nRemoved" : 1 }) > db.test.find() { "_id" : ObjectId("5e8700"), "name" : "Roja", "age" : 28, "city" : "Hyderabad" } { "_id" : ObjectId("5e4161"), "name" : "Ramani", "age" : 35, "city" : "Delhi" ... Read More